summaryrefslogtreecommitdiffstats
path: root/layout/tools/reftest/b2g_start_script.js
diff options
context:
space:
mode:
Diffstat (limited to 'layout/tools/reftest/b2g_start_script.js')
-rw-r--r--layout/tools/reftest/b2g_start_script.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/layout/tools/reftest/b2g_start_script.js b/layout/tools/reftest/b2g_start_script.js
new file mode 100644
index 000000000..7c368412f
--- /dev/null
+++ b/layout/tools/reftest/b2g_start_script.js
@@ -0,0 +1,57 @@
+/* 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/. */
+
+const { utils: Cu, classes: Cc, interfaces: Ci } = Components;
+
+function setPermissions() {
+ if (__webDriverArguments.length < 2) {
+ return;
+ }
+
+ let serverAddr = __webDriverArguments[0];
+ let serverPort = __webDriverArguments[1];
+ let perms = Cc["@mozilla.org/permissionmanager;1"]
+ .getService(Ci.nsIPermissionManager);
+ let ioService = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+ let uri = ioService.newURI("http://" + serverAddr + ":" + serverPort, null, null);
+ perms.add(uri, "allowXULXBL", Ci.nsIPermissionManager.ALLOW_ACTION);
+}
+
+var cm = Cc["@mozilla.org/categorymanager;1"]
+ .getService(Ci.nsICategoryManager);
+
+// Disable update timers that cause b2g failures.
+if (cm) {
+ cm.deleteCategoryEntry("update-timer", "nsUpdateService", false);
+}
+
+// Load into any existing windows
+var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Ci.nsIWindowMediator);
+var win = wm.getMostRecentWindow('');
+
+setPermissions();
+
+// Loading this into the global namespace causes intermittent failures.
+// See bug 882888 for more details.
+var reftest = {};
+Cu.import("chrome://reftest/content/reftest.jsm", reftest);
+
+// Prevent display off during testing.
+navigator.mozPower.screenEnabled = true;
+var settingLock = navigator.mozSettings.createLock();
+var settingResult = settingLock.set({
+ 'screen.timeout': 0
+});
+settingResult.onsuccess = function () {
+ dump("Set screen.time to 0\n");
+ // Start the reftests
+ reftest.OnRefTestLoad(win);
+}
+settingResult.onerror = function () {
+ dump("Change screen.time failed\n");
+ // Start the reftests
+ reftest.OnRefTestLoad(win);
+}