Backed out changeset eaa49fbb1bc2 (bug 1219064) for perma failures in test_data.html
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 01 Feb 2016 10:06:43 +0100
changeset 282513 941033a51983ddec2d99aa9f868a54c0196a4075
parent 282473 abc471c40416a94235f53e885c04c3d3afa30e77
child 282514 22897d8d45faa86766bf9305173894f25e18ac87
child 282524 d6518630d6d3cf6b6d5de3e1e5c3092f60d92c5b
child 282534 59fb5eb538f0bddd6bcc5523d0a710869ce717f9
push id71195
push usercbook@mozilla.com
push dateMon, 01 Feb 2016 09:10:44 +0000
treeherdermozilla-inbound@22897d8d45fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1219064
milestone47.0a1
backs outeaa49fbb1bc2fb8bfe590283858cbc92b1597e96
first release with
nightly linux32
941033a51983 / 47.0a1 / 20160201030241 / files
nightly linux64
941033a51983 / 47.0a1 / 20160201030241 / files
nightly mac
941033a51983 / 47.0a1 / 20160201030241 / files
nightly win32
941033a51983 / 47.0a1 / 20160201030241 / files
nightly win64
941033a51983 / 47.0a1 / 20160201030241 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset eaa49fbb1bc2 (bug 1219064) for perma failures in test_data.html
dom/push/test/frame.html
dom/push/test/mochitest.ini
dom/push/test/test_data.html
dom/push/test/test_register.html
dom/push/test/test_subscription_change.html
dom/push/test/test_utils.js
dom/push/test/worker.js
--- a/dom/push/test/frame.html
+++ b/dom/push/test/frame.html
@@ -1,24 +1,26 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
   <script>
 
-    function waitOnWorkerMessage(type) {
-      return new Promise(function(res, rej) {
-        function onMessage(e) {
-          if (e.data.type == type) {
-            navigator.serviceWorker.removeEventListener("message", onMessage);
+
+    function waitOnPushMessage()
+    {
+      var p = new Promise(function(res, rej) {
+        navigator.serviceWorker.onmessage = function(e) {
+          if (e.data.type == "finished") {
             (e.data.okay == "yes" ? res : rej)(e.data);
           }
-        }
-        navigator.serviceWorker.addEventListener("message", onMessage);
+        };
       });
+      return p;
     }
 
+
   </script>
 </head>
 <body>
 
 </body>
 </html>
--- a/dom/push/test/mochitest.ini
+++ b/dom/push/test/mochitest.ini
@@ -17,17 +17,15 @@ skip-if = os == "android" || toolkit == 
 [test_multiple_register.html]
 skip-if = os == "android" || toolkit == "gonk"
 [test_multiple_register_during_service_activation.html]
 skip-if = os == "android" || toolkit == "gonk"
 [test_unregister.html]
 skip-if = os == "android" || toolkit == "gonk"
 [test_multiple_register_different_scope.html]
 skip-if = os == "android" || toolkit == "gonk"
-[test_subscription_change.html]
-skip-if = os == "android" || toolkit == "gonk"
 [test_data.html]
 skip-if = os == "android" || toolkit == "gonk"
 # Disabled for too many intermittent failures (bug 1164432)
 #  [test_try_registering_offline_disabled.html]
 #  skip-if = os == "android" || toolkit == "gonk"
 [test_serviceworker_lifetime.html]
 skip-if = os == "android" || toolkit == "gonk"
--- a/dom/push/test/test_data.html
+++ b/dom/push/test/test_data.html
@@ -101,17 +101,17 @@ http://creativecommons.org/licenses/publ
       authSecret,
       new Uint8Array(data.auth),
       "Mismatched auth secret"
     );
   });
 
   function waitForMessage(pushSubscription, message) {
     return Promise.all([
-      controlledFrame.waitOnWorkerMessage("finished"),
+      controlledFrame.waitOnPushMessage(),
       webpush(pushSubscription, message),
     ]).then(([message]) => message);
   }
 
   add_task(function* sendPushMessageFromPage() {
     var typedArray = new Uint8Array([226, 130, 40, 240, 40, 140, 188]);
     var json = { hello: "world" };
 
@@ -156,17 +156,17 @@ http://creativecommons.org/licenses/publ
         }
       };
       reader.readAsText(message.data.blob);
     });
     is(text, "Hi! \ud83d\udc40", "Wrong blob data for message with emoji");
 
     // Send a blank message.
     var [message] = yield Promise.all([
-      controlledFrame.waitOnWorkerMessage("finished"),
+      controlledFrame.waitOnPushMessage(),
       fetch("http://mochi.test:8888/tests/dom/push/test/push-server.sjs", {
         method: "PUT",
         headers: {
           "X-Push-Method": "POST",
           "X-Push-Server": pushSubscription.endpoint,
         },
       }),
     ]);
--- a/dom/push/test/test_register.html
+++ b/dom/push/test/test_register.html
@@ -60,17 +60,17 @@ http://creativecommons.org/licenses/publ
     });
     pushSubscription = yield registration.pushManager.getSubscription();
     is(data.endpoint, pushSubscription.endpoint,
        "Subscription endpoints should match after resubscribing in worker");
   });
 
   add_task(function* waitForPushNotification() {
     yield Promise.all([
-      controlledFrame.waitOnWorkerMessage("finished"),
+      controlledFrame.waitOnPushMessage(),
       fetch("http://mochi.test:8888/tests/dom/push/test/push-server.sjs", {
         method: "PUT",
         headers: {
           "X-Push-Method": "POST",
           "X-Push-Server": pushSubscription.endpoint,
         },
       }),
     ]);
deleted file mode 100644
--- a/dom/push/test/test_subscription_change.html
+++ /dev/null
@@ -1,68 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Bug 1205109: Make `pushsubscriptionchange` extendable.
-
-Any copyright is dedicated to the Public Domain.
-http://creativecommons.org/licenses/publicdomain/
-
--->
-<head>
-  <title>Test for Bug 1205109</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.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=1205109">Mozilla Bug 1205109</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-</pre>
-
-<script class="testbody" type="text/javascript">
-
-  var registration;
-  add_task(function* start() {
-    yield setupPrefs();
-    yield setPushPermission(true);
-
-    var url = "worker.js" + "?" + (Math.random());
-    registration = yield navigator.serviceWorker.register(url, {scope: "."});
-  });
-
-  var controlledFrame;
-  add_task(function* createControlledIFrame() {
-    controlledFrame = yield injectControlledFrame();
-  });
-
-  add_task(function* togglePermission() {
-    var subscription = yield registration.pushManager.subscribe();
-    ok(subscription, "Should create a push subscription");
-
-    yield setPushPermission(false);
-    var permissionState = yield registration.pushManager.permissionState();
-    is(permissionState, "denied", "Should deny push permission");
-
-    var subscription = yield registration.pushManager.getSubscription();
-    is(subscription, null, "Should not return subscription when permission is revoked");
-
-    var changePromise = controlledFrame.waitOnWorkerMessage("changed");
-    yield setPushPermission(true);
-    yield changePromise;
-
-    subscription = yield registration.pushManager.getSubscription();
-    is(subscription, null, "Should drop subscription after reinstating permission");
-  });
-
-  add_task(function* unsubscribe() {
-    controlledFrame.remove();
-    yield registration.unregister();
-  });
-
-</script>
-</body>
-</html>
--- a/dom/push/test/test_utils.js
+++ b/dom/push/test/test_utils.js
@@ -24,25 +24,25 @@ function setupPrefs() {
       ["dom.serviceWorkers.testing.enabled", true]
       ]}, resolve);
   });
 }
 
 function injectControlledFrame(target = document.body) {
   return new Promise(function(res, rej) {
     var iframe = document.createElement("iframe");
-    iframe.src = "/tests/dom/push/test/frame.html";
+    iframe.src = "http://mochi.test:8888/tests/dom/push/test/frame.html";
 
     var controlledFrame = {
       remove() {
         target.removeChild(iframe);
         iframe = null;
       },
-      waitOnWorkerMessage(type) {
-        return iframe ? iframe.contentWindow.waitOnWorkerMessage(type) :
+      waitOnPushMessage() {
+        return iframe ? iframe.contentWindow.waitOnPushMessage() :
                Promise.reject(new Error("Frame removed from document"));
       },
     };
 
     iframe.onload = () => res(controlledFrame);
     target.appendChild(iframe);
   });
 }
--- a/dom/push/test/worker.js
+++ b/dom/push/test/worker.js
@@ -5,17 +5,16 @@
 // `frame.html`, which verifies that the worker can receive push messages.
 
 // `handleMessage` receives messages from `test_push_manager_worker.html`
 // and `test_data.html`, and verifies that `PushManager` can be used from
 // the worker.
 
 this.onpush = handlePush;
 this.onmessage = handleMessage;
-this.onpushsubscriptionchange = handlePushSubscriptionChange;
 
 function getJSON(data) {
   var result = {
     ok: false,
   };
   try {
     result.value = data.json();
     result.ok = true;
@@ -26,56 +25,51 @@ function getJSON(data) {
 }
 
 function assert(value, message) {
   if (!value) {
     throw new Error(message);
   }
 }
 
-function broadcast(event, promise) {
-  event.waitUntil(Promise.resolve(promise).then(message => {
-    return self.clients.matchAll().then(clients => {
-      clients.forEach(client => client.postMessage(message));
-    });
-  }));
-}
-
 function reply(event, promise) {
-  event.waitUntil(Promise.resolve(promise).then(result => {
+  event.waitUntil(promise.then(result => {
     event.ports[0].postMessage(result);
   }).catch(error => {
     event.ports[0].postMessage({
       error: String(error),
     });
   }));
 }
 
 function handlePush(event) {
-  if (event instanceof PushEvent) {
-    if (!('data' in event)) {
-      broadcast(event, {type: "finished", okay: "yes"});
+
+  event.waitUntil(self.clients.matchAll().then(function(result) {
+    if (event instanceof PushEvent) {
+      if (!('data' in event)) {
+        result[0].postMessage({type: "finished", okay: "yes"});
+        return;
+      }
+      var message = {
+        type: "finished",
+        okay: "yes",
+      };
+      if (event.data) {
+        message.data = {
+          text: event.data.text(),
+          arrayBuffer: event.data.arrayBuffer(),
+          json: getJSON(event.data),
+          blob: event.data.blob(),
+        };
+      }
+      result[0].postMessage(message);
       return;
     }
-    var message = {
-      type: "finished",
-      okay: "yes",
-    };
-    if (event.data) {
-      message.data = {
-        text: event.data.text(),
-        arrayBuffer: event.data.arrayBuffer(),
-        json: getJSON(event.data),
-        blob: event.data.blob(),
-      };
-    }
-    broadcast(event, message);
-    return;
-  }
-  broadcast(event, {type: "finished", okay: "no"});
+    result[0].postMessage({type: "finished", okay: "no"});
+  }));
 }
 
 function handleMessage(event) {
   if (event.data.type == "publicKey") {
     reply(event, self.registration.pushManager.getSubscription().then(
       subscription => ({
         p256dh: subscription.getKey("p256dh"),
         auth: subscription.getKey("auth"),
@@ -118,12 +112,8 @@ function handleMessage(event) {
         });
       }
     ));
     return;
   }
   reply(event, Promise.reject(
     "Invalid message type: " + event.data.type));
 }
-
-function handlePushSubscriptionChange(event) {
-  broadcast(event, {type: "changed", okay: "yes"});
-}