Bug 1254746 - Fix browser_service_workers_start.js intermittent when the worker is killed sooner than expected. r=jryans, a=test-only
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 30 May 2016 03:06:21 -0700
changeset 333477 cb2a54c80b550eb66f4dc57012328a0d237c3027
parent 333476 b0c78c7d137a3fb1591ec847a744ba91fb89ee01
child 333478 5d16ea3dd89aa2505128dcb3f36ae83357747ef9
push id6122
push userryanvm@gmail.com
push dateMon, 27 Jun 2016 16:42:25 +0000
treeherdermozilla-beta@00a6e2ca6e9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans, test-only
bugs1254746
milestone48.0
Bug 1254746 - Fix browser_service_workers_start.js intermittent when the worker is killed sooner than expected. r=jryans, a=test-only
devtools/client/aboutdebugging/test/browser_service_workers_start.js
--- a/devtools/client/aboutdebugging/test/browser_service_workers_start.js
+++ b/devtools/client/aboutdebugging/test/browser_service_workers_start.js
@@ -50,22 +50,28 @@ add_task(function* () {
   ok(true, "Service worker registration resolved");
 
   // Retrieve the Target element corresponding to the service worker.
   let names = [...document.querySelectorAll("#service-workers .target-name")];
   let name = names.filter(element => element.textContent === SERVICE_WORKER)[0];
   ok(name, "Found the service worker in the list");
   let targetElement = name.parentNode.parentNode;
 
-  // Check that there is a Debug button but not a Start button.
-  ok(targetElement.querySelector(".debug-button"), "Found its debug button");
-  ok(!targetElement.querySelector(".start-button"), "No start button");
+  // The service worker may already be killed with the low 1s timeout
+  if (!targetElement.querySelector(".start-button")) {
+    // Check that there is a Debug button but not a Start button.
+    ok(targetElement.querySelector(".debug-button"), "Found its debug button");
 
-  // Wait for the service worker to be killed due to inactivity.
-  yield waitForMutation(targetElement, { childList: true });
+    // Wait for the service worker to be killed due to inactivity.
+    yield waitForMutation(targetElement, { childList: true });
+  } else {
+    // Check that there is no Debug button when the SW is already shut down.
+    ok(!targetElement.querySelector(".debug-button"), "No debug button when " +
+      "the worker is already killed");
+  }
 
   // We should now have a Start button but no Debug button.
   let startBtn = targetElement.querySelector(".start-button");
   ok(startBtn, "Found its start button");
   ok(!targetElement.querySelector(".debug-button"), "No debug button");
 
   // Click on the Start button and wait for the service worker to be back.
   let onStarted = waitForMutation(targetElement, { childList: true });