Bug 1434599 - Enable test_workerupdatefoundevent.html. r=bkelly
--- 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");
}
});