diff --git a/browser/components/extensions/test/browser/head_devtools.js b/browser/components/extensions/test/browser/head_devtools.js index 7b4d602d4cfb..cb966be055e3 100644 --- a/browser/components/extensions/test/browser/head_devtools.js +++ b/browser/components/extensions/test/browser/head_devtools.js @@ -2,7 +2,7 @@ /* vim: set sts=2 sw=2 et tw=80: */ "use strict"; -/* exported openToolboxForTab, closeToolboxForTab, getToolboxTargetForTab, +/* exported openToolboxForTab, closeToolboxForTab, registerBlankToolboxPanel, TOOLBOX_BLANK_PANEL_ID, assertDevToolsExtensionEnabled */ ChromeUtils.defineModuleGetter( @@ -14,10 +14,6 @@ XPCOMUtils.defineLazyGetter(this, "gDevTools", () => { const { gDevTools } = loader.require("devtools/client/framework/devtools"); return gDevTools; }); -XPCOMUtils.defineLazyGetter(this, "TargetFactory", () => { - const { TargetFactory } = loader.require("devtools/client/framework/target"); - return TargetFactory; -}); ChromeUtils.defineModuleGetter( this, @@ -56,10 +52,6 @@ async function registerBlankToolboxPanel() { gDevTools.registerTool(testBlankPanel); } -function getToolboxTargetForTab(tab) { - return TargetFactory.forTab(tab); -} - async function openToolboxForTab(tab, panelId = TOOLBOX_BLANK_PANEL_ID) { if ( panelId == TOOLBOX_BLANK_PANEL_ID && @@ -69,22 +61,24 @@ async function openToolboxForTab(tab, panelId = TOOLBOX_BLANK_PANEL_ID) { registerBlankToolboxPanel(); } - const target = await getToolboxTargetForTab(tab); - const toolbox = await gDevTools.showToolbox(target, panelId); - const { url, outerWindowID } = target.form; + const toolbox = await gDevTools.showToolboxForTab(tab, { toolId: panelId }); + const { url, outerWindowID } = toolbox.target.form; info( `Developer toolbox opened on panel "${panelId}" for target ${JSON.stringify( { url, outerWindowID } )}` ); - return { toolbox, target }; + return { toolbox, target: toolbox.target }; } async function closeToolboxForTab(tab) { - const target = await getToolboxTargetForTab(tab); + const toolbox = await gDevTools.getToolboxForTab(tab); + const target = toolbox.target; const { url, outerWindowID } = target.form; - await gDevTools.closeToolbox(target); + + await gDevTools.closeToolboxForTab(tab); await target.destroy(); + info( `Developer toolbox closed for target ${JSON.stringify({ url, diff --git a/browser/tools/mozscreenshots/devtools/browser_devtools.js b/browser/tools/mozscreenshots/devtools/browser_devtools.js index 367bda2617c7..5f2504bc7233 100644 --- a/browser/tools/mozscreenshots/devtools/browser_devtools.js +++ b/browser/tools/mozscreenshots/devtools/browser_devtools.js @@ -7,7 +7,6 @@ "use strict"; const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm"); -const { TargetFactory } = require("devtools/client/framework/target"); const { gDevTools } = require("devtools/client/framework/devtools"); add_task(async function capture() { @@ -18,6 +17,5 @@ add_task(async function capture() { await TestRunner.start(sets, "devtools"); - let target = await TargetFactory.forTab(gBrowser.selectedTab); - await gDevTools.closeToolbox(target); + await gDevTools.closeToolboxForTab(gBrowser.selectedTab); }); diff --git a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/DevTools.jsm b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/DevTools.jsm index a15e1ea77a55..937c60a80cac 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/DevTools.jsm +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/DevTools.jsm @@ -7,15 +7,14 @@ var EXPORTED_SYMBOLS = ["DevTools"]; const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm"); -const { TargetFactory } = require("devtools/client/framework/target"); const { gDevTools } = require("devtools/client/framework/devtools"); const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm"); -async function getTargetForSelectedTab() { - let browserWindow = Services.wm.getMostRecentWindow("navigator:browser"); - let target = await TargetFactory.forTab(browserWindow.gBrowser.selectedTab); - return target; +async function showToolboxForSelectedTab(toolId, hostType) { + const browserWindow = Services.wm.getMostRecentWindow("navigator:browser"); + const tab = browserWindow.gBrowser.selectedTab; + return gDevTools.showToolboxForTab(tab, { toolId, hostType }); } function selectToolbox(toolbox) { @@ -37,8 +36,7 @@ var DevTools = { this.configurations[panel] = {}; this.configurations[panel].applyConfig = async function() { Services.prefs.setIntPref("devtools.toolbox.footer.height", 800); - let target = await getTargetForSelectedTab(); - let toolbox = await gDevTools.showToolbox(target, panel, "bottom"); + let toolbox = await showToolboxForSelectedTab(panel, "bottom"); this.selectors = [selectToolbox.bind(null, toolbox)]; await new Promise(resolve => setTimeout(resolve, 500)); }; @@ -49,20 +47,14 @@ var DevTools = { bottomToolbox: { async applyConfig() { Services.prefs.clearUserPref("devtools.toolbox.footer.height"); - let target = await getTargetForSelectedTab(); - let toolbox = await gDevTools.showToolbox( - target, - "inspector", - "bottom" - ); + let toolbox = await showToolboxForSelectedTab("inspector", "bottom"); this.selectors = [selectToolbox.bind(null, toolbox)]; await new Promise(resolve => setTimeout(resolve, 1000)); }, }, sideToolbox: { async applyConfig() { - let target = await getTargetForSelectedTab(); - let toolbox = await gDevTools.showToolbox(target, "inspector", "right"); + let toolbox = await showToolboxForSelectedTab("inspector", "right"); this.selectors = [selectToolbox.bind(null, toolbox)]; await new Promise(resolve => setTimeout(resolve, 1000)); }, @@ -73,12 +65,7 @@ var DevTools = { undockedToolbox: { windowType: "devtools:toolbox", async applyConfig() { - let target = await getTargetForSelectedTab(); - let toolbox = await gDevTools.showToolbox( - target, - "inspector", - "window" - ); + let toolbox = await showToolboxForSelectedTab("inspector", "window"); this.selectors = [selectToolbox.bind(null, toolbox)]; await new Promise(resolve => setTimeout(resolve, 1000)); },