diff --git a/browser/components/extensions/ext-devtools-inspectedWindow.js b/browser/components/extensions/ext-devtools-inspectedWindow.js index 7e52a6b387d9..a24a7203e771 100644 --- a/browser/components/extensions/ext-devtools-inspectedWindow.js +++ b/browser/components/extensions/ext-devtools-inspectedWindow.js @@ -4,15 +4,16 @@ /* 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() { @@ -21,7 +22,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 DevToolsShim.createWebExtensionInspectedWindowFront(clonedTarget); + return new WebExtensionInspectedWindowFront(clonedTarget.client, clonedTarget.form); } function getToolboxOptions() { diff --git a/browser/components/extensions/ext-devtools.js b/browser/components/extensions/ext-devtools.js index 7394e5826a38..d9c8fc4b4b1c 100644 --- a/browser/components/extensions/ext-devtools.js +++ b/browser/components/extensions/ext-devtools.js @@ -53,8 +53,9 @@ global.getDevToolsTargetForContext = async (context) => { throw new Error("Unexpected target type: only local tabs are currently supported."); } - const tab = context.devToolsToolbox.target.tab; - context.devToolsTarget = DevToolsShim.getTargetForTab(tab); + const {TabTarget} = require("devtools/client/framework/target"); + + context.devToolsTarget = new TabTarget(context.devToolsToolbox.target.tab); await context.devToolsTarget.makeRemote(); return context.devToolsTarget; diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js index 10f3202a0e01..40abbd2a8ac6 100644 --- a/devtools/client/framework/devtools.js +++ b/devtools/client/framework/devtools.js @@ -22,9 +22,6 @@ 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"); @@ -582,23 +579,6 @@ 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); - }, - - /** - * Compatibility layer for web-extensions. Used by DevToolsShim for - * toolkit/components/extensions/ext-c-toolkit.js - */ - openBrowserConsole: function () { - let {HUDService} = require("devtools/client/webconsole/hudservice"); - HUDService.openBrowserConsoleOrFocus(); - }, - /** * Called from the DevToolsShim, used by nsContextMenu.js. * diff --git a/devtools/shim/DevToolsShim.jsm b/devtools/shim/DevToolsShim.jsm index 303b8d38464d..fabf8f3c48f9 100644 --- a/devtools/shim/DevToolsShim.jsm +++ b/devtools/shim/DevToolsShim.jsm @@ -286,6 +286,7 @@ let addonSdkMethods = [ "closeToolbox", "connectDebuggerServer", "createDebuggerClient", + "getTargetForTab", "getToolbox", "initBrowserToolboxProcessForAddon", "showToolbox", @@ -298,10 +299,7 @@ let addonSdkMethods = [ * therefore DevTools should always be available when they are called. */ let webExtensionsMethods = [ - "createWebExtensionInspectedWindowFront", - "getTargetForTab", "getTheme", - "openBrowserConsole", ]; for (let method of [...addonSdkMethods, ...webExtensionsMethods]) { diff --git a/toolkit/components/extensions/ExtensionCommon.jsm b/toolkit/components/extensions/ExtensionCommon.jsm index a9a075c9aed1..32d1b134e07b 100644 --- a/toolkit/components/extensions/ExtensionCommon.jsm +++ b/toolkit/components/extensions/ExtensionCommon.jsm @@ -1262,6 +1262,7 @@ class SchemaAPIManager extends EventEmitter { XPCOMUtils.defineLazyModuleGetters(global, { ExtensionUtils: "resource://gre/modules/ExtensionUtils.jsm", XPCOMUtils: "resource://gre/modules/XPCOMUtils.jsm", + require: "resource://devtools/shared/Loader.jsm", }); return global; diff --git a/toolkit/components/extensions/ext-c-toolkit.js b/toolkit/components/extensions/ext-c-toolkit.js index a0c9438f3512..76cec1aae3e5 100644 --- a/toolkit/components/extensions/ext-c-toolkit.js +++ b/toolkit/components/extensions/ext-c-toolkit.js @@ -2,11 +2,6 @@ Cu.import("resource://gre/modules/ExtensionCommon.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Services", - "resource://gre/modules/Services.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "DevToolsShim", - "chrome://devtools-shim/content/DevToolsShim.jsm"); - // These are defined on "global" which is used for the same scopes as the other // ext-c-*.js files. /* exported EventManager */ @@ -21,7 +16,11 @@ global.initializeBackgroundPage = (contentWindow) => { let alertDisplayedWarning = false; let alertOverwrite = text => { if (!alertDisplayedWarning) { - DevToolsShim.openBrowserConsole(); + require("devtools/client/framework/devtools-browser"); + + let {HUDService} = require("devtools/client/webconsole/hudservice"); + HUDService.openBrowserConsoleOrFocus(); + contentWindow.console.warn("alert() is not supported in background windows; please use console.log instead."); alertDisplayedWarning = true;