Bug 1434599 - Enable test_workerupdatefoundevent.html. r=bkelly
authorCatalin Badea <catalin.badea392@gmail.com>
Fri, 02 Feb 2018 06:12:00 +0200
changeset 751766 66a85897ecb2d7b1a8b533a657b6767b117a262e
parent 751765 a7f88998e959dd94f9050371824b1e9a379cc705
child 751767 5fe2cd2df9ed887edd6cbd7478b9f7ad519a2375
push id98047
push userbmo:continuation@gmail.com
push dateTue, 06 Feb 2018 22:02:37 +0000
reviewersbkelly
bugs1434599
milestone60.0a1
Bug 1434599 - Enable test_workerupdatefoundevent.html. r=bkelly
dom/serviceworkers/test/mochitest.ini
dom/serviceworkers/test/test_workerupdatefoundevent.html
dom/serviceworkers/test/worker_updatefoundevent.js
--- a/dom/serviceworkers/test/mochitest.ini
+++ b/dom/serviceworkers/test/mochitest.ini
@@ -336,16 +336,15 @@ tags = openwindow
 [test_strict_mode_warning.html]
 [test_third_party_iframes.html]
 [test_unregister.html]
 [test_unresolved_fetch_interception.html]
 [test_update_missing_imported_script.html]
 [test_workerUnregister.html]
 [test_workerUpdate.html]
 [test_workerupdatefoundevent.html]
-skip-if = !e10s # Bug 1433276
 [test_xslt.html]
 [test_async_waituntil.html]
 [test_worker_reference_gc_timeout.html]
 [test_nofetch_handler.html]
 [test_bad_script_cache.html]
 [test_file_upload.html]
 support-files = script_file_upload.js sw_file_upload.js server_file_upload.sjs
--- a/dom/serviceworkers/test/test_workerupdatefoundevent.html
+++ b/dom/serviceworkers/test/test_workerupdatefoundevent.html
@@ -17,37 +17,43 @@
 <script class="testbody" type="text/javascript">
   var registration;
   var promise;
 
   async function start() {
     registration = await navigator.serviceWorker.register("worker_updatefoundevent.js",
                                                           { scope: "./updatefoundevent.html" })
     await waitForState(registration.installing, 'activated');
+
+    content = document.getElementById("content");
+    iframe = document.createElement("iframe");
+    content.appendChild(iframe);
+    iframe.setAttribute("src", "./updatefoundevent.html");
+
+    await new Promise(function(resolve) { iframe.onload = resolve; });
+    ok(iframe.contentWindow.navigator.serviceWorker.controller, "Controlled client.");
+
+    return Promise.resolve();
+
   }
 
   function startWaitForUpdateFound() {
     registration.onupdatefound = function(e) {
     }
 
     promise = new Promise(function(resolve, reject) {
       window.onmessage = function(e) {
 
         if (e.data == "finish") {
           ok(true, "Received updatefound");
           resolve();
         }
       }
     });
 
-    content = document.getElementById("content");
-    iframe = document.createElement("iframe");
-    content.appendChild(iframe);
-    iframe.setAttribute("src", "./updatefoundevent.html");
-
     return Promise.resolve();
   }
 
   function registerNext() {
     return navigator.serviceWorker.register("worker_updatefoundevent2.js",
                                             { scope: "./updatefoundevent.html" });
   }
 
--- a/dom/serviceworkers/test/worker_updatefoundevent.js
+++ b/dom/serviceworkers/test/worker_updatefoundevent.js
@@ -1,17 +1,19 @@
 /**
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 registration.onupdatefound = function(e) {
   clients.matchAll().then(function(clients) {
     if (!clients.length) {
-      reject("No clients found");
+      // We don't control any clients when the first update event is fired
+      // because we haven't reached the 'activated' state.
+      return;
     }
 
     if (registration.scope.match(/updatefoundevent\.html$/)) {
       clients[0].postMessage("finish");
     } else {
       dump("Scope did not match");
     }
   });