Bug 1159813 - Make sure service worker tests clean up after themselves; r=baku
☠☠ backed out by 4344c0378fe6 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 29 Apr 2015 13:34:20 -0400
changeset 241723 d90e308bfb98fe5c7561d05ed89cdaaff1261417
parent 241722 a59eaeaeb8b4c8c1a3bec1b2a72b87ab6f3b4c8c
child 241724 e158ed184326ceac6e2f862b17c6887c23d81e20
push id28669
push userryanvm@gmail.com
push dateThu, 30 Apr 2015 17:57:05 +0000
treeherdermozilla-central@7723b15ea695 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1159813
milestone40.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 1159813 - Make sure service worker tests clean up after themselves; r=baku This makes it possible to run the service workers tests using --run-until-failure, which will hopefully help with reproducing intermittent test failures.
dom/workers/test/serviceworkers/importscript.sjs
dom/workers/test/serviceworkers/periodic.sjs
dom/workers/test/serviceworkers/periodic/unregister.html
dom/workers/test/serviceworkers/test_importscript.html
--- a/dom/workers/test/serviceworkers/importscript.sjs
+++ b/dom/workers/test/serviceworkers/importscript.sjs
@@ -1,9 +1,11 @@
 function handleRequest(request, response) {
-  if (!getState('counter')) {
+  if (request.queryString == 'clearcounter') {
+    setState('counter', '');
+  } else if (!getState('counter')) {
     response.setHeader("Content-Type", "application/javascript", false);
     response.write("callByScript();");
     setState('counter', '1');
   } else {
     response.write("no cache no party!");
   }
 }
--- a/dom/workers/test/serviceworkers/periodic.sjs
+++ b/dom/workers/test/serviceworkers/periodic.sjs
@@ -1,9 +1,13 @@
 function handleRequest(request, response) {
+  if (request.queryString == 'clearcounter') {
+    setState('periodiccounter', '');
+    return;
+  }
   if (!getState('periodiccounter')) {
     setState('periodiccounter', '1');
   } else {
     // Make sure that we pass a string value to setState!
     setState('periodiccounter', "" + (parseInt(getState('periodiccounter')) + 1));
   }
   response.setHeader("Content-Type", "application/javascript", false);
   response.write(getScript());
--- a/dom/workers/test/serviceworkers/periodic/unregister.html
+++ b/dom/workers/test/serviceworkers/periodic/unregister.html
@@ -1,11 +1,13 @@
 <!DOCTYPE html>
 <script>
-  navigator.serviceWorker.getRegistration(".").then(function(registration) {
+  fetch("../periodic.sjs?clearcounter").then(function() {
+    return navigator.serviceWorker.getRegistration(".");
+  }).then(function(registration) {
     registration.unregister().then(function(success) {
       if (success) {
         parent.callback();
       } else {
         dump("Unregister failed\n");
       }
     }, function(e) {
       dump("Unregistering the SW failed with " + e + "\n");
--- a/dom/workers/test/serviceworkers/test_importscript.html
+++ b/dom/workers/test/serviceworkers/test_importscript.html
@@ -14,17 +14,19 @@
 <script class="testbody" type="text/javascript">
   function start() {
     return navigator.serviceWorker.register("importscript_worker.js",
                                             { scope: "./sw_clients/" })
       .then((swr) => registration = swr);
   }
 
   function unregister() {
-    return registration.unregister().then(function(result) {
+    fetch("importscript.sjs?clearcounter").then(function() {
+      return registration.unregister();
+    }).then(function(result) {
       ok(result, "Unregister should return true.");
     }, function(e) {
       dump("Unregistering the SW failed with " + e + "\n");
     });
   }
 
   function testPostMessage(swr) {
     var p = new Promise(function(res, rej) {