Bug 1286530 - Switch mozPower mochitests to chrome draft
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Fri, 06 May 2016 18:37:00 +0200
changeset 387117 3ae567ce23ef85fa338a64eec850a91724232d29
parent 387116 1c7a02a36bec9bb5e5aa653b3f32bd2c799b561a
child 387118 986b826556b732a11cc1aeebcc96d39d8bc349b2
push id22896
push userbmo:lissyx+mozillians@lissyx.dyndns.org
push dateWed, 13 Jul 2016 13:02:44 +0000
bugs1286530
milestone50.0a1
Bug 1286530 - Switch mozPower mochitests to chrome MozReview-Commit-ID: 2JFLIqsTsmy
dom/html/test/chrome.ini
dom/html/test/mochitest.ini
dom/html/test/test_audio_wakelock.html
dom/html/test/test_video_wakelock.html
dom/power/moz.build
dom/power/test/browser_wakelocks.js
dom/power/test/chrome.ini
dom/power/test/mochitest.ini
dom/power/test/test_power_basics.html
dom/power/test/test_power_set_cpusleepallowed.html
dom/power/test/test_power_set_key_light_enabled.html
dom/power/test/test_power_set_screen_brightness.html
dom/power/test/test_power_set_screen_enabled.html
--- a/dom/html/test/chrome.ini
+++ b/dom/html/test/chrome.ini
@@ -1,6 +1,12 @@
 [DEFAULT]
-skip-if = buildapp == 'b2g' || os == 'android'
 support-files =
   file_anchor_ping.html
+  wakelock.ogg
+  wakelock.ogv
 
 [test_anchor_ping.html]
+skip-if = buildapp == 'b2g' || os == 'android'
+[test_audio_wakelock.html]
+skip-if = buildapp == 'mulet' # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables.
+[test_video_wakelock.html]
+skip-if = toolkit == 'android' || (toolkit == 'gonk' && debug) #bug 871015, bug 881443
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -194,30 +194,26 @@ support-files =
   form_submit_server.sjs
   formData_worker.js
   formData_test.js
   image.png
   image-allow-credentials.png
   image-allow-credentials.png^headers^
   nnc_lockup.gif
   reflect.js
-  wakelock.ogg
-  wakelock.ogv
   file_ignoreuserfocus.html
   simpleFileOpener.js
   file_mozaudiochannel.html
   file_bug1166138_1x.png
   file_bug1166138_2x.png
   file_bug1166138_def.png
 
 [test_a_text.html]
 [test_anchor_href_cache_invalidation.html]
 [test_applet_attributes_reflection.html]
-[test_audio_wakelock.html]
-skip-if = buildapp == 'mulet' # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables.
 [test_base_attributes_reflection.html]
 [test_bug100533.html]
 [test_bug109445.html]
 [test_bug109445.xhtml]
 [test_bug1297.html]
 [test_bug1366.html]
 [test_bug1400.html]
 [test_bug143220.html]
@@ -539,18 +535,16 @@ skip-if = buildapp == 'mulet' || buildap
 [test_rowscollection.html]
 [test_srcdoc-2.html]
 [test_srcdoc.html]
 [test_style_attributes_reflection.html]
 [test_track.html]
 [test_track_disabled.html]
 [test_ul_attributes_reflection.html]
 [test_undoManager.html]
-[test_video_wakelock.html]
-skip-if = toolkit == 'android' || (toolkit == 'gonk' && debug) #bug 871015, bug 881443
 [test_input_files_not_nsIFile.html]
 [test_ignoreuserfocus.html]
 [test_fragment_form_pointer.html]
 [test_bug1682.html]
 [test_bug1823.html]
 [test_bug57600.html]
 [test_bug196523.html]
 skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
--- a/dom/html/test/test_audio_wakelock.html
+++ b/dom/html/test/test_audio_wakelock.html
@@ -1,19 +1,19 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=868943
 -->
 <head>
   <title>Test for Bug 868943</title>
   <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=868943">Mozilla Bug 868943</a>
 <p id="display"></p>
 <div id="content">
 </div>
 <pre id="test">
 <script type="application/javascript">
@@ -110,20 +110,16 @@ function runTests() {
     SimpleTest.finish();
     return;
   }
 
   var test =  tests.pop();
   test();
 };
 
-SpecialPowers.pushPermissions(
-  [{'type': 'power', 'allow': true, 'context': document}],
-  function() {
-    SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500]]}, runTests);
-  });
+SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500]]}, runTests);
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/html/test/test_video_wakelock.html
+++ b/dom/html/test/test_video_wakelock.html
@@ -1,19 +1,19 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=868943
 -->
 <head>
   <title>Test for Bug 868943</title>
   <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=868943">Mozilla Bug 868943</a>
 <p id="display"></p>
 <div id="content">
 </div>
 <pre id="test">
 <script type="application/javascript">
@@ -182,21 +182,17 @@ function runTests() {
     SimpleTest.finish();
     return;
   }
 
   var test =  tests.pop();
   test();
 };
 
-SpecialPowers.pushPermissions(
-  [{'type': 'power', 'allow': true, 'context': document}],
-  function() {
-    SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500],
-                                       ["dom.wakelock.enabled", true]]}, runTests);
-  });
+SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500],
+                                   ["dom.wakelock.enabled", true]]}, runTests);
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/power/moz.build
+++ b/dom/power/moz.build
@@ -27,9 +27,10 @@ UNIFIED_SOURCES += [
     'WakeLock.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
+MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
 BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
--- a/dom/power/test/browser_wakelocks.js
+++ b/dom/power/test/browser_wakelocks.js
@@ -222,15 +222,11 @@ function runNextStep() {
   if (gCurStepIndex < gSteps.length) {
     gSteps[gCurStepIndex]();
   } else {
     finish();
   }
 }
 
 function test() {
-  SpecialPowers.pushPermissions([
-    {type: "power", allow: true, context: kUrlSource}
-  ], function () {
-    SpecialPowers.pushPrefEnv({"set": [["dom.wakelock.enabled", true]]},
-                              runNextStep);
-  });
+  SpecialPowers.pushPrefEnv({"set": [["dom.wakelock.enabled", true]]},
+                            runNextStep);
 }
new file mode 100644
--- /dev/null
+++ b/dom/power/test/chrome.ini
@@ -0,0 +1,9 @@
+[test_power_basics.html]
+[test_power_set_cpusleepallowed.html]
+skip-if = toolkit != "gonk"
+[test_power_set_screen_brightness.html]
+skip-if = toolkit != "gonk"
+[test_power_set_screen_enabled.html]
+skip-if = toolkit != "gonk"
+[test_power_set_key_light_enabled.html]
+skip-if = toolkit != "gonk"
--- a/dom/power/test/mochitest.ini
+++ b/dom/power/test/mochitest.ini
@@ -1,13 +1,4 @@
 [test_bug957893.html]
 [test_bug957899.html]
 [test_wakelock_not_exposed.html]
 skip-if = appname == "b2g" || buildapp == "mulet"
-[test_power_basics.html]
-[test_power_set_cpusleepallowed.html]
-skip-if = toolkit != "gonk"
-[test_power_set_screen_brightness.html]
-skip-if = toolkit != "gonk"
-[test_power_set_screen_enabled.html]
-skip-if = toolkit != "gonk"
-[test_power_set_key_light_enabled.html]
-skip-if = toolkit != "gonk"
--- a/dom/power/test/test_power_basics.html
+++ b/dom/power/test/test_power_basics.html
@@ -1,45 +1,29 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for Power API</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 <script type="application/javascript">
 
 /** Test for Power API **/
 
-/** Test permission **/
-// In b2g, addPermission 'power' is only working after a document reload
-// See bug 802312
-
 SimpleTest.waitForExplicitFinish();
 
 function startTest() {
-  SpecialPowers.pushPermissions([
-    {type: "power", allow: true, context: window.frames[0].document}
-  ], doTest1);
+  doTest1();
 }
 
 function doTest1() {
-  window.frames[0].frameElement.setAttribute('onload', 'doTest2()');
+  window.frames[0].frameElement.setAttribute('onload', 'doTest3()');
   power = window.frames[0].navigator.mozPower;
   ok(power, "Should be able to access power manager with permission.");
 
-  SpecialPowers.removePermission("power", window.frames[0].document);
-  window.frames[0].location.reload();
-}
-
-function doTest2() {
-  window.frames[0].frameElement.setAttribute('onload', 'doTest3()');
-  power = window.frames[0].navigator.mozPower;
-  ok(!power, "Shouldn't be able to access power manager with permission.");
-
-  SpecialPowers.addPermission("power",true, window.frames[0].document);
   window.frames[0].location.reload();
 }
 
 function doTest3() {
   power = window.frames[0].navigator.mozPower;
   ok(power, "Should be able to access power manager with permission.");
   SimpleTest.finish();
 }
--- a/dom/power/test/test_power_set_cpusleepallowed.html
+++ b/dom/power/test/test_power_set_cpusleepallowed.html
@@ -1,15 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="utf-8">
   <title>Test Enabling/Disabling CPU Sleep with Power Management API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
   <script type="application/javascript">
 
   "use strict";
@@ -36,26 +36,20 @@
     testDisableSleep();
     testEnableSleep();
 
     SimpleTest.finish();
   }
 
   SimpleTest.expectAssertions(0, 9);
   SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("power", document)) {
-    // Currently only applicable on FxOS
-    if (navigator.userAgent.indexOf("Mobile") != -1 &&
-        navigator.appVersion.indexOf("Android") == -1) {
-      startTests();
-    } else {
-      ok(true, "mozPower on Firefox OS only.");
-      SimpleTest.finish();
-    }
+  // Currently only applicable on FxOS
+  if (navigator.userAgent.indexOf("Mobile") != -1 &&
+      navigator.appVersion.indexOf("Android") == -1) {
+     startTests();
   } else {
-    // Add the permission and reload so it's propogated
-    SpecialPowers.addPermission("power", true, document);
-    window.location.reload();
+    ok(true, "mozPower on Firefox OS only.");
+    SimpleTest.finish();
   }
   </script>
 </pre>
 </body>
 </html>
--- a/dom/power/test/test_power_set_key_light_enabled.html
+++ b/dom/power/test/test_power_set_key_light_enabled.html
@@ -1,15 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="utf-8">
   <title>Test Enabling/Disabling Screen with Power Management API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
   <script type="application/javascript">
 
   "use strict";
@@ -39,26 +39,20 @@
 
     testDisableKeyLight();
     testEnableKeyLight();
 
     SimpleTest.finish();
   }
 
   SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("power", document)) {
-    // Currently only applicable on FxOS
-    if (navigator.userAgent.indexOf("Mobile") != -1 &&
-        navigator.appVersion.indexOf("Android") == -1) {
-      startTests();
-    } else {
-      ok(true, "mozPower on Firefox OS only.");
-      SimpleTest.finish();
-    }
+  // Currently only applicable on FxOS
+  if (navigator.userAgent.indexOf("Mobile") != -1 &&
+      navigator.appVersion.indexOf("Android") == -1) {
+    startTests();
   } else {
-    // Add the permission and reload so it's propogated
-    SpecialPowers.addPermission("power", true, document);
-    window.location.reload();
+    ok(true, "mozPower on Firefox OS only.");
+    SimpleTest.finish();
   }
   </script>
 </pre>
 </body>
 </html>
--- a/dom/power/test/test_power_set_screen_brightness.html
+++ b/dom/power/test/test_power_set_screen_brightness.html
@@ -1,15 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="utf-8">
   <title>Test Setting Screen Brightness with Power Management API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
   <script type="application/javascript">
 
   "use strict";
@@ -51,26 +51,20 @@
 
   function fuzzyEq(a, b) {
     var epsilon = 0.002;
     return Math.abs(a - b) < epsilon;
   }
 
   SimpleTest.expectAssertions(0, 9);
   SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("power", document)) {
-    // Currently only applicable on FxOS
-    if (navigator.userAgent.indexOf("Mobile") != -1 &&
-        navigator.appVersion.indexOf("Android") == -1) {
-      startTests();
-    } else {
-      ok(true, "mozPower on Firefox OS only.");
-      SimpleTest.finish();
-    }
+  // Currently only applicable on FxOS
+  if (navigator.userAgent.indexOf("Mobile") != -1 &&
+      navigator.appVersion.indexOf("Android") == -1) {
+    startTests();
   } else {
-    // Add the permission and reload so it's propogated
-    SpecialPowers.addPermission("power", true, document);
-    window.location.reload();
+    ok(true, "mozPower on Firefox OS only.");
+    SimpleTest.finish();
   }
   </script>
 </pre>
 </body>
 </html>
--- a/dom/power/test/test_power_set_screen_enabled.html
+++ b/dom/power/test/test_power_set_screen_enabled.html
@@ -1,15 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="utf-8">
   <title>Test Enabling/Disabling Screen with Power Management API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
   <script type="application/javascript">
 
   "use strict";
@@ -40,26 +40,20 @@
     testDisableScreen();
     testEnableScreen();
 
     SimpleTest.finish();
   }
 
   SimpleTest.expectAssertions(0, 9);
   SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("power", document)) {
-    // Currently only applicable on FxOS
-    if (navigator.userAgent.indexOf("Mobile") != -1 &&
-        navigator.appVersion.indexOf("Android") == -1) {
-      startTests();
-    } else {
-      ok(true, "mozPower on Firefox OS only.");
-      SimpleTest.finish();
-    }
+  // Currently only applicable on FxOS
+  if (navigator.userAgent.indexOf("Mobile") != -1 &&
+      navigator.appVersion.indexOf("Android") == -1) {
+    startTests();
   } else {
-    // Add the permission and reload so it's propogated
-    SpecialPowers.addPermission("power", true, document);
-    window.location.reload();
+    ok(true, "mozPower on Firefox OS only.");
+    SimpleTest.finish();
   }
   </script>
 </pre>
 </body>
 </html>