Bug 1425975 P11 Fix test_workerupdatefound.html not to frame loading against SW activation and updatefound events. r=asuth
☠☠ backed out by 2e0db1b48499 ☠ ☠
authorBen Kelly <ben@wanderview.com>
Fri, 22 Dec 2017 21:09:19 -0500
changeset 397377 0e50d9d1d06961d9866e1c34bec7b97839bb5834
parent 397376 fb89dbd922ba50ebf7a5da5a555416f449a6c715
child 397378 9e1544ec814d46dcf8a771a221f3ac1349663497
push id98509
push userbkelly@mozilla.com
push dateSat, 23 Dec 2017 02:09:27 +0000
treeherdermozilla-inbound@e6f4a2d1df9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1425975
milestone59.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 1425975 P11 Fix test_workerupdatefound.html not to frame loading against SW activation and updatefound events. r=asuth
dom/workers/test/serviceworkers/test_workerupdatefoundevent.html
dom/workers/test/serviceworkers/worker_updatefoundevent.js
--- a/dom/workers/test/serviceworkers/test_workerupdatefoundevent.html
+++ b/dom/workers/test/serviceworkers/test_workerupdatefoundevent.html
@@ -8,24 +8,25 @@
   <title>Bug 1131327 - Test ServiceWorkerRegistration.onupdatefound on ServiceWorker</title>
   <script type="text/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"></div>
 <pre id="test"></pre>
+<script src="utils.js"></script>
 <script class="testbody" type="text/javascript">
   var registration;
   var promise;
 
-  function start() {
-    return navigator.serviceWorker.register("worker_updatefoundevent.js",
-                                            { scope: "./updatefoundevent.html" })
-      .then((swr) => registration = swr);
+  async function start() {
+    registration = await navigator.serviceWorker.register("worker_updatefoundevent.js",
+                                                          { scope: "./updatefoundevent.html" })
+    await waitForState(registration.installing, 'activated');
   }
 
   function startWaitForUpdateFound() {
     registration.onupdatefound = function(e) {
     }
 
     promise = new Promise(function(resolve, reject) {
       window.onmessage = function(e) {
--- a/dom/workers/test/serviceworkers/worker_updatefoundevent.js
+++ b/dom/workers/test/serviceworkers/worker_updatefoundevent.js
@@ -1,23 +1,18 @@
 /**
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-onactivate = function(e) {
-  e.waitUntil(new Promise(function(resolve, reject) {
-    registration.onupdatefound = function(e) {
-      clients.matchAll().then(function(clients) {
-        if (!clients.length) {
-          reject("No clients found");
-        }
+registration.onupdatefound = function(e) {
+  clients.matchAll().then(function(clients) {
+    if (!clients.length) {
+      reject("No clients found");
+    }
 
-        if (registration.scope.match(/updatefoundevent\.html$/)) {
-          clients[0].postMessage("finish");
-          resolve();
-        } else {
-          dump("Scope did not match");
-        }
-      }, reject);
+    if (registration.scope.match(/updatefoundevent\.html$/)) {
+      clients[0].postMessage("finish");
+    } else {
+      dump("Scope did not match");
     }
-  }));
+  });
 }