Bug 1465670 P7 Make the fetch mochitest reroute test framework use a unique scope. r=asuth

This commit is contained in:
Ben Kelly 2018-06-05 10:49:12 -07:00
parent f91f6158ab
commit 81094133b3

View File

@ -1,11 +1,13 @@
var gRegistration;
var iframe;
function testScript(script) {
var scope = "./reroute.html?" + script.replace(".js", "");
function setupSW(registration) {
gRegistration = registration;
var iframe = document.createElement("iframe");
iframe.src = "reroute.html?" + script.replace(".js", "");
iframe = document.createElement("iframe");
iframe.src = scope;
document.body.appendChild(iframe);
}
@ -16,13 +18,14 @@ function testScript(script) {
}, function() {
var scriptURL = location.href.includes("sw_empty_reroute.html")
? "empty.js" : "reroute.js";
navigator.serviceWorker.register(scriptURL, {scope: "/"})
navigator.serviceWorker.register(scriptURL, {scope: scope})
.then(swr => waitForState(swr.installing, 'activated', swr))
.then(setupSW);
});
}
function finishTest() {
iframe.remove();
gRegistration.unregister().then(SimpleTest.finish, function(e) {
dump("unregistration failed: " + e + "\n");
SimpleTest.finish();