Bug 1425975 P10 Fix the test_skip_waiting.html mochitest to properly wait for active worker state. r=asuth
☠☠ backed out by 2e0db1b48499 ☠ ☠
authorBen Kelly <ben@wanderview.com>
Fri, 22 Dec 2017 21:09:19 -0500
changeset 449131 fb89dbd922ba50ebf7a5da5a555416f449a6c715
parent 449130 f2b451ce55d4ff70661c66a6e5e87947ed48e5d1
child 449132 0e50d9d1d06961d9866e1c34bec7b97839bb5834
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [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 P10 Fix the test_skip_waiting.html mochitest to properly wait for active worker state. r=asuth
dom/workers/test/serviceworkers/skip_waiting_scope/index.html
dom/workers/test/serviceworkers/test_skip_waiting.html
--- a/dom/workers/test/serviceworkers/skip_waiting_scope/index.html
+++ b/dom/workers/test/serviceworkers/skip_waiting_scope/index.html
@@ -14,20 +14,16 @@
 <div id="content" style="display: none"></div>
 <pre id="test"></pre>
 <script class="testbody" type="text/javascript">
 
   if (!parent) {
     info("skip_waiting_scope/index.html shouldn't be launched directly!");
   }
 
-  navigator.serviceWorker.ready.then(function() {
-    parent.postMessage("READY", "*");
-  });
-
   navigator.serviceWorker.oncontrollerchange = function() {
     parent.postMessage({
       event: "controllerchange",
       controllerScriptURL: navigator.serviceWorker.controller &&
                            navigator.serviceWorker.controller.scriptURL
     }, "*");
   }
 
--- a/dom/workers/test/serviceworkers/test_skip_waiting.html
+++ b/dom/workers/test/serviceworkers/test_skip_waiting.html
@@ -8,45 +8,36 @@
   <title>Bug 1131352 - Add ServiceWorkerGlobalScope skipWaiting()</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" style="display: none"></div>
 <pre id="test"></pre>
+<script src="utils.js"></script>
 <script class="testbody" type="text/javascript">
   var registration, iframe, content;
 
   function start() {
     return navigator.serviceWorker.register("worker.js",
                                             {scope: "./skip_waiting_scope/"});
   }
 
-  function waitForActivated(swr) {
+  async function waitForActivated(swr) {
     registration = swr;
-    var promise = new Promise(function(resolve, reject) {
-      window.onmessage = function(e) {
-        if (e.data === "READY") {
-          ok(true, "Active worker is activated now");
-          resolve();
-        } else {
-          ok(false, "Wrong value. Somenting went wrong");
-          resolve();
-        }
-      }
-    });
+    await waitForState(registration.installing, "activated")
 
     iframe = document.createElement("iframe");
     iframe.setAttribute("src", "skip_waiting_scope/index.html");
 
     content = document.getElementById("content");
     content.appendChild(iframe);
 
-    return promise;
+    await new Promise(resolve => iframe.onload = resolve);
   }
 
   function checkWhetherItSkippedWaiting() {
     var promise = new Promise(function(resolve, reject) {
       window.onmessage = function (evt) {
         if (evt.data.event === "controllerchange") {
           ok(evt.data.controllerScriptURL.match("skip_waiting_installed_worker"),
              "The controller changed after skiping the waiting step");