From 9d101b9e445e8f0f06dbe3cc11e8d822bf502fab Mon Sep 17 00:00:00 2001 From: Daisuke Akatsuka Date: Mon, 1 Oct 2018 09:17:38 +0000 Subject: [PATCH] Bug 1488507: Disable extension/worker debugging except this firefox. r=jdescottes Depends on D7038 Differential Revision: https://phabricator.services.mozilla.com/D7039 --HG-- extra : moz-landing-system : lando --- .../src/actions/runtimes.js | 19 ++- .../src/components/RuntimePage.js | 157 ++++++++---------- .../src/modules/debug-target-support.js | 25 +++ .../aboutdebugging-new/src/modules/moz.build | 1 + 4 files changed, 106 insertions(+), 96 deletions(-) create mode 100644 devtools/client/aboutdebugging-new/src/modules/debug-target-support.js diff --git a/devtools/client/aboutdebugging-new/src/actions/runtimes.js b/devtools/client/aboutdebugging-new/src/actions/runtimes.js index 7b40df5d6479..dbd5feea7054 100644 --- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js +++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js @@ -13,11 +13,13 @@ const Actions = require("./index"); const { findRuntimeById, } = require("../modules/runtimes-state-helper"); +const { isSupportedDebugTarget } = require("../modules/debug-target-support"); const { CONNECT_RUNTIME_FAILURE, CONNECT_RUNTIME_START, CONNECT_RUNTIME_SUCCESS, + DEBUG_TARGETS, DISCONNECT_RUNTIME_FAILURE, DISCONNECT_RUNTIME_START, DISCONNECT_RUNTIME_SUCCESS, @@ -67,7 +69,7 @@ async function createClientForRuntime(runtime) { } async function getRuntimeInfo(runtime, client) { - const { model } = runtime; + const { model, type } = runtime; const deviceFront = await client.mainRoot.getFront("device"); const { brandName: name, channel, version } = await deviceFront.getDescription(); const icon = @@ -79,6 +81,7 @@ async function getRuntimeInfo(runtime, client) { icon, model, name, + type, version, }; } @@ -143,9 +146,17 @@ function watchRuntime(id) { const runtime = findRuntimeById(id, getState().runtimes); await dispatch({ type: WATCH_RUNTIME_SUCCESS, runtime }); - dispatch(Actions.requestExtensions()); - dispatch(Actions.requestTabs()); - dispatch(Actions.requestWorkers()); + 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()); + } } catch (e) { dispatch({ type: WATCH_RUNTIME_FAILURE, error: e.message }); } diff --git a/devtools/client/aboutdebugging-new/src/components/RuntimePage.js b/devtools/client/aboutdebugging-new/src/components/RuntimePage.js index 44c9d94767fc..9b1e6dadb0de 100644 --- a/devtools/client/aboutdebugging-new/src/components/RuntimePage.js +++ b/devtools/client/aboutdebugging-new/src/components/RuntimePage.js @@ -25,6 +25,7 @@ const WorkerDetail = createFactory(require("./debugtarget/WorkerDetail")); const { DEBUG_TARGET_PANE } = require("../constants"); const { getCurrentRuntimeInfo } = require("../modules/runtimes-state-helper"); +const { isSupportedDebugTargetPane } = require("../modules/debug-target-support"); class RuntimePage extends PureComponent { static get propTypes() { @@ -41,9 +42,33 @@ class RuntimePage extends PureComponent { }; } + renderDebugTargetPane(name, targets, actionComponent, + detailComponent, paneKey, localizationId) { + const { collapsibilities, dispatch, runtimeInfo } = this.props; + + if (!isSupportedDebugTargetPane(runtimeInfo.type, paneKey)) { + return null; + } + + return Localized( + { + id: localizationId, + attrs: { name: true } + }, + DebugTargetPane({ + actionComponent, + collapsibilityKey: paneKey, + detailComponent, + dispatch, + isCollapsed: collapsibilities.get(paneKey), + name, + targets, + }) + ); + } + render() { const { - collapsibilities, dispatch, installedExtensions, otherWorkers, @@ -65,97 +90,45 @@ class RuntimePage extends PureComponent { className: "page js-runtime-page", }, RuntimeInfo(runtimeInfo), - TemporaryExtensionInstaller({ dispatch }), - Localized( - { - id: "about-debugging-runtime-temporary-extensions", - attrs: { name: true } - }, - DebugTargetPane({ - actionComponent: TemporaryExtensionAction, - collapsibilityKey: DEBUG_TARGET_PANE.TEMPORARY_EXTENSION, - detailComponent: ExtensionDetail, - dispatch, - isCollapsed: collapsibilities.get(DEBUG_TARGET_PANE.TEMPORARY_EXTENSION), - name: "Temporary Extensions", - targets: temporaryExtensions, - }) - ), - Localized( - { - id: "about-debugging-runtime-extensions", - attrs: { name: true } - }, - DebugTargetPane({ - actionComponent: InspectAction, - collapsibilityKey: DEBUG_TARGET_PANE.INSTALLED_EXTENSION, - detailComponent: ExtensionDetail, - dispatch, - isCollapsed: collapsibilities.get(DEBUG_TARGET_PANE.INSTALLED_EXTENSION), - name: "Extensions", - targets: installedExtensions, - }) - ), - Localized( - { - id: "about-debugging-runtime-tabs", - attrs: { name: true } - }, - DebugTargetPane({ - actionComponent: InspectAction, - collapsibilityKey: DEBUG_TARGET_PANE.TAB, - detailComponent: TabDetail, - dispatch, - isCollapsed: collapsibilities.get(DEBUG_TARGET_PANE.TAB), - name: "Tabs", - targets: tabs - }) - ), - Localized( - { - id: "about-debugging-runtime-service-workers", - attrs: { name: true } - }, - DebugTargetPane({ - actionComponent: ServiceWorkerAction, - collapsibilityKey: DEBUG_TARGET_PANE.SERVICE_WORKER, - detailComponent: WorkerDetail, - dispatch, - isCollapsed: collapsibilities.get(DEBUG_TARGET_PANE.SERVICE_WORKER), - name: "Service Workers", - targets: serviceWorkers - }) - ), - Localized( - { - id: "about-debugging-runtime-shared-workers", - attrs: { name: true } - }, - DebugTargetPane({ - actionComponent: InspectAction, - collapsibilityKey: DEBUG_TARGET_PANE.SHARED_WORKER, - detailComponent: WorkerDetail, - dispatch, - isCollapsed: collapsibilities.get(DEBUG_TARGET_PANE.SHARED_WORKER), - name: "Shared Workers", - targets: sharedWorkers - }) - ), - Localized( - { - id: "about-debugging-runtime-other-workers", - attrs: { name: true } - }, - DebugTargetPane({ - actionComponent: InspectAction, - collapsibilityKey: DEBUG_TARGET_PANE.OTHER_WORKER, - detailComponent: WorkerDetail, - dispatch, - isCollapsed: collapsibilities.get(DEBUG_TARGET_PANE.OTHER_WORKER), - name: "Other Workers", - targets: otherWorkers - }) - ), + isSupportedDebugTargetPane(runtimeInfo.type, DEBUG_TARGET_PANE.TEMPORARY_EXTENSION) + ? TemporaryExtensionInstaller({ dispatch }) + : null, + this.renderDebugTargetPane("Temporary Extensions", + temporaryExtensions, + TemporaryExtensionAction, + ExtensionDetail, + DEBUG_TARGET_PANE.TEMPORARY_EXTENSION, + "about-debugging-runtime-temporary-extensions"), + this.renderDebugTargetPane("Extensions", + installedExtensions, + InspectAction, + ExtensionDetail, + DEBUG_TARGET_PANE.INSTALLED_EXTENSION, + "about-debugging-runtime-extensions"), + this.renderDebugTargetPane("Tabs", + tabs, + InspectAction, + TabDetail, + DEBUG_TARGET_PANE.TAB, + "about-debugging-runtime-tabs"), + this.renderDebugTargetPane("Service Workers", + serviceWorkers, + ServiceWorkerAction, + WorkerDetail, + DEBUG_TARGET_PANE.SERVICE_WORKER, + "about-debugging-runtime-service-workers"), + this.renderDebugTargetPane("Shared Workers", + sharedWorkers, + InspectAction, + WorkerDetail, + DEBUG_TARGET_PANE.SHARED_WORKER, + "about-debugging-runtime-shared-workers"), + this.renderDebugTargetPane("Other Workers", + otherWorkers, + InspectAction, + WorkerDetail, + DEBUG_TARGET_PANE.OTHER_WORKER, + "about-debugging-runtime-other-workers"), ); } } diff --git a/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js b/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js new file mode 100644 index 000000000000..35bb312fbdb0 --- /dev/null +++ b/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js @@ -0,0 +1,25 @@ +/* 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"); + +function isSupportedDebugTarget(runtimeType, debugTargetType) { + if (runtimeType === RUNTIMES.THIS_FIREFOX) { + return true; + } + + return debugTargetType === DEBUG_TARGETS.TAB; +} +exports.isSupportedDebugTarget = isSupportedDebugTarget; + +function isSupportedDebugTargetPane(runtimeType, debugTargetPaneKey) { + if (runtimeType === RUNTIMES.THIS_FIREFOX) { + return true; + } + + return debugTargetPaneKey === DEBUG_TARGET_PANE.TAB; +} +exports.isSupportedDebugTargetPane = isSupportedDebugTargetPane; diff --git a/devtools/client/aboutdebugging-new/src/modules/moz.build b/devtools/client/aboutdebugging-new/src/modules/moz.build index 884cba6c6400..a22562027813 100644 --- a/devtools/client/aboutdebugging-new/src/modules/moz.build +++ b/devtools/client/aboutdebugging-new/src/modules/moz.build @@ -4,6 +4,7 @@ DevToolsModules( 'debug-target-collapsibilities.js', + 'debug-target-support.js', 'extensions-helper.js', 'network-locations.js', 'runtimes-state-helper.js',