Bug 958689 - Fix intermittent errors in networkstats tests. r=ettseng, a=test-only
authorAlbert Crespell <alberto.crespellperez@telefonica.com>
Sat, 16 May 2015 09:47:54 +0200
changeset 260547 ad098fdd6f81
parent 260546 bee6825f6c92
child 260548 013da2859c88
push id815
push userryanvm@gmail.com
push date2015-05-21 17:19 +0000
treeherdermozilla-release@3ef925962765 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersettseng, test-only
bugs958689
milestone38.0.5
Bug 958689 - Fix intermittent errors in networkstats tests. r=ettseng, a=test-only
dom/network/tests/mochitest.ini
dom/network/tests/test_networkstats_alarms.html
dom/network/tests/test_networkstats_basics.html
dom/network/tests/test_networkstats_enabled_no_perm.html
--- a/dom/network/tests/mochitest.ini
+++ b/dom/network/tests/mochitest.ini
@@ -9,18 +9,18 @@ skip-if = toolkit == "gonk" || toolkit =
 [test_tcpsocket_client_and_server_basics.html]
 [test_tcpsocket_default_permissions.html]
 skip-if = toolkit == "gonk"
 [test_tcpsocket_enabled_no_perm.html]
 skip-if = toolkit == "gonk"
 [test_tcpsocket_enabled_with_perm.html]
 skip-if = toolkit == "gonk" || e10s
 [test_networkstats_alarms.html]
-skip-if = true # Bug 958689
+skip-if = toolkit != "gonk"
 [test_networkstats_basics.html]
-skip-if = true # Bug 958689, bug 858005
+skip-if = toolkit != "gonk"
 [test_networkstats_disabled.html]
 skip-if = toolkit != "gonk"
 [test_networkstats_enabled_no_perm.html]
-skip-if = true # Bug 958689
+skip-if = toolkit != "gonk"
 [test_networkstats_enabled_perm.html]
 skip-if = toolkit != "gonk"
 [test_udpsocket.html]
--- a/dom/network/tests/test_networkstats_alarms.html
+++ b/dom/network/tests/test_networkstats_alarms.html
@@ -144,17 +144,16 @@ var steps = [
     };
 
     req.onerror = function () {
       ok(false, "getAllAlarms() shouldn't fail.");
     }
   },
   function () {
     ok(true, "all done!\n");
-    SpecialPowers.removePermission("networkstats-manage", document);
     SimpleTest.finish();
     return;
   }
 ];
 
 function next() {
   index += 1;
   if (index >= steps.length) {
@@ -165,29 +164,31 @@ function next() {
     steps[index]();
   } catch(ex) {
     ok(false, "Caught exception", ex);
   }
 }
 
 SimpleTest.waitForExplicitFinish();
 
-SpecialPowers.addPermission("networkstats-manage", true, document);
 SpecialPowers.pushPrefEnv({'set': [["dom.mozNetworkStats.enabled", true]]},
                           function() {
-  ok(SpecialPowers.hasPermission("networkstats-manage", document),
-     "Has permission 'networkstats-manage'.");
+  SpecialPowers.pushPermissions([{ 'type': 'networkstats-manage', 'allow': 1, 'context': window.document }],
+                                function() {
+    ok(SpecialPowers.hasPermission("networkstats-manage", document),
+       "Has permission 'networkstats-manage'.");
 
-  ok(SpecialPowers.getBoolPref("dom.mozNetworkStats.enabled"),
-     "Preference 'dom.mozNetworkStats.enabled' is true.");
+    ok(SpecialPowers.getBoolPref("dom.mozNetworkStats.enabled"),
+       "Preference 'dom.mozNetworkStats.enabled' is true.");
 
-  ok('mozNetworkStats' in navigator, "navigator.mozNetworkStats should exist");
+    ok('mozNetworkStats' in navigator, "navigator.mozNetworkStats should exist");
 
-  ok(navigator.mozNetworkStats instanceof SpecialPowers.Ci.nsIDOMMozNetworkStatsManager,
-     "navigator.mozNetworkStats should be a nsIDOMMozNetworkStatsManager object");
+    ok(navigator.mozNetworkStats instanceof SpecialPowers.Ci.nsIDOMMozNetworkStatsManager,
+       "navigator.mozNetworkStats should be a nsIDOMMozNetworkStatsManager object");
 
-  test();
+    test();
+  });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/network/tests/test_networkstats_basics.html
+++ b/dom/network/tests/test_networkstats_basics.html
@@ -296,17 +296,16 @@ var steps = [
       next();
     };
     req.onerror = function () {
       ok(false, "getAvailableServiceTypes failure!");
     }
   },
   function () {
     ok(true, "all done!\n");
-    SpecialPowers.removePermission("networkstats-manage", document);
     SimpleTest.finish();
     return;
   }
 ];
 
 function next() {
   index += 1;
   if (index >= steps.length) {
@@ -317,29 +316,31 @@ function next() {
     steps[index]();
   } catch(ex) {
     ok(false, "Caught exception", ex);
   }
 }
 
 SimpleTest.waitForExplicitFinish();
 
-SpecialPowers.addPermission("networkstats-manage", true, document);
 SpecialPowers.pushPrefEnv({'set': [["dom.mozNetworkStats.enabled", true]]},
                           function() {
-  ok(SpecialPowers.hasPermission("networkstats-manage", document),
-     "Has permission 'networkstats-manage'.");
+  SpecialPowers.pushPermissions([{ 'type': 'networkstats-manage', 'allow': 1, 'context': window.document }],
+                                function() {
+    ok(SpecialPowers.hasPermission("networkstats-manage", document),
+       "Has permission 'networkstats-manage'.");
 
-  ok(SpecialPowers.getBoolPref("dom.mozNetworkStats.enabled"),
-     "Preference 'dom.mozNetworkStats.enabled' is true.");
+    ok(SpecialPowers.getBoolPref("dom.mozNetworkStats.enabled"),
+       "Preference 'dom.mozNetworkStats.enabled' is true.");
 
-  ok('mozNetworkStats' in navigator, "navigator.mozNetworkStats should exist");
+    ok('mozNetworkStats' in navigator, "navigator.mozNetworkStats should exist");
 
-  ok(navigator.mozNetworkStats instanceof SpecialPowers.Ci.nsIDOMMozNetworkStatsManager,
-     "navigator.mozNetworkStats should be a nsIDOMMozNetworkStatsManager object");
+    ok(navigator.mozNetworkStats instanceof SpecialPowers.Ci.nsIDOMMozNetworkStatsManager,
+       "navigator.mozNetworkStats should be a nsIDOMMozNetworkStatsManager object");
 
-  test();
+    test();
+  });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/network/tests/test_networkstats_enabled_no_perm.html
+++ b/dom/network/tests/test_networkstats_enabled_no_perm.html
@@ -10,20 +10,22 @@
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 // Test to ensure NetworkStats is enabled but mozNetworkStats.getAvailableNetworks
 // does not work in content because mozNetworkStats is null when no permission.
   SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPrefEnv({"set": [['dom.mozNetworkStats.enabled', true]]}, runTest);
+  SpecialPowers.pushPrefEnv({"set": [['dom.mozNetworkStats.enabled', true]]},
+                            function() {
+    SpecialPowers.pushPermissions([{ 'type': 'networkstats-manage', 'allow': 0, 'context': window.document }], runTest);
+  });
+
   function runTest() {
-    SpecialPowers.removePermission("networkstats-manage", document);
-
     ok(SpecialPowers.getBoolPref("dom.mozNetworkStats.enabled"),
       "Preference 'dom.mozNetworkStats.enabled' is true.");
 
     ok(!SpecialPowers.hasPermission("networkstats-manage", document),
       "Has no permission 'networkstats-manage'.");
 
     ok('mozNetworkStats' in navigator, "navigator.mozNetworkStats should exist");