Bug 1374735 - use DevToolsShim to retrieve the WebExtensionInspectedWindowFront;r=ochameau,rpl

Expose an API to retrieve devtools' WebExtensionInspectedWindowFront which is needed
for webextensions. Exposed a new API on devtools/DevToolsShim

MozReview-Commit-ID: Dyc2UUJGsrs

--HG--
extra : rebase_source : 018660cc54bf2454c1f810ded639fd647ba79da3
This commit is contained in:
Julian Descottes 2017-07-12 11:04:28 +02:00
Родитель c6f45428f0
Коммит 0cda1042cc
3 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -4,16 +4,15 @@
/* global getDevToolsTargetForContext */
XPCOMUtils.defineLazyModuleGetter(this, "DevToolsShim",
"chrome://devtools-shim/content/DevToolsShim.jsm");
var {
SpreadArgs,
} = ExtensionCommon;
this.devtools_inspectedWindow = class extends ExtensionAPI {
getAPI(context) {
const {
WebExtensionInspectedWindowFront,
} = require("devtools/shared/fronts/webextension-inspected-window");
// Lazily retrieve and store an inspectedWindow actor front per child context.
let waitForInspectedWindowFront;
async function getInspectedWindowFront() {
@ -22,7 +21,7 @@ this.devtools_inspectedWindow = class extends ExtensionAPI {
// because the first time that the target has been cloned, it is not ready to be used to create
// the front instance until it is connected to the remote debugger successfully).
const clonedTarget = await getDevToolsTargetForContext(context);
return new WebExtensionInspectedWindowFront(clonedTarget.client, clonedTarget.form);
return DevToolsShim.createWebExtensionInspectedWindowFront(clonedTarget);
}
function getToolboxOptions() {

Просмотреть файл

@ -22,6 +22,9 @@ loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/main", true);
loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
loader.lazyRequireGetter(this, "WebExtensionInspectedWindowFront",
"devtools/shared/fronts/webextension-inspected-window", true);
const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
require("devtools/client/definitions");
const EventEmitter = require("devtools/shared/old-event-emitter");
@ -579,6 +582,14 @@ DevTools.prototype = {
BrowserToolboxProcess.init({ addonID });
},
/**
* Compatibility layer for web-extensions. Used by DevToolsShim for
* browser/components/extensions/ext-devtools-inspectedWindow.js
*/
createWebExtensionInspectedWindowFront: function (tabTarget) {
return new WebExtensionInspectedWindowFront(tabTarget.client, tabTarget.form);
},
/**
* Called from the DevToolsShim, used by nsContextMenu.js.
*

Просмотреть файл

@ -300,6 +300,7 @@ let addonSdkMethods = [
let webExtensionsMethods = [
"getTargetForTab",
"getTheme",
"createWebExtensionInspectedWindowFront",
];
for (let method of [...addonSdkMethods, ...webExtensionsMethods]) {