Bug 1354937 - Stop using mutations in browser_service_workers_status.js. r=ochameau, a=test-only
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 21 Sep 2017 23:44:26 +0200
changeset 431878 977bae742f4f355d236d2157f6b9916525ab8001
parent 431877 c5912bbb5405c263b428dae7fd51a4ebabe2882a
child 431879 1c4aa3cce409bdcc911b4b9dc7f3d4c79b618d34
push id7837
push userryanvm@gmail.com
push dateWed, 27 Sep 2017 17:37:56 +0000
treeherdermozilla-beta@c89417bb5ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, test-only
bugs1354937
milestone57.0
Bug 1354937 - Stop using mutations in browser_service_workers_status.js. r=ochameau, a=test-only MozReview-Commit-ID: 7VUpgyOF68
devtools/client/aboutdebugging/test/browser_service_workers_status.js
--- a/devtools/client/aboutdebugging/test/browser_service_workers_status.js
+++ b/devtools/client/aboutdebugging/test/browser_service_workers_status.js
@@ -2,17 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Service workers can't be loaded from chrome://,
 // but http:// is ok with dom.serviceWorkers.testing.enabled turned on.
 const SERVICE_WORKER = URL_ROOT + "service-workers/delay-sw.js";
 const TAB_URL = URL_ROOT + "service-workers/delay-sw.html";
-const SW_TIMEOUT = 2000;
+const SW_TIMEOUT = 5000;
 
 requestLongerTimeout(2);
 
 add_task(function* () {
   yield enableServiceWorkerDebugging();
   yield pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
   yield pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
 
@@ -31,24 +31,22 @@ add_task(function* () {
 
   // Check that the service worker appears in the UI
   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;
   let status = targetElement.querySelector(".target-status");
-  // We might miss the registering state in some setup...
-  if (status.textContent == "Registering") {
-    yield waitForMutation(serviceWorkersElement, { childList: true, subtree: true });
-  }
 
-  is(status.textContent, "Running", "Service worker is currently running");
-
-  yield waitForMutation(serviceWorkersElement, { attributes: true, subtree: true });
+  // We should ideally check that the service worker registration goes through the
+  // "registering" and "running" steps, but it is difficult to workaround race conditions
+  // for a test running on a wide variety of platforms. Due to intermittent failures, we
+  // simply check that the registration transitions to "stopped".
+  yield waitUntil(() => status.textContent == "Stopped", 100);
   is(status.textContent, "Stopped", "Service worker is currently stopped");
 
   try {
     yield unregisterServiceWorker(swTab, serviceWorkersElement);
     ok(true, "Service worker unregistered");
   } catch (e) {
     ok(false, "Service worker not unregistered; " + e);
   }