Bug 1471795 - Part 11: Add inspect button. r?jdescottes
MozReview-Commit-ID: 4HFFqFQOQFa
--- a/devtools/client/aboutdebugging-new/src/components/DebugTargetsPane.js
+++ b/devtools/client/aboutdebugging-new/src/components/DebugTargetsPane.js
@@ -90,22 +90,24 @@ class DebugTargetsPane extends PureCompo
{
className: "debug-targets-pane",
},
RuntimeInfo({ info }),
DebugTargetList({
className: "debug-target-list--temporary-extensions",
debugTargetItemComponent: ExtensionItem,
debugTargets: temporaryExtensions,
+ runtime,
title: "Temporary Extensions",
}),
DebugTargetList({
className: "debug-target-list--installed-extensions",
debugTargetItemComponent: ExtensionItem,
debugTargets: installedExtensions,
+ runtime,
title: "Extensions",
}),
DebugTargetList({
className: "debug-target-list--tabs",
debugTargetItemComponent: TabItem,
debugTargets: tabs,
runtime,
title: "Tabs",
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionItem.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionItem.js
@@ -14,31 +14,42 @@ class ExtensionItem extends DebugTargetI
return debugTarget.iconURL || "chrome://mozapps/skin/extensions/extensionGeneric.svg";
}
getName() {
const { debugTarget } = this.props;
return debugTarget.name;
}
+ inspect() {
+ const { debugTarget, runtime } = this.props;
+ runtime.inspectExtension(debugTarget);
+ }
+
parseFileUri(url) {
// Strip a leading slash from Windows drive letter URIs.
// file:///home/foo ~> /home/foo
// file:///C:/foo ~> C:/foo
const windowsRegex = /^file:\/\/\/([a-zA-Z]:\/.*)/;
if (windowsRegex.test(url)) {
return windowsRegex.exec(url)[1];
}
return url.slice("file://".length);
}
renderActionComponents() {
- return null;
+ return dom.button(
+ {
+ className: "debug-target-item__actions__extension-inspect",
+ onClick: e => this.inspect(),
+ },
+ "Inspect"
+ );
}
renderDetailComponents() {
return dom.div(
{
className: "debug-target-item__info__detail__extension",
},
this.renderFilePath(),
--- a/devtools/client/aboutdebugging-new/src/runtimes/runtime.js
+++ b/devtools/client/aboutdebugging-new/src/runtimes/runtime.js
@@ -56,16 +56,25 @@ class Runtime {
* Subclass should override this method.
* @return {Array}
*/
async getTabs() {
throw new Error("Subclass of Runtime should override getTabs()");
}
/**
+ * Inspect the provided extension target which can get by getExtensions().
+ * Subclass should override this method.
+ * @param {Object} - debug target
+ */
+ async inspectExtension(_) {
+ throw new Error("Subclass of Runtime should override inspectExtension()");
+ }
+
+ /**
* Inspect the provided tab target which can get by getTabs().
* Subclass should override this method.
* @param {Object} - debug target
*/
async inspectTab(_) {
throw new Error("Subclass of Runtime should override inspectTab()");
}
--- a/devtools/client/aboutdebugging-new/src/runtimes/this-firefox.js
+++ b/devtools/client/aboutdebugging-new/src/runtimes/this-firefox.js
@@ -1,14 +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 { BrowserToolboxProcess } =
+ require("resource://devtools/client/framework/ToolboxProcess.jsm");
const { DebuggerClient } = require("devtools/shared/client/debugger-client");
const { DebuggerServer } = require("devtools/server/main");
const Services = require("Services");
const Runtime = require("./runtime");
/**
* This class represents the Firefox instance which runs in the same environment that
@@ -41,16 +43,30 @@ class ThisFirefox extends Runtime {
};
}
async getTabs() {
const { tabs } = await this.client.listTabs({ favicons: true });
return tabs;
}
+ async inspectExtension(debugTarget) {
+ // Close previous addon debugging toolbox.
+ if (this.browserToolboxProcess) {
+ this.browserToolboxProcess.close();
+ }
+
+ this.browserToolboxProcess = BrowserToolboxProcess.init({
+ addonID: debugTarget.id,
+ onClose: () => {
+ this.browserToolboxProcess = null;
+ }
+ });
+ }
+
async inspectTab(debugTarget) {
window.open(`about:devtools-toolbox?type=tab&id=${ debugTarget.outerWindowID }`);
}
removeTabsUpdateListener(listener) {
this.client.removeListener("tabListChanged", listener);
}
}