Bug 1425975 P10 Fix the test_skip_waiting.html mochitest to properly wait for active worker state. r=asuth
authorBen Kelly <ben@wanderview.com>
Fri, 05 Jan 2018 12:10:21 -0500
changeset 449774 8e4ffe879be7ec092b58657f8b06fe78b96c4437
parent 449773 8449669c2adc5012c05ea09d279d4b57e6df5096
child 449775 86acf7e4d09daf2b392eba2784bc92591cab00d5
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");