diff --git a/dom/tests/mochitest/fetch/sw_reroute.js b/dom/tests/mochitest/fetch/sw_reroute.js index a4e10349c264..32d1246045bc 100644 --- a/dom/tests/mochitest/fetch/sw_reroute.js +++ b/dom/tests/mochitest/fetch/sw_reroute.js @@ -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();