Bug 1518581 - Silence worker updates if they are not required by the test;r=daisuke,ochameau a=lizzard
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 14 Feb 2019 08:27:36 +0000
changeset 516184 571ad2687c2ea8b846d9468e493fae909eb35e78
parent 516183 cf46b5a6e3ed1f8db130127dca8d14b9fddb7cfa
child 516185 6bacdb768e5af3f69cc3977ff70219ffaebac0cf
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke, ochameau, lizzard
bugs1518581
milestone66.0
Bug 1518581 - Silence worker updates if they are not required by the test;r=daisuke,ochameau a=lizzard Depends on D18236 Worker updates are very hard to predict and we have many intermittents caused by pending requests for workers while we destroy the client. Discussed with @ochameau about the potential solutions, and disabling worker updates in tests that don't need them seems a good option. A complementary solution can be to wait for debugger-client waitForRequestsToSettle (different from our current helper in head.js). Differential Revision: https://phabricator.services.mozilla.com/D18237
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtools.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_select_page_with_serviceworker.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_multie10s.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_push.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_pushservice_url.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_runtime-page.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_start.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_timeout.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_workers_remote_runtime.js
devtools/client/aboutdebugging-new/test/browser/head.js
devtools/client/aboutdebugging-new/test/browser/helper-mocks.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtools.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtools.js
@@ -21,17 +21,16 @@ add_task(async function() {
   ok(connectSidebarItem, "Found the Connect sidebar item");
 
   info("Open devtools on the current about:debugging tab");
   const toolbox = await openToolboxForTab(tab, "inspector");
   const inspector = toolbox.getPanel("inspector");
 
   info("DevTools starts workers, wait for requests to settle");
   const store = window.AboutDebugging.store;
-  await waitForDispatch(store, "REQUEST_WORKERS_SUCCESS");
   await waitForRequestsToSettle(store);
 
   info("Click on the Connect item in the sidebar");
   connectLink.click();
   await waitForDispatch(store, "UNWATCH_RUNTIME_SUCCESS");
 
   info("Wait until Connect page is displayed");
   await waitUntil(() => document.querySelector(".js-connect-page"));
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_select_page_with_serviceworker.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_select_page_with_serviceworker.js
@@ -10,17 +10,18 @@ const WORKER_NAME = "testserviceworker";
 // Test that navigating from:
 // - a remote runtime page that contains a service worker
 // to:
 // - this firefox
 // does not crash. See Bug 1519088.
 add_task(async function() {
   const mocks = new Mocks();
 
-  const { document, tab, window } = await openAboutDebugging();
+  const { document, tab, window } =
+    await openAboutDebugging({ enableWorkerUpdates: true });
 
   info("Prepare Network client mock");
   const networkClient = mocks.createNetworkRuntime(NETWORK_RUNTIME_HOST, {
     name: NETWORK_RUNTIME_APP_NAME,
   });
 
   info("Connect and select the network runtime");
   await connectToRuntime(NETWORK_RUNTIME_HOST, document);
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_multie10s.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_multie10s.js
@@ -30,17 +30,17 @@ add_task(async function() {
 
   await testDebuggingSW(enableFn, disableFn);
 });
 
 async function testDebuggingSW(enableMultiE10sFn, disableMultiE10sFn) {
   // enable service workers
   await pushPref("dom.serviceWorkers.testing.enabled", true);
 
-  const { document, tab } = await openAboutDebugging();
+  const { document, tab } = await openAboutDebugging({ enableWorkerUpdates: true });
 
   // disable multi e10s
   info("Disabling multi e10s");
   await disableMultiE10sFn();
 
   // Open a tab that registers a push service worker.
   const swTab = await addTab(TAB_URL);
 
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_push.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_push.js
@@ -8,17 +8,17 @@ Services.scriptloader.loadSubScript(CHRO
 
 const SERVICE_WORKER = URL_ROOT + "resources/service-workers/push-sw.js";
 const TAB_URL = URL_ROOT + "resources/service-workers/push-sw.html";
 
 // Test that clicking on the Push button next to a Service Worker works as intended.
 // It should trigger a "push" notification in the worker.
 add_task(async function() {
   await enableServiceWorkerDebugging();
-  const { document, tab } = await openAboutDebugging();
+  const { document, tab } = await openAboutDebugging({ enableWorkerUpdates: true });
 
   // Open a tab that registers a push service worker.
   const swTab = await addTab(TAB_URL);
 
   info("Forward service worker messages to the test");
   await forwardServiceWorkerMessage(swTab);
 
   info("Wait for the service worker to claim the test window before proceeding.");
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_pushservice_url.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_pushservice_url.js
@@ -14,17 +14,17 @@ const FAKE_ENDPOINT = "https://fake/endp
 // Test that the push service url is displayed for service workers subscribed to a push
 // service.
 add_task(async function() {
   await enableServiceWorkerDebugging();
 
   info("Mock the push service");
   mockPushService(FAKE_ENDPOINT);
 
-  const { document, tab } = await openAboutDebugging();
+  const { document, tab } = await openAboutDebugging({ enableWorkerUpdates: true });
 
   // Open a tab that registers a push service worker.
   const swTab = await addTab(TAB_URL);
 
   info("Forward service worker messages to the test");
   await forwardServiceWorkerMessage(swTab);
 
   info("Wait for the service worker to claim the test window before proceeding.");
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_runtime-page.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_runtime-page.js
@@ -16,17 +16,18 @@ const SW_URL = URL_ROOT + "resources/ser
 
 /**
  * Test that service workers appear and dissapear from the runtime page when they
  * are registered / unregistered.
  */
 add_task(async function() {
   prepareCollapsibilitiesTest();
   await enableServiceWorkerDebugging();
-  const { document, tab, window } = await openAboutDebugging();
+  const { document, tab, window } =
+    await openAboutDebugging({ enableWorkerUpdates: true });
   const store = window.AboutDebugging.store;
 
   await selectThisFirefoxPage(document, store);
 
   // check that SW list is empty
   info("Check that the SW pane is empty");
   let swPane = getDebugTargetPane("Service Workers", document);
   ok(!swPane.querySelector(".js-debug-target-item"),
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_start.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_start.js
@@ -20,17 +20,17 @@ add_task(async function() {
 
   // Setting a low idle_timeout and idle_extended_timeout will allow the service worker
   // to reach the STOPPED state quickly, which will allow us to test the start button.
   // The default value is 30000 milliseconds.
   info("Set a low service worker idle timeout");
   await pushPref("dom.serviceWorkers.idle_timeout", 1000);
   await pushPref("dom.serviceWorkers.idle_extended_timeout", 1000);
 
-  const { document, tab } = await openAboutDebugging();
+  const { document, tab } = await openAboutDebugging({ enableWorkerUpdates: true });
 
   // Open a tab that registers a basic service worker.
   const swTab = await addTab(SW_TAB_URL);
 
   // Wait for the registration to make sure service worker has been started, and that we
   // are not just reading STOPPED as the initial state.
   await waitForRegistration(swTab);
 
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_timeout.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_timeout.js
@@ -26,17 +26,17 @@ add_task(async function() {
 
   // Setting a low idle_timeout and idle_extended_timeout will allow the service worker
   // to reach the STOPPED state quickly, which will allow us to test the start button.
   // The default value is 30000 milliseconds.
   info("Set a low service worker idle timeout");
   await pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
   await pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
 
-  const { document, tab } = await openAboutDebugging();
+  const { document, tab } = await openAboutDebugging({ enableWorkerUpdates: true });
 
   // Open a tab that registers a basic service worker.
   const swTab = await addTab(SW_TAB_URL);
 
   // Wait for the registration to make sure service worker has been started, and that we
   // are not just reading STOPPED as the initial state.
   await waitForRegistration(swTab);
 
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_workers_remote_runtime.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_workers_remote_runtime.js
@@ -30,17 +30,17 @@ const EMPTY_WORKERS_RESPONSE = {
   serviceWorkers: [],
   sharedWorkers: [],
 };
 
 // Test that workers are displayed and updated for remote runtimes when expected.
 add_task(async function() {
   const mocks = new Mocks();
 
-  const { document, tab } = await openAboutDebugging();
+  const { document, tab } = await openAboutDebugging({ enableWorkerUpdates: true });
 
   info("Prepare USB client mock");
   const usbClient = mocks.createUSBRuntime(USB_RUNTIME_ID, {
     deviceName: USB_RUNTIME_DEVICE_NAME,
     name: USB_RUNTIME_APP_NAME,
   });
   mocks.emitUSBUpdate();
 
--- a/devtools/client/aboutdebugging-new/test/browser/head.js
+++ b/devtools/client/aboutdebugging-new/test/browser/head.js
@@ -39,17 +39,21 @@ registerCleanupFunction(async function()
 /**
  * Enable the new about:debugging panel.
  */
 async function enableNewAboutDebugging() {
   await pushPref("devtools.aboutdebugging.new-enabled", true);
   await pushPref("devtools.aboutdebugging.network", true);
 }
 
-async function openAboutDebugging() {
+async function openAboutDebugging({ enableWorkerUpdates } = {}) {
+  if (!enableWorkerUpdates) {
+    silenceWorkerUpdates();
+  }
+
   await enableNewAboutDebugging();
 
   info("opening about:debugging");
 
   const tab = await addTab("about:debugging");
   const browser = tab.linkedBrowser;
   const document = browser.contentDocument;
   const window = browser.contentWindow;
--- a/devtools/client/aboutdebugging-new/test/browser/helper-mocks.js
+++ b/devtools/client/aboutdebugging-new/test/browser/helper-mocks.js
@@ -158,8 +158,28 @@ class Mocks {
       this.removeUSBRuntime(id);
     } else if (this._clients[RUNTIMES.NETWORK][id]) {
       this.removeNetworkRuntime(id);
     }
   }
 }
 /* exported Mocks */
 
+const silenceWorkerUpdates = function() {
+  const { removeMockedModule, setMockedModule } =
+    require("devtools/client/shared/browser-loader-mocks");
+
+  const mock = {
+    WorkersListener: () => {
+      return {
+        addListener: () => {},
+        removeListener: () => {},
+      };
+    },
+  };
+  setMockedModule(mock,
+    "devtools/client/aboutdebugging-new/src/modules/workers-listener");
+
+  registerCleanupFunction(() => {
+    removeMockedModule("devtools/client/aboutdebugging-new/src/modules/workers-listener");
+  });
+};
+/* exported silenceWorkerUpdates */