Bug 1465670 P7 Make the fetch mochitest reroute test framework use a unique scope. r=asuth
authorBen Kelly <ben@wanderview.com>
Tue, 05 Jun 2018 10:49:12 -0700
changeset 421457 eab80a391434d02618c5f47a04eb28982dccad0c
parent 421456 8551bb8503d67dc2d99e8ac93dfa5612e331668c
child 421458 c8103e36d8cff7ae4d18244f1ea5bef53c78c1b1
push id34093
push useraiakab@mozilla.com
push dateTue, 05 Jun 2018 21:58:58 +0000
treeherdermozilla-central@da28b92efe6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1465670
milestone62.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 1465670 P7 Make the fetch mochitest reroute test framework use a unique scope. r=asuth
dom/tests/mochitest/fetch/sw_reroute.js
--- a/dom/tests/mochitest/fetch/sw_reroute.js
+++ b/dom/tests/mochitest/fetch/sw_reroute.js
@@ -1,32 +1,35 @@
 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);
   }
 
   SpecialPowers.pushPrefEnv({
     "set": [["dom.serviceWorkers.enabled", true],
             ["dom.serviceWorkers.testing.enabled", true],
             ["dom.serviceWorkers.exemptFromPerDomainMax", true]]
   }, 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();
   });
 }
 
 SimpleTest.waitForExplicitFinish();