Bug 1164432 - Update test_try_registering_offline_disabled.html to use mock push server. r=kit
☠☠ backed out by 5bee898930bc ☠ ☠
authorWilliam Chen <wchen@mozilla.com>
Fri, 18 Mar 2016 00:20:00 -0400
changeset 289449 7e63f8cd76bb289e860e390645b922a8b8d22084
parent 289448 10d8bc81030bda050546b70be11237746194f120
child 289450 5bee898930bc8a69bcfba2e9cd7da8380f1c5434
push id30102
push userryanvm@gmail.com
push dateSat, 19 Mar 2016 15:23:17 +0000
treeherdermozilla-central@720fb3d55e28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskit
bugs1164432
milestone48.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 1164432 - Update test_try_registering_offline_disabled.html to use mock push server. r=kit
dom/push/test/mochitest.ini
dom/push/test/mockpushserviceparent.js
dom/push/test/test_try_registering_offline_disabled.html
--- a/dom/push/test/mochitest.ini
+++ b/dom/push/test/mochitest.ini
@@ -13,11 +13,10 @@ skip-if = os == "android" || toolkit == 
 [test_permissions.html]
 [test_register.html]
 [test_multiple_register.html]
 [test_multiple_register_during_service_activation.html]
 [test_unregister.html]
 [test_multiple_register_different_scope.html]
 [test_subscription_change.html]
 [test_data.html]
-# Disabled for too many intermittent failures (bug 1164432)
-#  [test_try_registering_offline_disabled.html]
+[test_try_registering_offline_disabled.html]
 [test_serviceworker_lifetime.html]
--- a/dom/push/test/mockpushserviceparent.js
+++ b/dom/push/test/mockpushserviceparent.js
@@ -80,23 +80,27 @@ MockNetworkInfo.prototype = {
 var pushService = Cc["@mozilla.org/push/Service;1"].
                   getService(Ci.nsIPushService).
                   wrappedJSObject;
 
 var mockWebSocket;
 
 addMessageListener("setup", function () {
   mockWebSocket = new Promise((resolve, reject) => {
+    var mockSocket = null;
     pushService.replaceServiceBackend({
       serverURI: "wss://push.example.org/",
       networkInfo: new MockNetworkInfo(),
       makeWebSocket(uri) {
-        var socket = new MockWebSocketParent(uri);
-        resolve(socket);
-        return socket;
+        if (!mockSocket) {
+          mockSocket = new MockWebSocketParent(uri);
+          resolve(mockSocket);
+        }
+
+        return mockSocket;
       }
     });
   });
 });
 
 addMessageListener("teardown", function () {
   mockWebSocket.then(socket => {
     socket.close();
--- a/dom/push/test/test_try_registering_offline_disabled.html
+++ b/dom/push/test/test_try_registering_offline_disabled.html
@@ -5,16 +5,17 @@ Bug 1150812: Try to register when servic
 
 Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/licenses/publicdomain/
 
 -->
 <head>
   <title>Test for Bug 1150812</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/dom/push/test/test_utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
   <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
 </head>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1150812">Mozilla Bug 1150812</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
@@ -282,20 +283,14 @@ http://creativecommons.org/licenses/publ
     .then(_ => runTest2())
     .then(_ => runTest3())
     .then(_ => runTest4())
     .then(_ => runTest5())
     .then(_ => runTest6())
     .then(SimpleTest.finish);
   }
 
-  SpecialPowers.pushPrefEnv({"set": [
-    ["dom.push.enabled", true],
-    ["dom.push.connection.enabled", true],
-    ["dom.serviceWorkers.exemptFromPerDomainMax", true],
-    ["dom.serviceWorkers.enabled", true],
-    ["dom.serviceWorkers.testing.enabled", true]
-    ]}, runTest);
+  setupPrefsAndMock(new MockWebSocket()).then(_ => runTest());
   SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>