Back out bc8eeacc3c8a (bug 843893) for (at least) desktop bustage in test_power_basics.html
authorPhil Ringnalda <philringnalda@gmail.com>
Tue, 19 Mar 2013 14:27:55 -0700
changeset 125506 2e9988148b18c31f4e5faef1bace455a6bedd24c
parent 125505 42caf484567704e1cee9918c63e37afd7d7a41c4
child 125507 d72d29f6a92c8051a7b9c6b8bf521fed86ceda3a
push id24459
push useremorley@mozilla.com
push dateWed, 20 Mar 2013 11:46:36 +0000
treeherdermozilla-central@1d6fe70c79c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs843893
milestone22.0a1
backs outbc8eeacc3c8a8bd02241fab8d3fe3e7ceaaf1200
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
Back out bc8eeacc3c8a (bug 843893) for (at least) desktop bustage in test_power_basics.html
dom/alarm/test/test_alarm_non_permitted_app.html
dom/power/test/Makefile.in
dom/power/test/test_power_basics.html
dom/power/test/test_power_non_permitted_app.html
--- a/dom/alarm/test/test_alarm_non_permitted_app.html
+++ b/dom/alarm/test/test_alarm_non_permitted_app.html
@@ -1,50 +1,35 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test Non-Permitted Application for Alarm API</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
 <script type="application/javascript">
 
 "use strict";
 
-function alarmtests() {
-  SimpleTest.waitForExplicitFinish();
-
-  SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
+SimpleTest.waitForExplicitFinish();
 
-    // 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();
-  });
+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");
+  }
 
-if(!SpecialPowers.hasPermission("alarms", document)) {
-  var head = document.getElementsByTagName('head')[0];
-  var js = document.createElement("script");
-  js.type = "application/javascript";
-  js.src = "/tests/SimpleTest/SimpleTest.js";
-  js.onload = alarmtests;
-  head.appendChild(js);
-  
-} else {
-  SpecialPowers.removePermission("alarms", document);
-  window.location = window.location; 
-}
-
+  SimpleTest.finish();
+});
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/power/test/Makefile.in
+++ b/dom/power/test/Makefile.in
@@ -8,16 +8,15 @@ srcdir           = @srcdir@
 VPATH            = @srcdir@
 
 relativesrcdir   = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_FILES = \
   test_power_basics.html \
-  test_power_non_permitted_app.html \
   $(NULL)
 
 MOCHITEST_BROWSER_FILES = \
   browser_bug697132.js \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/dom/power/test/test_power_basics.html
+++ b/dom/power/test/test_power_basics.html
@@ -1,27 +1,52 @@
 <!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"/>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
 <script type="application/javascript">
 
 /** Test for Power API **/
 
 ok('mozPower' in navigator, "navigator.mozPower should exist");
 
 /** Test permission **/
+// In b2g, addPermission 'power' is only working after a document reload
+// See bug 802312
 
-power = navigator.mozPower;
-ok(power, "Should be able to access power manager with permission.");
+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.");
+
+  SpecialPowers.addPermission("power", true, 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.");
 
+  SpecialPowers.removePermission("power", 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.");
+  SimpleTest.finish();
+}
 </script>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<iframe onload="startTest()"></iframe>
+<pre id="test">
 </pre>
 </body>
 </html>
deleted file mode 100644
--- a/dom/power/test/test_power_non_permitted_app.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Power API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Power API **/
-
-function powertests() {
-  SimpleTest.waitForExplicitFinish();
-  power = navigator.mozPower;
-  ok(!power, "Shouldn't be able to access power manager without permission.");
-  SimpleTest.finish();
-}
-
-if(!SpecialPowers.hasPermission("power", document)) {
-  var head = document.getElementsByTagName('head')[0];
-  var js = document.createElement("script");
-  js.type = "application/javascript";
-  js.src = "/tests/SimpleTest/SimpleTest.js";
-  js.onload = powertests;
-  head.appendChild(js);
-
-} else {
-  SpecialPowers.removePermission("power", document);
-  window.location = window.location;
-}
-
-</script>
-</pre>
-</body>
-</html>