зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1694140 - [devtools] Stop using TargetFactory.forTab outside of devtools r=rpl,ochameau
Depends on D106000 Differential Revision: https://phabricator.services.mozilla.com/D106001
This commit is contained in:
Родитель
982c525960
Коммит
1ac3484028
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче