Bug 1488502 - [part 2] add test to check that service workers debugging is disabled in multi e10s. r=jdescottes,daisuke
authorBelén Albeza <balbeza@mozilla.com>
Thu, 10 Jan 2019 14:57:20 +0000
changeset 510389 392036709e44d5edf28a4dee2baf4f9c457e2e0a
parent 510388 993c073ab27a61d60a3f4aafbe4d1ef7d80fae38
child 510390 d3aef0e30186f54f428fb6f0299a64ecd11039dd
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, daisuke
bugs1488502
milestone66.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 1488502 - [part 2] add test to check that service workers debugging is disabled in multi e10s. r=jdescottes,daisuke Differential Revision: https://phabricator.services.mozilla.com/D14958
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_multie10s.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -37,16 +37,17 @@ skip-if = (os == 'linux' && bits == 32) 
 [browser_aboutdebugging_debug-target-pane_usb_runtime.js]
 [browser_aboutdebugging_devtools.js]
 [browser_aboutdebugging_navigate.js]
 [browser_aboutdebugging_persist_connection.js]
 [browser_aboutdebugging_routes.js]
 [browser_aboutdebugging_runtime_connection-prompt.js]
 [browser_aboutdebugging_runtime_usbclient_closed.js]
 [browser_aboutdebugging_select_network_runtime.js]
+[browser_aboutdebugging_serviceworker_multie10s.js]
 [browser_aboutdebugging_serviceworker_push.js]
 [browser_aboutdebugging_serviceworker_pushservice_url.js]
 [browser_aboutdebugging_sidebar_network_runtimes.js]
 [browser_aboutdebugging_sidebar_usb_runtime.js]
 [browser_aboutdebugging_sidebar_usb_runtime_connect.js]
 [browser_aboutdebugging_sidebar_usb_runtime_refresh.js]
 [browser_aboutdebugging_sidebar_usb_runtime_select.js]
 [browser_aboutdebugging_sidebar_usb_status.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_serviceworker_multie10s.js
@@ -0,0 +1,90 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* global sendAsyncMessage */
+
+"use strict";
+
+/* import-globals-from helper-serviceworker.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-serviceworker.js", this);
+
+const SERVICE_WORKER = URL_ROOT + "resources/service-workers/push-sw.js";
+const TAB_URL = URL_ROOT + "resources/service-workers/push-sw.html";
+const PROCESS_COUNT_PREF = "dom.ipc.processCount";
+const OPTOUT_PREF = "dom.ipc.multiOptOut";
+
+// Test that debugging service workers is disabled when we are in multi e10s
+// (enabling/disabling multi e10s via process count)
+add_task(async function() {
+  const enableFn = async () => pushPref(PROCESS_COUNT_PREF, 8);
+  const disableFn = async () => pushPref(PROCESS_COUNT_PREF, 1);
+
+  await testDebuggingSW(enableFn, disableFn);
+});
+
+// Test that debugging service workers is disabled when we are in multi e10s
+// (enabling/disabling multi e10s via opt out pref)
+add_task(async function() {
+  const enableFn = async () => pushPref(OPTOUT_PREF, 0);
+  const disableFn = async () => pushPref(OPTOUT_PREF, 1);
+
+  await testDebuggingSW(enableFn, disableFn);
+});
+
+async function testDebuggingSW(enableMultiE10sFn, disableMultiE10sFn) {
+  // enable service workers
+  await pushPref("dom.serviceWorkers.testing.enabled", true);
+
+  const { document, tab } = await openAboutDebugging();
+
+  // disable multi e10s
+  info("Disabling multi e10s");
+  await disableMultiE10sFn();
+
+  // 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.");
+  await onTabMessage(swTab, "sw-claimed");
+
+  info("Wait until the service worker appears and is running");
+  await waitUntil(() => {
+    const target = findDebugTargetByText(SERVICE_WORKER, document);
+    const status = target && target.querySelector(".js-worker-status");
+    return status && status.textContent === "Running";
+  });
+
+  let targetElement = findDebugTargetByText(SERVICE_WORKER, document);
+  let pushButton = targetElement.querySelector(".js-push-button");
+  ok(!pushButton.disabled, "Push button is not disabled");
+  let inspectButton = targetElement.querySelector(".js-debug-target-inspect-button");
+  ok(!inspectButton.disabled, "Inspect button is not disabled");
+
+  // enable multi e10s
+  info("Enabling multi e10s");
+  await enableMultiE10sFn();
+
+  info("Wait for debug target to re-render");
+  await waitUntil(() => {
+    targetElement = findDebugTargetByText(SERVICE_WORKER, document);
+    pushButton = targetElement.querySelector(".js-push-button");
+    return pushButton.disabled;
+  });
+
+  ok(pushButton.disabled, "Push button is disabled");
+  inspectButton = targetElement.querySelector(".js-debug-target-inspect-button");
+  ok(inspectButton.disabled, "Inspect button is disabled");
+
+  info("Unregister the service worker");
+  await unregisterServiceWorker(swTab, "pushServiceWorkerRegistration");
+
+  info("Wait until the service worker disappears from about:debugging");
+  await waitUntil(() => !findDebugTargetByText(SERVICE_WORKER, document));
+
+  info("Remove browser tabs");
+  await removeTab(swTab);
+  await removeTab(tab);
+}