Bug 1495383 - Support all debug targets for all runtimes;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 17 Jan 2019 07:54:14 +0000
changeset 511349 26303cb81de738dd341f54a00955d76a332c6654
parent 511348 824fafc39762398f102ee7f17cac42c3fd04ed89
child 511350 e93d25864ea7e494a7fd1a18f0b4c2811f232055
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)
reviewersdaisuke
bugs1495383
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 1495383 - Support all debug targets for all runtimes;r=daisuke Depends on D15399. I am open to be more conservative and keep the methods around in case we expect to disable some targets on some runtimes in the future Differential Revision: https://phabricator.services.mozilla.com/D15083
devtools/client/aboutdebugging-new/src/actions/runtimes.js
devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js
devtools/client/aboutdebugging-new/src/modules/debug-target-support.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js
@@ -6,29 +6,27 @@
 
 const Actions = require("./index");
 
 const {
   getAllRuntimes,
   getCurrentRuntime,
   findRuntimeById,
 } = require("../modules/runtimes-state-helper");
-const { isSupportedDebugTarget } = require("../modules/debug-target-support");
 
 const { l10n } = require("../modules/l10n");
 const { createClientForRuntime } = require("../modules/runtime-client-factory");
 
 const { remoteClientManager } =
   require("devtools/client/shared/remote-debugging/remote-client-manager");
 
 const {
   CONNECT_RUNTIME_FAILURE,
   CONNECT_RUNTIME_START,
   CONNECT_RUNTIME_SUCCESS,
-  DEBUG_TARGETS,
   DISCONNECT_RUNTIME_FAILURE,
   DISCONNECT_RUNTIME_START,
   DISCONNECT_RUNTIME_SUCCESS,
   PAGE_TYPES,
   REMOTE_RUNTIMES_UPDATED,
   RUNTIME_PREFERENCE,
   RUNTIMES,
   THIS_FIREFOX_RUNTIME_CREATED,
@@ -205,27 +203,19 @@ function watchRuntime(id) {
         // THIS_FIREFOX connects and disconnects on the fly when opening the page.
         await dispatch(connectRuntime(RUNTIMES.THIS_FIREFOX));
       }
 
       // The selected runtime should already have a connected client assigned.
       const runtime = findRuntimeById(id, getState().runtimes);
       await dispatch({ type: WATCH_RUNTIME_SUCCESS, runtime });
 
-      if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.EXTENSION)) {
-        dispatch(Actions.requestExtensions());
-      }
-
-      if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.TAB)) {
-        dispatch(Actions.requestTabs());
-      }
-
-      if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.WORKER)) {
-        dispatch(Actions.requestWorkers());
-      }
+      dispatch(Actions.requestExtensions());
+      dispatch(Actions.requestTabs());
+      dispatch(Actions.requestWorkers());
     } catch (e) {
       dispatch({ type: WATCH_RUNTIME_FAILURE, error: e });
     }
   };
 }
 
 function unwatchRuntime(id) {
   return async (dispatch, getState) => {
--- a/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js
+++ b/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js
@@ -1,21 +1,19 @@
 /* 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 {
-  DEBUG_TARGETS,
   UNWATCH_RUNTIME_START,
   WATCH_RUNTIME_SUCCESS,
 } = require("../constants");
 const Actions = require("../actions/index");
-const { isSupportedDebugTarget } = require("../modules/debug-target-support");
 
 function debugTargetListenerMiddleware(store) {
   const onExtensionsUpdated = () => {
     store.dispatch(Actions.requestExtensions());
   };
 
   const onTabsUpdated = () => {
     store.dispatch(Actions.requestTabs());
@@ -26,73 +24,69 @@ function debugTargetListenerMiddleware(s
   };
 
   return next => action => {
     switch (action.type) {
       case WATCH_RUNTIME_SUCCESS: {
         const { runtime } = action;
         const { clientWrapper } = runtime.runtimeDetails;
 
-        if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.TAB)) {
-          clientWrapper.addListener("tabListChanged", onTabsUpdated);
-        }
+        // Tabs
+        clientWrapper.addListener("tabListChanged", onTabsUpdated);
 
-        if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.EXTENSION)) {
-          clientWrapper.addListener("addonListChanged", onExtensionsUpdated);
-        }
+        // Addons
+        clientWrapper.addListener("addonListChanged", onExtensionsUpdated);
 
-        if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.WORKER)) {
-          clientWrapper.addListener("workerListChanged", onWorkersUpdated);
-          clientWrapper.onFront("contentProcessTarget", front => {
-            clientWrapper.contentProcessFronts.push(front);
-            front.on("workerListChanged", onWorkersUpdated);
-          });
+        // Workers
+        clientWrapper.addListener("workerListChanged", onWorkersUpdated);
+        clientWrapper.onFront("contentProcessTarget", front => {
+          clientWrapper.contentProcessFronts.push(front);
+          front.on("workerListChanged", onWorkersUpdated);
+        });
 
-          clientWrapper.onFront("serviceWorkerRegistration", front => {
-            clientWrapper.serviceWorkerRegistrationFronts.push(front);
-            front.on("push-subscription-modified", onWorkersUpdated);
-            front.on("registration-changed", onWorkersUpdated);
-          });
+        clientWrapper.onFront("serviceWorkerRegistration", front => {
+          clientWrapper.serviceWorkerRegistrationFronts.push(front);
+          front.on("push-subscription-modified", onWorkersUpdated);
+          front.on("registration-changed", onWorkersUpdated);
+        });
 
-          clientWrapper.addListener("serviceWorkerRegistrationListChanged",
-            onWorkersUpdated);
-          clientWrapper.addListener("processListChanged", onWorkersUpdated);
-        }
+        clientWrapper.addListener("serviceWorkerRegistrationListChanged",
+          onWorkersUpdated);
+        clientWrapper.addListener("processListChanged", onWorkersUpdated);
+
         break;
       }
       case UNWATCH_RUNTIME_START: {
         const { runtime } = action;
         const { clientWrapper } = runtime.runtimeDetails;
 
-        if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.TAB)) {
-          clientWrapper.removeListener("tabListChanged", onTabsUpdated);
-        }
+        // Tabs
+        clientWrapper.removeListener("tabListChanged", onTabsUpdated);
 
-        if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.EXTENSION)) {
-          clientWrapper.removeListener("addonListChanged", onExtensionsUpdated);
-        }
+        // Addons
+        clientWrapper.removeListener("addonListChanged", onExtensionsUpdated);
 
-        if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.WORKER)) {
-          clientWrapper.removeListener("workerListChanged", onWorkersUpdated);
-          clientWrapper.removeListener("serviceWorkerRegistrationListChanged",
-            onWorkersUpdated);
+        // Workers
+        clientWrapper.removeListener("workerListChanged", onWorkersUpdated);
+        clientWrapper.removeListener("serviceWorkerRegistrationListChanged",
+          onWorkersUpdated);
 
-          for (const front of clientWrapper.contentProcessFronts) {
-            front.off("workerListChanged", onWorkersUpdated);
-          }
-          clientWrapper.contentProcessFronts = [];
+        for (const front of clientWrapper.contentProcessFronts) {
+          front.off("workerListChanged", onWorkersUpdated);
+        }
+        clientWrapper.contentProcessFronts = [];
 
-          for (const front of clientWrapper.serviceWorkerRegistrationFronts) {
-            front.off("push-subscription-modified", onWorkersUpdated);
-            front.off("registration-changed", onWorkersUpdated);
-          }
-          clientWrapper.serviceWorkerRegistrationFronts = [];
+        for (const front of clientWrapper.serviceWorkerRegistrationFronts) {
+          front.off("push-subscription-modified", onWorkersUpdated);
+          front.off("registration-changed", onWorkersUpdated);
+        }
+        clientWrapper.serviceWorkerRegistrationFronts = [];
 
-          clientWrapper.removeListener("processListChanged", onWorkersUpdated);
-        }
+        clientWrapper.removeListener("processListChanged", onWorkersUpdated);
+
         break;
       }
     }
 
     return next(action);
   };
 }
 
--- a/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js
+++ b/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js
@@ -1,54 +1,33 @@
 /* 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 { DEBUG_TARGETS, DEBUG_TARGET_PANE, RUNTIMES } = require("../constants");
-
-const ALL_DEBUG_TARGETS = [
-  DEBUG_TARGETS.EXTENSION,
-  DEBUG_TARGETS.TAB,
-  DEBUG_TARGETS.WORKER,
-];
-
-const SUPPORTED_TARGET_BY_RUNTIME = {
-  [RUNTIMES.THIS_FIREFOX]: ALL_DEBUG_TARGETS,
-  [RUNTIMES.NETWORK]: ALL_DEBUG_TARGETS,
-  [RUNTIMES.USB]: [
-    DEBUG_TARGETS.EXTENSION,
-    DEBUG_TARGETS.TAB,
-  ],
-};
-
-function isSupportedDebugTarget(runtimeType, debugTargetType) {
-  return SUPPORTED_TARGET_BY_RUNTIME[runtimeType].includes(debugTargetType);
-}
-exports.isSupportedDebugTarget = isSupportedDebugTarget;
+const { DEBUG_TARGET_PANE, RUNTIMES } = require("../constants");
 
 const ALL_DEBUG_TARGET_PANES = [
   DEBUG_TARGET_PANE.INSTALLED_EXTENSION,
   DEBUG_TARGET_PANE.OTHER_WORKER,
   DEBUG_TARGET_PANE.SERVICE_WORKER,
   DEBUG_TARGET_PANE.SHARED_WORKER,
   DEBUG_TARGET_PANE.TAB,
   DEBUG_TARGET_PANE.TEMPORARY_EXTENSION,
 ];
 
+// All debug target panes except temporary extensions
+const REMOTE_DEBUG_TARGET_PANES = ALL_DEBUG_TARGET_PANES.filter(p =>
+  p !== DEBUG_TARGET_PANE.TEMPORARY_EXTENSION);
+
 const SUPPORTED_TARGET_PANE_BY_RUNTIME = {
   [RUNTIMES.THIS_FIREFOX]: ALL_DEBUG_TARGET_PANES,
-  [RUNTIMES.USB]: [
-    DEBUG_TARGET_PANE.INSTALLED_EXTENSION,
-    DEBUG_TARGET_PANE.TAB,
-  ],
-  // All debug target panes except temporary extensions
-  [RUNTIMES.NETWORK]: ALL_DEBUG_TARGET_PANES.filter(p =>
-    p !== DEBUG_TARGET_PANE.TEMPORARY_EXTENSION),
+  [RUNTIMES.USB]: REMOTE_DEBUG_TARGET_PANES,
+  [RUNTIMES.NETWORK]: REMOTE_DEBUG_TARGET_PANES,
 };
 
 /**
  * A debug target pane is more specialized than a debug target. For instance EXTENSION is
  * a DEBUG_TARGET but INSTALLED_EXTENSION and TEMPORARY_EXTENSION are DEBUG_TARGET_PANES.
  */
 function isSupportedDebugTargetPane(runtimeType, debugTargetPaneKey) {
   return SUPPORTED_TARGET_PANE_BY_RUNTIME[runtimeType].includes(debugTargetPaneKey);
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
@@ -24,16 +24,19 @@ add_task(async function() {
   });
   mocks.emitUSBUpdate();
 
   await connectToRuntime(RUNTIME_DEVICE_NAME, document);
   await selectRuntime(RUNTIME_DEVICE_NAME, RUNTIME_APP_NAME, document);
 
   const SUPPORTED_TARGET_PANES = [
     "Extensions",
+    "Other Workers",
+    "Shared Workers",
+    "Service Workers",
     "Tabs",
   ];
 
   for (const { title } of TARGET_PANES) {
     const debugTargetPaneEl = getDebugTargetPane(title, document);
     if (SUPPORTED_TARGET_PANES.includes(title)) {
       ok(debugTargetPaneEl, `Supported target pane [${title}] is displayed`);
     } else {