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
This commit is contained in:
Daisuke Akatsuka 2018-10-01 09:17:38 +00:00
parent c9e805c422
commit 9d101b9e44
4 changed files with 106 additions and 96 deletions

View File

@ -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 });
}

View File

@ -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"),
);
}
}

View File

@ -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;

View File

@ -4,6 +4,7 @@
DevToolsModules(
'debug-target-collapsibilities.js',
'debug-target-support.js',
'extensions-helper.js',
'network-locations.js',
'runtimes-state-helper.js',