Skip to content

Commit

Permalink
Bug 1374735 - use DevToolsShim to retrieve the WebExtensionInspectedW…
Browse files Browse the repository at this point in the history
…indowFront;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
  • Loading branch information
juliandescottes committed Jul 12, 2017
1 parent dee86ba commit 386c9d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 4 additions & 5 deletions browser/components/extensions/ext-devtools-inspectedWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
11 changes: 11 additions & 0 deletions devtools/client/framework/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions devtools/shim/DevToolsShim.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ let addonSdkMethods = [
let webExtensionsMethods = [
"getTargetForTab",
"getTheme",
"createWebExtensionInspectedWindowFront",
];

for (let method of [...addonSdkMethods, ...webExtensionsMethods]) {
Expand Down

0 comments on commit 386c9d0

Please sign in to comment.