From 0cda1042cc7827d256435c315bac64c1971e4366 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Wed, 12 Jul 2017 11:04:28 +0200 Subject: [PATCH] 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 --- .../extensions/ext-devtools-inspectedWindow.js | 9 ++++----- devtools/client/framework/devtools.js | 11 +++++++++++ devtools/shim/DevToolsShim.jsm | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/browser/components/extensions/ext-devtools-inspectedWindow.js b/browser/components/extensions/ext-devtools-inspectedWindow.js index a24a7203e771..7e52a6b387d9 100644 --- a/browser/components/extensions/ext-devtools-inspectedWindow.js +++ b/browser/components/extensions/ext-devtools-inspectedWindow.js @@ -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() { diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js index 40abbd2a8ac6..03629444a062 100644 --- a/devtools/client/framework/devtools.js +++ b/devtools/client/framework/devtools.js @@ -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. * diff --git a/devtools/shim/DevToolsShim.jsm b/devtools/shim/DevToolsShim.jsm index a505f706fcfd..f761492f944b 100644 --- a/devtools/shim/DevToolsShim.jsm +++ b/devtools/shim/DevToolsShim.jsm @@ -300,6 +300,7 @@ let addonSdkMethods = [ let webExtensionsMethods = [ "getTargetForTab", "getTheme", + "createWebExtensionInspectedWindowFront", ]; for (let method of [...addonSdkMethods, ...webExtensionsMethods]) {