Bug 1539344 - Part 1: share constants between about:debugging and DebugTargetInfo r=jdescottes,Ola
authorBelén Albeza <balbeza@mozilla.com>
Wed, 10 Apr 2019 09:59:05 +0000
changeset 468814 51e1db28ce228ab4cd5b2b12a69369e4df4994b7
parent 468813 5967ffe89473dc2cc5ecdd516a83a126b8b57755
child 468815 f3e332b425b3a4fb7d8cb1c3944156587a13b864
push id112755
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 22:06:41 +0000
treeherdermozilla-inbound@606f85641d0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, Ola
bugs1539344
milestone68.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 1539344 - Part 1: share constants between about:debugging and DebugTargetInfo r=jdescottes,Ola Differential Revision: https://phabricator.services.mozilla.com/D25374
devtools/client/aboutdebugging-new/src/actions/debug-targets.js
devtools/client/aboutdebugging-new/src/constants.js
devtools/client/aboutdebugging-new/src/types/debug-target.js
devtools/client/framework/components/DebugTargetInfo.js
devtools/client/framework/test/jest/components/debug-target-info.test.js
devtools/client/shared/remote-debugging/constants.js
devtools/client/shared/remote-debugging/moz.build
devtools/client/shared/remote-debugging/remote-client-manager.js
--- a/devtools/client/aboutdebugging-new/src/actions/debug-targets.js
+++ b/devtools/client/aboutdebugging-new/src/actions/debug-targets.js
@@ -52,24 +52,24 @@ function inspectDebugTarget(type, id) {
       // actor is cached in the client instance. Instead we should pass an id that does
       // not depend on the client (such as the worker url). This will be fixed in
       // Bug 1539328.
       // Once the target is destroyed after closing the toolbox, the front will be gone
       // and can no longer be used. When debugging This Firefox, workers are regularly
       // updated so this is not an issue. On remote runtimes however, trying to inspect a
       // worker a second time after closing the corresponding about:devtools-toolbox tab
       // will fail. See Bug 1534201.
-      window.open(`about:devtools-toolbox?type=${type.toLowerCase()}&id=${id}`);
+      window.open(`about:devtools-toolbox?type=${type}&id=${id}`);
     } else {
-      window.open(`about:devtools-toolbox?type=${type.toLowerCase()}&id=${id}` +
+      window.open(`about:devtools-toolbox?type=${type}&id=${id}` +
                   `&remoteId=${remoteId}`);
     }
 
     dispatch(Actions.recordTelemetryEvent("inspect", {
-      "target_type": type,
+      "target_type": type.toUpperCase(),
       "runtime_type": runtime.type,
     }));
   };
 }
 
 function installTemporaryExtension() {
   const message = l10n.getString("about-debugging-tmp-extension-install-message");
   return async (dispatch, getState) => {
--- a/devtools/client/aboutdebugging-new/src/constants.js
+++ b/devtools/client/aboutdebugging-new/src/constants.js
@@ -1,16 +1,16 @@
 /* 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 { CONNECTION_TYPES } =
-  require("devtools/client/shared/remote-debugging/remote-client-manager");
+const { CONNECTION_TYPES, DEBUG_TARGET_TYPES } =
+  require("devtools/client/shared/remote-debugging/constants");
 
 const actionTypes = {
   ADB_ADDON_INSTALL_START: "ADB_ADDON_INSTALL_START",
   ADB_ADDON_INSTALL_SUCCESS: "ADB_ADDON_INSTALL_SUCCESS",
   ADB_ADDON_INSTALL_FAILURE: "ADB_ADDON_INSTALL_FAILURE",
   ADB_ADDON_UNINSTALL_START: "ADB_ADDON_UNINSTALL_START",
   ADB_ADDON_UNINSTALL_SUCCESS: "ADB_ADDON_UNINSTALL_SUCCESS",
   ADB_ADDON_UNINSTALL_FAILURE: "ADB_ADDON_UNINSTALL_FAILURE",
@@ -62,22 +62,17 @@ const actionTypes = {
   UPDATE_RUNTIME_MULTIE10S_SUCCESS: "UPDATE_RUNTIME_MULTIE10S_SUCCESS",
   USB_RUNTIMES_SCAN_START: "USB_RUNTIMES_SCAN_START",
   USB_RUNTIMES_SCAN_SUCCESS: "USB_RUNTIMES_SCAN_SUCCESS",
   WATCH_RUNTIME_FAILURE: "WATCH_RUNTIME_FAILURE",
   WATCH_RUNTIME_START: "WATCH_RUNTIME_START",
   WATCH_RUNTIME_SUCCESS: "WATCH_RUNTIME_SUCCESS",
 };
 
-const DEBUG_TARGETS = {
-  EXTENSION: "EXTENSION",
-  PROCESS: "PROCESS",
-  TAB: "TAB",
-  WORKER: "WORKER",
-};
+const DEBUG_TARGETS = DEBUG_TARGET_TYPES;
 
 const DEBUG_TARGET_PANE = {
   INSTALLED_EXTENSION: "installedExtension",
   PROCESSES: "processes",
   OTHER_WORKER: "otherWorker",
   SERVICE_WORKER: "serviceWorker",
   SHARED_WORKER: "sharedWorker",
   TAB: "tab",
--- a/devtools/client/aboutdebugging-new/src/types/debug-target.js
+++ b/devtools/client/aboutdebugging-new/src/types/debug-target.js
@@ -1,15 +1,16 @@
 /* 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 PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+const { DEBUG_TARGETS } = require("../constants");
 
 const extensionTargetDetails = {
   // actor ID for this extention.
   actor: PropTypes.string.isRequired,
   location: PropTypes.string.isRequired,
   // manifestURL points to the manifest.json file. This URL is only valid when debugging
   // local extensions so it might be null.
   manifestURL: PropTypes.string,
@@ -54,13 +55,13 @@ const debugTarget = {
   icon: PropTypes.string.isRequired,
   // unique id for the target (unique in the scope of the application lifecycle).
   // - extensions: {String} extension id (for instance "someextension@mozilla.org")
   // - tabs: {Number} outerWindowID
   // - workers: {String} id for the WorkerTargetActor corresponding to the worker
   id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
   // display name for the debug target.
   name: PropTypes.string.isRequired,
-  // one of "EXTENSION", "TAB", "WORKER".
-  type: PropTypes.string.isRequired,
+  // one of "extension", "tab", "worker", "process".
+  type: PropTypes.oneOf(Object.values(DEBUG_TARGETS)).isRequired,
 };
 
 exports.debugTarget = PropTypes.shape(debugTarget);
--- a/devtools/client/framework/components/DebugTargetInfo.js
+++ b/devtools/client/framework/components/DebugTargetInfo.js
@@ -2,17 +2,17 @@
  * 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 { PureComponent } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 const { CONNECTION_TYPES } =
-  require("devtools/client/shared/remote-debugging/remote-client-manager");
+  require("devtools/client/shared/remote-debugging/constants");
 
 /**
  * This is header that should be displayed on top of the toolbox when using
  * about:devtools-toolbox.
  */
 class DebugTargetInfo extends PureComponent {
   static get propTypes() {
     return {
--- a/devtools/client/framework/test/jest/components/debug-target-info.test.js
+++ b/devtools/client/framework/test/jest/components/debug-target-info.test.js
@@ -5,17 +5,17 @@
 
 /**
  * Unit tests for the DebugTargetInfo component.
  */
 
 const renderer = require("react-test-renderer");
 const React = require("devtools/client/shared/vendor/react");
 const DebugTargetInfo = React.createFactory(require("devtools/client/framework/components/DebugTargetInfo"));
-const { CONNECTION_TYPES } = require("devtools/client/shared/remote-debugging/remote-client-manager");
+const { CONNECTION_TYPES } = require("devtools/client/shared/remote-debugging/constants");
 
 /**
  * Stub for the L10N property expected by the DebugTargetInfo component.
  */
 const stubL10N = {
   getStr: id => id,
   getFormatStr: (id, ...args) => [id, ...args].join("-"),
 };
new file mode 100644
--- /dev/null
+++ b/devtools/client/shared/remote-debugging/constants.js
@@ -0,0 +1,24 @@
+/* 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 CONNECTION_TYPES = {
+  NETWORK: "network",
+  THIS_FIREFOX: "this-firefox",
+  UNKNOWN: "unknown",
+  USB: "usb",
+};
+
+const DEBUG_TARGET_TYPES = {
+  EXTENSION: "extension",
+  PROCESS: "process",
+  TAB: "tab",
+  WORKER: "worker",
+};
+
+module.exports = {
+  CONNECTION_TYPES,
+  DEBUG_TARGET_TYPES,
+};
--- a/devtools/client/shared/remote-debugging/moz.build
+++ b/devtools/client/shared/remote-debugging/moz.build
@@ -1,15 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 DevToolsModules(
+    'constants.js',
     'remote-client-manager.js',
     'version-checker.js',
 )
 
 XPCSHELL_TESTS_MANIFESTS += [
     'test/unit/xpcshell.ini'
 ]
 
--- a/devtools/client/shared/remote-debugging/remote-client-manager.js
+++ b/devtools/client/shared/remote-debugging/remote-client-manager.js
@@ -1,21 +1,15 @@
 /* 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";
 
-/* connection types for remote clients */
-const CONNECTION_TYPES = {
-  NETWORK: "network",
-  THIS_FIREFOX: "this-firefox",
-  UNKNOWN: "unknown",
-  USB: "usb",
-};
+const { CONNECTION_TYPES } = require("devtools/client/shared/remote-debugging/constants");
 
 /**
  * This class is designed to be a singleton shared by all DevTools to get access to
  * existing clients created for remote debugging.
  */
 class RemoteClientManager {
   constructor() {
     this._clients = new Map();
@@ -121,10 +115,9 @@ class RemoteClientManager {
       this._removeClientByKey(key);
     }
   }
 }
 
 // Expose a singleton of RemoteClientManager.
 module.exports = {
   remoteClientManager: new RemoteClientManager(),
-  CONNECTION_TYPES,
 };