Bug 1522511 - [remote-dbg-next] Do not prevent service-worker debugging if new sw implementation is enabled r=ladybenko
authorsole <spenades@mozilla.com>
Thu, 07 Mar 2019 09:35:52 +0000
changeset 520715 4db188219e4779e107bf352bea309600f70320f9
parent 520714 fdb89003ea1348d0ce1b896d72038af51b1fe1d6
child 520716 5fb9ad2446bc49615d9d658108d2f52747ad1f9a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko
bugs1522511
milestone67.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 1522511 - [remote-dbg-next] Do not prevent service-worker debugging if new sw implementation is enabled r=ladybenko Take into account new service worker implementation to decide if workers can be debugged Differential Revision: https://phabricator.services.mozilla.com/D20677
devtools/shared/multi-e10s-helper.js
--- a/devtools/shared/multi-e10s-helper.js
+++ b/devtools/shared/multi-e10s-helper.js
@@ -1,15 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const Services = require("Services");
+const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyServiceGetter(
+  this, "swm",
+  "@mozilla.org/serviceworkers/manager;1",
+  "nsIServiceWorkerManager"
+);
 
 /**
  * This helper provides info on whether we are in multi e10s mode or not.
  * Since this can be changed on the fly, there are subscribe/unsubscribe functions
  * to get notified of this.
  *
  * The logic to handle this is borrowed from the (old) about:debugging code.
  */
@@ -34,20 +41,28 @@ function addMultiE10sListener(listener) 
   Services.prefs.addObserver(MULTI_OPTOUT_PREF, listener);
 }
 
 function removeMultiE10sListener(listener) {
   Services.prefs.removeObserver(PROCESS_COUNT_PREF, listener);
   Services.prefs.removeObserver(MULTI_OPTOUT_PREF, listener);
 }
 
+// TODO to be refactored as `canDebugServiceWorkers` (and
+// logic in the consumers of the function to be changed)
+// See Bug 1531349
 function isMultiE10s() {
   const isE10s = Services.appinfo.browserTabsRemoteAutostart;
   const processCount = Services.appinfo.maxWebProcessCount;
+  const multiE10s =  isE10s && processCount > 1;
+  const isNewSWImplementation = swm.isParentInterceptEnabled();
 
-  return isE10s && processCount > 1;
+  // When can we debug Service Workers?
+  // If we're running the new implementation, OR if not in multiprocess mode
+  const canDebugSW = isNewSWImplementation || !multiE10s;
+  return !canDebugSW;
 }
 
 module.exports = {
   addMultiE10sListener,
   isMultiE10s,
   removeMultiE10sListener,
 };