Bug 1593753 - [devtools] Remove the "Browser Content Toolbox". r=jdescottes

The Browser Toolbox should be handy enough now with parent versus multiprocess modes
to debug the content process. The context selector in the right of the console evaluation
of the browser console and toolbox allow to select the content processes.
The thread selector in the debugger also allow to distinguish content processes.

Differential Revision: https://phabricator.services.mozilla.com/D164704
This commit is contained in:
Alexandre Poirot 2022-12-21 13:57:49 +00:00
Родитель 443ffe6f54
Коммит 52f6708144
9 изменённых файлов: 1 добавлений и 207 удалений

Просмотреть файл

@ -78,8 +78,6 @@ skip-if = debug # Window leaks: bug 1575332
skip-if = skip-if =
os == 'linux' && bits == 64 && debug # Bug 1750199 os == 'linux' && bits == 64 && debug # Bug 1750199
apple_catalina && !debug # Bug 1767705 apple_catalina && !debug # Bug 1767705
[browser_dbg-browser-content-toolbox.js]
skip-if = verify
[browser_dbg-continue-to-here.js] [browser_dbg-continue-to-here.js]
[browser_dbg-continue-to-here-click.js] [browser_dbg-continue-to-here-click.js]
skip-if = os == "win" skip-if = os == "win"

Просмотреть файл

@ -1,68 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/**
* Tests that the debugger is succesfully loaded in the Browser Content Toolbox.
*/
"use strict";
const {
gDevToolsBrowser,
} = require("devtools/client/framework/devtools-browser");
add_task(async function() {
clearDebuggerPreferences();
info("Open a tab pointing to doc-scripts.html");
await addTab(`${EXAMPLE_URL}doc-scripts.html`);
info("Open the Browser Content Toolbox");
const toolbox = await gDevToolsBrowser.openContentProcessToolbox(gBrowser);
info("Select the debugger");
await toolbox.selectTool("jsdebugger");
const dbg = createDebuggerContext(toolbox);
ok(dbg, "Debugger context is available");
info("Create a breakpoint");
await selectSource(dbg, "simple2.js");
await addBreakpoint(dbg, "simple2.js", 3);
info("Disable the breakpoint");
await disableBreakpoint(dbg, 0);
let bp = findBreakpoint(dbg, "simple2.js", 3);
is(bp.disabled, true, "breakpoint is disabled");
info("Enable the breakpoint");
await enableBreakpoint(dbg, 0);
bp = findBreakpoint(dbg, "simple2.js", 3);
is(bp.disabled, false, "breakpoint is enabled");
info("Close the browser toolbox window");
const onToolboxDestroyed = toolbox.once("destroyed");
toolbox.win.top.close();
await onToolboxDestroyed;
info("Toolbox is destroyed");
});
function toggleBreakpoint(dbg, index) {
const bp = findAllElements(dbg, "breakpointItems")[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg.store, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}
async function enableBreakpoint(dbg, index) {
const enabled = waitForDispatch(dbg.store, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await enabled;
}

Просмотреть файл

@ -62,17 +62,6 @@ loader.lazyRequireGetter(
"resource://devtools/client/framework/enable-devtools-popup.js", "resource://devtools/client/framework/enable-devtools-popup.js",
true true
); );
loader.lazyRequireGetter(
this,
"CommandsFactory",
"resource://devtools/shared/commands/commands-factory.js",
true
);
const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);
const BROWSER_STYLESHEET_URL = "chrome://devtools/skin/devtools-browser.css"; const BROWSER_STYLESHEET_URL = "chrome://devtools/skin/devtools-browser.css";
@ -142,16 +131,11 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = {
); );
const remoteEnabled = chromeEnabled && devtoolsRemoteEnabled; const remoteEnabled = chromeEnabled && devtoolsRemoteEnabled;
toggleMenuItem("menu_browserToolbox", remoteEnabled); toggleMenuItem("menu_browserToolbox", remoteEnabled);
toggleMenuItem(
"menu_browserContentToolbox",
remoteEnabled && win.gMultiProcessBrowser
);
if (Services.prefs.getBoolPref("devtools.policy.disabled", false)) { if (Services.prefs.getBoolPref("devtools.policy.disabled", false)) {
toggleMenuItem("menu_devToolbox", false); toggleMenuItem("menu_devToolbox", false);
toggleMenuItem("menu_devtools_remotedebugging", false); toggleMenuItem("menu_devtools_remotedebugging", false);
toggleMenuItem("menu_browserToolbox", false); toggleMenuItem("menu_browserToolbox", false);
toggleMenuItem("menu_browserContentToolbox", false);
toggleMenuItem("menu_browserConsole", false); toggleMenuItem("menu_browserConsole", false);
toggleMenuItem("menu_responsiveUI", false); toggleMenuItem("menu_responsiveUI", false);
toggleMenuItem("menu_eyedropper", false); toggleMenuItem("menu_eyedropper", false);
@ -348,61 +332,6 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = {
gBrowser.selectedTab = gBrowser.addTrustedTab(url); gBrowser.selectedTab = gBrowser.addTrustedTab(url);
}, },
/**
* Open the Browser Content Toolbox for the provided gBrowser instance.
* Returns a promise that resolves with a toolbox instance. If no content process is
* available, the promise will be rejected and a message will be displayed to the user.
*
* Used by menus.js
*/
async openContentProcessToolbox(gBrowser) {
const { childCount } = Services.ppmm;
// Get the process message manager for the current tab
const mm = gBrowser.selectedBrowser.messageManager.processMessageManager;
let processId = null;
for (let i = 1; i < childCount; i++) {
const child = Services.ppmm.getChildAt(i);
if (child == mm) {
processId = mm.osPid;
break;
}
}
if (processId) {
try {
const commands = await CommandsFactory.forProcess(processId);
// Display a new toolbox in a new window
const toolbox = await gDevTools.showToolbox(commands, {
hostType: Toolbox.HostType.WINDOW,
hostOptions: {
// Will be used by the WINDOW host to decide whether to create a
// private window or not.
browserContentToolboxOpener: gBrowser.ownerGlobal,
},
});
// Ensure closing the connection in order to cleanup
// the devtools client and also the server created in the
// content process
toolbox.target.on("target-destroyed", () => {
toolbox.commands.client.close();
});
return toolbox;
} catch (e) {
console.error(
"Exception while opening the browser content toolbox:",
e
);
}
} else {
const msg = L10N.getStr("toolbox.noContentProcessForTab.message");
Services.prompt.alert(null, "", msg);
throw new Error(msg);
}
return null;
},
/** /**
* Add the devtools-browser stylesheet to browser window's document. Returns a promise. * Add the devtools-browser stylesheet to browser window's document. Returns a promise.
* *

Просмотреть файл

@ -159,7 +159,6 @@ skip-if =
[browser_toolbox_toolbar_reorder_by_width.js] [browser_toolbox_toolbar_reorder_by_width.js]
[browser_toolbox_toolbar_reorder_with_extension.js] [browser_toolbox_toolbar_reorder_with_extension.js]
[browser_toolbox_toolbar_reorder_with_hidden_extension.js] [browser_toolbox_toolbar_reorder_with_hidden_extension.js]
[browser_toolbox_toolbar_reorder_with_secondary_toolbox.js]
[browser_toolbox_tools_per_toolbox_registration.js] [browser_toolbox_tools_per_toolbox_registration.js]
[browser_toolbox_view_source_01.js] [browser_toolbox_view_source_01.js]
[browser_toolbox_view_source_02.js] [browser_toolbox_view_source_02.js]

Просмотреть файл

@ -1,42 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test for reordering with secondary toolbox such as Browser Content Toolbox.
// We test whether the ordering preference will not change when the secondary toolbox
// was closed without reordering.
const {
gDevToolsBrowser,
} = require("resource://devtools/client/framework/devtools-browser.js");
add_task(async function() {
registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.toolbox.selectedTool");
});
// Keep initial tabs order preference of devtools so as to compare after re-ordering
// tabs on browser content toolbox.
const initialTabsOrderOnDevTools = Services.prefs.getCharPref(
"devtools.toolbox.tabsOrder"
);
info("Prepare the toolbox on browser content toolbox");
await addTab(`${URL_ROOT}doc_empty-tab-01.html`);
// Select "memory" tool from first, because the webconsole might connect to the content.
Services.prefs.setCharPref("devtools.toolbox.selectedTool", "memory");
const toolbox = await gDevToolsBrowser.openContentProcessToolbox(gBrowser);
info(
"Check whether the value of devtools.toolbox.tabsOrder was not affected after closed"
);
const onToolboxDestroyed = toolbox.once("destroyed");
toolbox.topWindow.close();
await onToolboxDestroyed;
is(
Services.prefs.getCharPref("devtools.toolbox.tabsOrder"),
initialTabsOrderOnDevTools,
"The preference of devtools.toolbox.tabsOrder should not be affected"
);
});

Просмотреть файл

@ -255,10 +255,7 @@ WindowHost.prototype = {
// set the private flag on the DevTools host window. Otherwise switching // set the private flag on the DevTools host window. Otherwise switching
// hosts between docked and window modes can fail due to incompatible // hosts between docked and window modes can fail due to incompatible
// docshell origin attributes. See 1581093. // docshell origin attributes. See 1581093.
// This host is also used by the Browser Content Toolbox, in which case const owner = this.hostTab?.ownerGlobal;
// the owner window was passed in the host options.
const owner =
this.hostTab?.ownerGlobal || this.options?.browserContentToolboxOpener;
if (owner && lazy.PrivateBrowsingUtils.isWindowPrivate(owner)) { if (owner && lazy.PrivateBrowsingUtils.isWindowPrivate(owner)) {
flags += ",private"; flags += ",private";
} }

Просмотреть файл

@ -22,12 +22,6 @@ eyedropper.accesskey = Y
browserToolboxMenu.label = Browser Toolbox browserToolboxMenu.label = Browser Toolbox
browserToolboxMenu.accesskey = e browserToolboxMenu.accesskey = e
# LOCALIZATION NOTE (browserContentToolboxMenu.label): This is the label for the
# application menu item that opens the browser content toolbox UI in the Tools menu.
# This toolbox allows to debug the chrome of the content process in multiprocess builds.
browserContentToolboxMenu.label = Browser Content Toolbox
browserContentToolboxMenu.accesskey = x
webDeveloperToolsMenu.label = Web Developer Tools webDeveloperToolsMenu.label = Web Developer Tools
webDeveloperToolsMenu.accesskey = T webDeveloperToolsMenu.accesskey = T

Просмотреть файл

@ -72,11 +72,6 @@ toolbox.elementPicker.key=CmdOrCtrl+Shift+C
# Key shortcut used to toggle the element picker for macOS. # Key shortcut used to toggle the element picker for macOS.
toolbox.elementPicker.mac.key=Cmd+Opt+C toolbox.elementPicker.mac.key=Cmd+Opt+C
# LOCALIZATION NOTE (toolbox.noContentProcessForTab.message)
# Used as a message in the alert displayed when trying to open a browser
# content toolbox and there is no content process running for the current tab
toolbox.noContentProcessForTab.message=No content process for this tab.
# LOCALIZATION NOTE (toolbox.viewCssSourceInStyleEditor.label) # LOCALIZATION NOTE (toolbox.viewCssSourceInStyleEditor.label)
# Used as a message in either tooltips or contextual menu items to open the # Used as a message in either tooltips or contextual menu items to open the
# corresponding URL as a css file in the Style-Editor tool. # corresponding URL as a css file in the Style-Editor tool.

Просмотреть файл

@ -94,14 +94,6 @@ exports.menuitems = [
}, },
keyId: "browserToolbox", keyId: "browserToolbox",
}, },
{
id: "menu_browserContentToolbox",
l10nKey: "browserContentToolboxMenu",
oncommand(event) {
const window = event.target.ownerDocument.defaultView;
gDevToolsBrowser.openContentProcessToolbox(window.gBrowser);
},
},
{ {
id: "menu_browserConsole", id: "menu_browserConsole",
l10nKey: "browserConsoleCmd", l10nKey: "browserConsoleCmd",