Bug 843893 - Fix alarm and power mochitests, r=gene.lian
authorDavid Clarke <dclarke@mozilla.com>
Mon, 25 Mar 2013 16:50:06 -0700
changeset 126185 0edebdda6d5ae82ab05f404e9a9fd38fd2d30b3e
parent 126184 5b6a1e103c82f4cc3bfbbc8c31274b8560f4b9ed
child 126186 623c2704b45bb9166e9d36a329fabc7bbc29e05b
push id25333
push userjgriffin@mozilla.com
push dateMon, 25 Mar 2013 23:50:23 +0000
treeherdermozilla-inbound@0edebdda6d5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgene.lian
bugs843893
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 843893 - Fix alarm and power mochitests, r=gene.lian
dom/alarm/test/test_alarm_non_permitted_app.html
dom/alarm/test/test_alarm_permitted_app.html
dom/power/moz.build
dom/power/test/test_power_basics.html
testing/mochitest/b2g.json
--- a/dom/alarm/test/test_alarm_non_permitted_app.html
+++ b/dom/alarm/test/test_alarm_non_permitted_app.html
@@ -9,27 +9,30 @@
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
 <script type="application/javascript">
 
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
-
-SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
+if (SpecialPowers.hasPermission("alarms", document)) {
   SpecialPowers.removePermission("alarms", document);
+  window.location.reload();
+} else {
+  SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
+    SpecialPowers.removePermission("alarms", document);
 
-  // mozAlarms is intalled on all platforms except Android for the moment.
-  if (navigator.appVersion.indexOf("Android") != -1) {
-    ok(!('mozAlarms' in navigator), "navigator.mozAlarms should not exist");
-  } else {
-    ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
-    is(navigator.mozAlarms, null, "navigator.mozAlarms should return null");
-  }
-
-  SimpleTest.finish();
-});
-
+    // mozAlarms is intalled on all platforms except Android for the moment.
+    if (navigator.appVersion.indexOf("Android") != -1) {
+      ok(!('mozAlarms' in navigator), "navigator.mozAlarms should not exist");
+    } else {
+      ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
+      is(navigator.mozAlarms, null, "navigator.mozAlarms should return null");
+    }
+    SpecialPowers.addPermission("alarms", true, document);
+    SimpleTest.finish();
+  });
+}
 </script>
 </pre>
 </body>
 </html>
--- a/dom/alarm/test/test_alarm_permitted_app.html
+++ b/dom/alarm/test/test_alarm_permitted_app.html
@@ -23,16 +23,15 @@ SpecialPowers.pushPrefEnv({"set": [["dom
     ok(!('mozAlarms' in navigator), "navigator.mozAlarms should not exist");
   } else {
     ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
     ok(navigator.mozAlarms, "navigator.mozAlarms should return an object");
     ok(navigator.mozAlarms instanceof SpecialPowers.Ci.nsIDOMMozAlarmsManager,
       "navigator.mozAlarms should be an nsIDOMMozAlarmsManager object");
   }
 
-  SpecialPowers.removePermission("alarms", document);
   SimpleTest.finish();
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/power/moz.build
+++ b/dom/power/moz.build
@@ -1,14 +1,15 @@
 # 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_DIRS += ['test']
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+    TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'nsIDOMPowerManager.idl',
     'nsIDOMWakeLock.idl',
     'nsIDOMWakeLockListener.idl',
     'nsIPowerManagerService.idl',
 ]
 
--- a/dom/power/test/test_power_basics.html
+++ b/dom/power/test/test_power_basics.html
@@ -14,34 +14,34 @@ ok('mozPower' in navigator, "navigator.m
 // In b2g, addPermission 'power' is only working after a document reload
 // See bug 802312
 
 SimpleTest.waitForExplicitFinish();
 
 function startTest() {
   window.frames[0].frameElement.setAttribute('onload', 'doTest2()');
   power = window.frames[0].navigator.mozPower;
-  ok(!power, "Shouldn't be able to access power manager without permission.");
+  ok(power, "Should be able to access power manager with permission.");
 
-  SpecialPowers.addPermission("power", true, window.frames[0].document);
+  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, "Should be able to access power manager with permission.");
+  ok(!power, "Shouldn't be able to access power manager with permission.");
 
-  SpecialPowers.removePermission("power", window.frames[0].document);
+  SpecialPowers.addPermission("power",true, window.frames[0].document);
   window.frames[0].location.reload();
 }
 
 function doTest3() {
   power = window.frames[0].navigator.mozPower;
-  ok(!power, "Shouldn't be able to access power manager without permission.");
+  ok(power, "Should be able to access power manager with permission.");
   SimpleTest.finish();
 }
 </script>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
--- a/testing/mochitest/b2g.json
+++ b/testing/mochitest/b2g.json
@@ -16,18 +16,16 @@
         "content/base/test/test_object.html":"",
         "content/base/test/test_bug282547.html":"",
         "content/base/test/test_bug282547.html":"",
         "content/events/test/test_focus_disabled.html":"",
 	"content/base/test/test_xbl_userdata.xhtml":"",
 	"content/base/test/test_CSP_evalscript.html":"",
 	"content/base/test/test_CSP_frameancestors.html":"",
 	"content/base/test/test_CSP_inlinescript.html":"",
-	"dom/alarm/test/test_alarm_non_permitted_app.html":"",
-	"dom/power/test/test_power_basics.html":"",
 	"content/svg/content/test/test_text_selection.html":"",
 	"content/base/test/test_CSP.html" : "",
 	"content/base/test/test_CrossSiteXHR_origin.html" : "",
         "content/base/test/test_CrossSiteXHR.html": "",
 	"content/base/test/test_XHRSendData.html" : "",
 	"content/base/test/test_XHR_parameters.html" : "",
 	"content/base/test/test_XHR_system.html" : "",
 	"content/base/test/test_base.xhtml" : "",