From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- .../client/framework/components/MeatballMenu.js | 34 +++++++++------ .../client/framework/components/ToolboxToolbar.js | 8 ++-- .../test/browser_dynamic_tool_enabling.js | 2 +- .../framework/test/browser_toolbox_error_count.js | 32 +++++++++++++- ...wser_toolbox_error_count_reset_on_navigation.js | 2 +- .../test/browser_toolbox_remoteness_change.js | 2 +- .../test/browser_toolbox_screenshot_tool.js | 2 +- .../test/browser_toolbox_watchedByDevTools.js | 5 +++ devtools/client/framework/toolbox-init.js | 4 +- devtools/client/framework/toolbox-options.html | 12 ++++++ devtools/client/framework/toolbox-options.js | 10 +++++ devtools/client/framework/toolbox.js | 49 ++++++++++++++++++---- 12 files changed, 132 insertions(+), 30 deletions(-) (limited to 'devtools/client/framework') diff --git a/devtools/client/framework/components/MeatballMenu.js b/devtools/client/framework/components/MeatballMenu.js index fc694171c8..74d8592723 100644 --- a/devtools/client/framework/components/MeatballMenu.js +++ b/devtools/client/framework/components/MeatballMenu.js @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +const SPLITCONSOLE_ENABLED_PREF = "devtools.toolbox.splitconsole.enabled"; + const { PureComponent, createFactory, @@ -180,19 +182,27 @@ class MeatballMenu extends PureComponent { // Split console if (this.props.currentToolId !== "webconsole") { - const l10nID = this.props.isSplitConsoleActive - ? "toolbox-meatball-menu-hideconsole-label" - : "toolbox-meatball-menu-splitconsole-label"; - items.push( - MenuItem({ - id: "toolbox-meatball-menu-splitconsole", - key: "splitconsole", - l10nID, - accelerator: "Esc", - onClick: this.props.toggleSplitConsole, - className: "iconic", - }) + const isSplitConsoleEnabled = Services.prefs.getBoolPref( + SPLITCONSOLE_ENABLED_PREF, + true ); + + if (isSplitConsoleEnabled) { + const l10nID = this.props.isSplitConsoleActive + ? "toolbox-meatball-menu-hideconsole-label" + : "toolbox-meatball-menu-splitconsole-label"; + + items.push( + MenuItem({ + id: "toolbox-meatball-menu-splitconsole", + key: "splitconsole", + l10nID, + accelerator: "Esc", + onClick: this.props.toggleSplitConsole, + className: "iconic", + }) + ); + } } // Settings diff --git a/devtools/client/framework/components/ToolboxToolbar.js b/devtools/client/framework/components/ToolboxToolbar.js index f9998db0ab..bd9e3d5071 100644 --- a/devtools/client/framework/components/ToolboxToolbar.js +++ b/devtools/client/framework/components/ToolboxToolbar.js @@ -320,6 +320,10 @@ class ToolboxToolbar extends Component { errorCount = "99+"; } + const errorIconTooltip = this.props.toolbox.isSplitConsoleEnabled() + ? this.props.L10N.getStr("toolbox.errorCountButton.tooltip") + : this.props.L10N.getStr("toolbox.errorCountButtonConsoleTab.tooltip"); + return button( { id, @@ -330,9 +334,7 @@ class ToolboxToolbar extends Component { } }, title: - this.props.currentToolId !== "webconsole" - ? this.props.L10N.getStr("toolbox.errorCountButton.tooltip") - : null, + this.props.currentToolId !== "webconsole" ? errorIconTooltip : null, }, errorCount ); diff --git a/devtools/client/framework/test/browser_dynamic_tool_enabling.js b/devtools/client/framework/test/browser_dynamic_tool_enabling.js index 56313607cf..0caf32b134 100644 --- a/devtools/client/framework/test/browser_dynamic_tool_enabling.js +++ b/devtools/client/framework/test/browser_dynamic_tool_enabling.js @@ -11,7 +11,7 @@ var gItemsToTest = { }; function expectedAttributeValueFromPrefs(prefs) { - return prefs.every(pref => Services.prefs.getBoolPref(pref)) ? "" : "true"; + return prefs.every(pref => Services.prefs.getBoolPref(pref)) ? null : "true"; } function checkItem(el, prefs) { diff --git a/devtools/client/framework/test/browser_toolbox_error_count.js b/devtools/client/framework/test/browser_toolbox_error_count.js index e4dcf0214f..858615f18b 100644 --- a/devtools/client/framework/test/browser_toolbox_error_count.js +++ b/devtools/client/framework/test/browser_toolbox_error_count.js @@ -22,8 +22,14 @@ const TEST_URI = `https://example.com/document-builder.sjs?html= { + Services.prefs.clearUserPref("devtools.toolbox.splitconsole.enabled"); + }); + const tab = await addTab(TEST_URI); const toolbox = await openToolboxForTab( @@ -175,6 +181,28 @@ add_task(async function () { "The error is displayed again, with the correct error count, after enabling it from the settings panel" ); + info("Disable the split console from the options panel"); + const splitConsoleButtonToggleEl = + optionsPanel.panelWin.document.querySelector( + "input#devtools-enable-split-console" + ); + splitConsoleButtonToggleEl.click(); + await waitFor( + () => getErrorIcon(toolbox).getAttribute("title") === "Show Console" + ); + ok( + true, + "The error count icon title changed to reflect split console being disabled" + ); + + info( + "Check if with split console being disabled click leads to the console tab" + ); + const onWebConsole = toolbox.once("webconsole-selected"); + getErrorIcon(toolbox).click(); + await onWebConsole; + ok(!toolbox.splitConsole, "Web Console opened instead of split console"); + toolbox.destroy(); }); diff --git a/devtools/client/framework/test/browser_toolbox_error_count_reset_on_navigation.js b/devtools/client/framework/test/browser_toolbox_error_count_reset_on_navigation.js index 53f5068655..ebf862be88 100644 --- a/devtools/client/framework/test/browser_toolbox_error_count_reset_on_navigation.js +++ b/devtools/client/framework/test/browser_toolbox_error_count_reset_on_navigation.js @@ -23,7 +23,7 @@ add_task(async function () { // Make sure we start the test with the split console disabled. // ⚠️ In this test it's important to _not_ enable the console. - await pushPref("devtools.toolbox.splitconsoleEnabled", false); + await pushPref("devtools.toolbox.splitconsole.open", false); const tab = await addTab(TEST_URI); const toolbox = await openToolboxForTab( diff --git a/devtools/client/framework/test/browser_toolbox_remoteness_change.js b/devtools/client/framework/test/browser_toolbox_remoteness_change.js index af5f105214..ff019d1826 100644 --- a/devtools/client/framework/test/browser_toolbox_remoteness_change.js +++ b/devtools/client/framework/test/browser_toolbox_remoteness_change.js @@ -19,7 +19,7 @@ add_task(async function () { ); is( tab.linkedBrowser.getAttribute("remote"), - "", + null, "And running in parent process" ); diff --git a/devtools/client/framework/test/browser_toolbox_screenshot_tool.js b/devtools/client/framework/test/browser_toolbox_screenshot_tool.js index 63c8b9fd58..e87830a940 100644 --- a/devtools/client/framework/test/browser_toolbox_screenshot_tool.js +++ b/devtools/client/framework/test/browser_toolbox_screenshot_tool.js @@ -121,6 +121,6 @@ add_task(async function () { await resetDownloads(); const closePromise = BrowserTestUtils.windowClosed(privateWindow); - privateWindow.BrowserTryToCloseWindow(); + privateWindow.BrowserCommands.tryToCloseWindow(); await closePromise; }); diff --git a/devtools/client/framework/test/browser_toolbox_watchedByDevTools.js b/devtools/client/framework/test/browser_toolbox_watchedByDevTools.js index a58b57885d..7365c43313 100644 --- a/devtools/client/framework/test/browser_toolbox_watchedByDevTools.js +++ b/devtools/client/framework/test/browser_toolbox_watchedByDevTools.js @@ -64,6 +64,11 @@ add_task(async function () { info("Check that the flag is reset when the toolbox is closed"); await gDevTools.closeToolboxForTab(tab); + + // As the destroy sequence of DevTools server is synchronous and we aren't waiting + // for full completion of server cleanups, we have to wait for its full processing. + await waitFor(() => !tab.linkedBrowser.browsingContext.watchedByDevTools); + is( tab.linkedBrowser.browsingContext.watchedByDevTools, false, diff --git a/devtools/client/framework/toolbox-init.js b/devtools/client/framework/toolbox-init.js index de2bce080a..130f94dc0e 100644 --- a/devtools/client/framework/toolbox-init.js +++ b/devtools/client/framework/toolbox-init.js @@ -40,8 +40,8 @@ const onLoad = new Promise(r => { async function showErrorPage(doc, errorMessage) { const win = doc.defaultView; - const { BrowserLoader } = ChromeUtils.import( - "resource://devtools/shared/loader/browser-loader.js" + const { BrowserLoader } = ChromeUtils.importESModule( + "resource://devtools/shared/loader/browser-loader.sys.mjs" ); const browserRequire = BrowserLoader({ window: win, diff --git a/devtools/client/framework/toolbox-options.html b/devtools/client/framework/toolbox-options.html index 2ff33a581f..08c63265f0 100644 --- a/devtools/client/framework/toolbox-options.html +++ b/devtools/client/framework/toolbox-options.html @@ -126,6 +126,18 @@ +
+ + +
+