Bug 1254746 - Fix browser_service_workers_start.js intermittent when the worker is killed sooner than expected. r=jryans, a=test-only
--- 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 });