summaryrefslogtreecommitdiffstats
path: root/mobile/android/tests/browser/robocop/roboextender
diff options
context:
space:
mode:
Diffstat (limited to 'mobile/android/tests/browser/robocop/roboextender')
-rw-r--r--mobile/android/tests/browser/robocop/roboextender/Makefile.in9
-rw-r--r--mobile/android/tests/browser/robocop/roboextender/base/robocop_home_banner.html37
-rw-r--r--mobile/android/tests/browser/robocop/roboextender/base/robocop_prompt_gridinput.html51
-rw-r--r--mobile/android/tests/browser/robocop/roboextender/bootstrap.js65
-rw-r--r--mobile/android/tests/browser/robocop/roboextender/chrome.manifest1
-rw-r--r--mobile/android/tests/browser/robocop/roboextender/install.rdf19
-rw-r--r--mobile/android/tests/browser/robocop/roboextender/moz.build12
7 files changed, 194 insertions, 0 deletions
diff --git a/mobile/android/tests/browser/robocop/roboextender/Makefile.in b/mobile/android/tests/browser/robocop/roboextender/Makefile.in
new file mode 100644
index 000000000..07d7992ac
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/roboextender/Makefile.in
@@ -0,0 +1,9 @@
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+TEST_EXTENSIONS_DIR = $(DEPTH)/_tests/testing/mochitest/extensions
+
+tools::
+ -cp $(DEPTH)/mobile/android/tests/javaaddons/javaaddons-test.apk $(TEST_EXTENSIONS_DIR)/roboextender@mozilla.org/base
diff --git a/mobile/android/tests/browser/robocop/roboextender/base/robocop_home_banner.html b/mobile/android/tests/browser/robocop/roboextender/base/robocop_home_banner.html
new file mode 100644
index 000000000..9a9456604
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/roboextender/base/robocop_home_banner.html
@@ -0,0 +1,37 @@
+<html>
+ <head>
+ <title>HomeBanner test page</title>
+ <meta name="viewport" content="initial-scale=1.0"/>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript">
+Components.utils.import("resource://gre/modules/Messaging.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("resource://gre/modules/Home.jsm");
+
+const TEXT = "The quick brown fox jumps over the lazy dog.";
+
+function start() {
+ var test = location.hash.substring(1);
+ window[test]();
+}
+
+var messageId;
+
+function addMessage() {
+ messageId = Home.banner.add({
+ text: TEXT,
+ onshown: function() {
+ Messaging.sendRequest({ type: "TestHomeBanner:MessageShown" });
+ },
+ ondismiss: function() {
+ Messaging.sendRequest({ type: "TestHomeBanner:MessageDismissed" });
+ }
+ });
+ Messaging.sendRequest({ type: "TestHomeBanner:MessageAdded" });
+}
+
+ </script>
+ </head>
+ <body onload="start();">
+ </body>
+</html>
diff --git a/mobile/android/tests/browser/robocop/roboextender/base/robocop_prompt_gridinput.html b/mobile/android/tests/browser/robocop/roboextender/base/robocop_prompt_gridinput.html
new file mode 100644
index 000000000..733683c16
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/roboextender/base/robocop_prompt_gridinput.html
@@ -0,0 +1,51 @@
+<html>
+ <head>
+ <title>IconGrid test page</title>
+ <meta name="viewport" content="initial-scale=1.0"/>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript">
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("resource://gre/modules/Prompt.jsm");
+
+function start() {
+ var test = location.hash.substring(1);
+ window[test]();
+}
+
+function test1() {
+ var p = new Prompt({
+ title: "Prompt 1",
+ buttons: [
+ "OK"
+ ],
+ }).addIconGrid({
+ items: [
+ { iconUri: "drawable://alert_camera", name: "Icon 1", selected: true },
+ { iconUri: "drawable://alert_download", name: "Icon 2" },
+ { iconUri: "drawable://icon", name: "Icon 3" },
+ { iconUri: "drawable://icon", name: "Icon 4" },
+ { iconUri: "drawable://icon", name: "Icon 5" },
+ { iconUri: "drawable://icon", name: "Icon 6" },
+ { iconUri: "drawable://icon", name: "Icon 7" },
+ { iconUri: "drawable://icon", name: "Icon 8" },
+ { iconUri: "drawable://icon", name: "Icon 9" },
+ { iconUri: "drawable://icon", name: "Icon 10" },
+ { iconUri: "drawable://icon", name: "Icon 11" },
+ ]
+ });
+ p.show(function(data) {
+ sendResult(data.icongrid0 == 10, "Got result " + data.icongrid0);
+ });
+}
+
+function sendResult(pass, message) {
+ setTimeout(function() {
+ alert((pass ? "PASS " : "FAIL ") + message);
+ }, 1000);
+}
+ </script>
+ </head>
+ <body onload="start();">
+ </body>
+</html>
diff --git a/mobile/android/tests/browser/robocop/roboextender/bootstrap.js b/mobile/android/tests/browser/robocop/roboextender/bootstrap.js
new file mode 100644
index 000000000..e903aa3f6
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/roboextender/bootstrap.js
@@ -0,0 +1,65 @@
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cu = Components.utils;
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+function loadIntoWindow(window) {}
+function unloadFromWindow(window) {}
+
+function _sendMessageToJava (aMsg) {
+ return Services.androidBridge.handleGeckoMessage(aMsg);
+};
+
+/*
+ bootstrap.js API
+*/
+var windowListener = {
+ onOpenWindow: function(aWindow) {
+ // Wait for the window to finish loading
+ let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+ domWindow.addEventListener("load", function() {
+ domWindow.removeEventListener("load", arguments.callee, false);
+ if (domWindow) {
+ domWindow.addEventListener("scroll", function(e) {
+ let message = {
+ type: 'robocop:scroll',
+ y: XPCNativeWrapper.unwrap(e.target).documentElement.scrollTop,
+ height: XPCNativeWrapper.unwrap(e.target).documentElement.scrollHeight,
+ cheight: XPCNativeWrapper.unwrap(e.target).documentElement.clientHeight,
+ };
+ _sendMessageToJava(message);
+ });
+ }
+ }, false);
+ },
+ onCloseWindow: function(aWindow) { },
+ onWindowTitleChange: function(aWindow, aTitle) { }
+};
+
+function startup(aData, aReason) {
+ let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
+
+ // Load into any new windows
+ wm.addListener(windowListener);
+ Services.obs.addObserver(function observe(aSubject, aTopic, aData) {
+ dump("Robocop:Quit received -- requesting quit");
+ let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
+ appStartup.quit(Ci.nsIAppStartup.eForceQuit);
+ }, "Robocop:Quit", false);
+}
+
+function shutdown(aData, aReason) {
+ // When the application is shutting down we normally don't have to clean up any UI changes
+ if (aReason == APP_SHUTDOWN) return;
+
+ let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
+
+ // Stop watching for new windows
+ wm.removeListener(windowListener);
+}
+
+function install(aData, aReason) { }
+function uninstall(aData, aReason) { }
+
diff --git a/mobile/android/tests/browser/robocop/roboextender/chrome.manifest b/mobile/android/tests/browser/robocop/roboextender/chrome.manifest
new file mode 100644
index 000000000..7467f91a6
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/roboextender/chrome.manifest
@@ -0,0 +1 @@
+content roboextender base/ \ No newline at end of file
diff --git a/mobile/android/tests/browser/robocop/roboextender/install.rdf b/mobile/android/tests/browser/robocop/roboextender/install.rdf
new file mode 100644
index 000000000..cbf66e884
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/roboextender/install.rdf
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>roboextender@mozilla.org</em:id>
+ <em:type>2</em:type>
+ <em:name>Robocop Extender</em:name>
+ <em:version>1.0</em:version>
+ <em:bootstrap>true</em:bootstrap>
+ <em:creator>Joel Maher</em:creator>
+ <em:targetApplication>
+ <Description>
+ <em:id>toolkit@mozilla.org</em:id>
+ <em:minVersion>10.0</em:minVersion>
+ <em:maxVersion>*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+ </Description>
+</RDF>
+
diff --git a/mobile/android/tests/browser/robocop/roboextender/moz.build b/mobile/android/tests/browser/robocop/roboextender/moz.build
new file mode 100644
index 000000000..e2388a2b8
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/roboextender/moz.build
@@ -0,0 +1,12 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+TEST_HARNESS_FILES.testing.mochitest.extensions['roboextender@mozilla.org'] += [
+ 'base/**',
+ 'bootstrap.js',
+ 'chrome.manifest',
+ 'install.rdf',
+]