summaryrefslogtreecommitdiffstats
path: root/devtools/client/framework
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/framework')
-rw-r--r--devtools/client/framework/components/MeatballMenu.js34
-rw-r--r--devtools/client/framework/components/ToolboxToolbar.js8
-rw-r--r--devtools/client/framework/test/browser_dynamic_tool_enabling.js2
-rw-r--r--devtools/client/framework/test/browser_toolbox_error_count.js32
-rw-r--r--devtools/client/framework/test/browser_toolbox_error_count_reset_on_navigation.js2
-rw-r--r--devtools/client/framework/test/browser_toolbox_remoteness_change.js2
-rw-r--r--devtools/client/framework/test/browser_toolbox_screenshot_tool.js2
-rw-r--r--devtools/client/framework/test/browser_toolbox_watchedByDevTools.js5
-rw-r--r--devtools/client/framework/toolbox-init.js4
-rw-r--r--devtools/client/framework/toolbox-options.html12
-rw-r--r--devtools/client/framework/toolbox-options.js10
-rw-r--r--devtools/client/framework/toolbox.js49
12 files changed, 132 insertions, 30 deletions
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=<meta charset=ut
const { Toolbox } = require("resource://devtools/client/framework/toolbox.js");
add_task(async function () {
- // Make sure we start the test with the split console disabled.
- await pushPref("devtools.toolbox.splitconsoleEnabled", false);
+ // Make sure we start the test with the split console closed, and the split console setting enabled
+ await pushPref("devtools.toolbox.splitconsole.open", false);
+ await pushPref("devtools.toolbox.splitconsole.enabled", true);
+
+ registerCleanupFunction(() => {
+ 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 @@
</label>
</fieldset>
+ <fieldset id="webconsole-options" class="options-groupbox">
+ <legend data-l10n-id="options-webconsole-label"></legend>
+ <label data-l10n-id="options-webconsole-split-console-tooltip">
+ <input
+ type="checkbox"
+ id="devtools-enable-split-console"
+ data-pref="devtools.toolbox.splitconsole.enabled"
+ />
+ <span data-l10n-id="options-webconsole-split-console-label"></span>
+ </label>
+ </fieldset>
+
<fieldset id="styleeditor-options" class="options-groupbox">
<legend data-l10n-id="options-styleeditor-label"></legend>
<label data-l10n-id="options-stylesheet-autocompletion-tooltip">
diff --git a/devtools/client/framework/toolbox-options.js b/devtools/client/framework/toolbox-options.js
index 98b263ad44..809804e2f1 100644
--- a/devtools/client/framework/toolbox-options.js
+++ b/devtools/client/framework/toolbox-options.js
@@ -106,6 +106,10 @@ OptionsPanel.prototype = {
"devtools.source-map.client-service.enabled",
this._prefChanged
);
+ Services.prefs.addObserver(
+ "devtools.toolbox.splitconsole.enabled",
+ this._prefChanged
+ );
gDevTools.on("theme-registered", this._themeRegistered);
gDevTools.on("theme-unregistered", this._themeUnregistered);
@@ -126,6 +130,10 @@ OptionsPanel.prototype = {
"devtools.source-map.client-service.enabled",
this._prefChanged
);
+ Services.prefs.removeObserver(
+ "devtools.toolbox.splitconsole.enabled",
+ this._prefChanged
+ );
this.toolbox.off("tool-registered", this.setupToolsList);
this.toolbox.off("tool-unregistered", this.setupToolsList);
@@ -145,6 +153,8 @@ OptionsPanel.prototype = {
this.updateCurrentTheme();
} else if (prefName === "devtools.source-map.client-service.enabled") {
this.updateSourceMapPref();
+ } else if (prefName === "devtools.toolbox.splitconsole.enabled") {
+ this.toolbox.updateIsSplitConsoleEnabled();
}
},
diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js
index a03360aa26..222f928ecf 100644
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -5,7 +5,8 @@
"use strict";
const MAX_ORDINAL = 99;
-const SPLITCONSOLE_ENABLED_PREF = "devtools.toolbox.splitconsoleEnabled";
+const SPLITCONSOLE_OPEN_PREF = "devtools.toolbox.splitconsole.open";
+const SPLITCONSOLE_ENABLED_PREF = "devtools.toolbox.splitconsole.enabled";
const SPLITCONSOLE_HEIGHT_PREF = "devtools.toolbox.splitconsoleHeight";
const DEVTOOLS_ALWAYS_ON_TOP = "devtools.toolbox.alwaysOnTop";
const DISABLE_AUTOHIDE_PREF = "ui.popup.disable_autohide";
@@ -41,8 +42,8 @@ var Startup = Cc["@mozilla.org/devtools/startup-clh;1"].getService(
Ci.nsISupports
).wrappedJSObject;
-const { BrowserLoader } = ChromeUtils.import(
- "resource://devtools/shared/loader/browser-loader.js"
+const { BrowserLoader } = ChromeUtils.importESModule(
+ "resource://devtools/shared/loader/browser-loader.sys.mjs"
);
const {
@@ -608,6 +609,18 @@ Toolbox.prototype = {
);
},
+ /**
+ * Get the enabled split console setting, and if it's not set, set it with updateIsSplitConsoleEnabled
+ * @returns {boolean} devtools.toolbox.splitconsole.enabled option
+ */
+ isSplitConsoleEnabled() {
+ if (typeof this._splitConsoleEnabled !== "boolean") {
+ this.updateIsSplitConsoleEnabled();
+ }
+
+ return this._splitConsoleEnabled;
+ },
+
get isBrowserToolbox() {
return this.hostType === Toolbox.HostType.BROWSERTOOLBOX;
},
@@ -1038,7 +1051,7 @@ Toolbox.prototype = {
// Wait until the original tool is selected so that the split
// console input will receive focus.
let splitConsolePromise = Promise.resolve();
- if (Services.prefs.getBoolPref(SPLITCONSOLE_ENABLED_PREF)) {
+ if (Services.prefs.getBoolPref(SPLITCONSOLE_OPEN_PREF)) {
splitConsolePromise = this.openSplitConsole();
this.telemetry.addEventProperty(
this.topWindow,
@@ -1617,7 +1630,7 @@ Toolbox.prototype = {
},
_splitConsoleOnKeypress(e) {
- if (e.keyCode !== KeyCodes.DOM_VK_ESCAPE) {
+ if (e.keyCode !== KeyCodes.DOM_VK_ESCAPE || !this.isSplitConsoleEnabled()) {
return;
}
@@ -2351,6 +2364,21 @@ Toolbox.prototype = {
},
/**
+ * Setup the _splitConsoleEnabled, reflecting the enabled/disabled state of the Enable Split
+ * Console setting, and close the split console if it's open and the setting is turned off
+ */
+ updateIsSplitConsoleEnabled() {
+ this._splitConsoleEnabled = Services.prefs.getBoolPref(
+ SPLITCONSOLE_ENABLED_PREF,
+ true
+ );
+
+ if (!this._splitConsoleEnabled && this.splitConsole) {
+ this.closeSplitConsole();
+ }
+ },
+
+ /**
* Ensure the visibility of each toolbox button matches the preference value.
*/
_commandIsVisible(button) {
@@ -3013,8 +3041,15 @@ Toolbox.prototype = {
* loaded and focused.
*/
openSplitConsole({ focusConsoleInput = true } = {}) {
+ if (!this.isSplitConsoleEnabled()) {
+ return this.selectTool(
+ "webconsole",
+ "use_in_console_with_disabled_split_console"
+ );
+ }
+
this._splitConsole = true;
- Services.prefs.setBoolPref(SPLITCONSOLE_ENABLED_PREF, true);
+ Services.prefs.setBoolPref(SPLITCONSOLE_OPEN_PREF, true);
this._refreshConsoleDisplay();
// Ensure split console is visible if console was already loaded in background
@@ -3044,7 +3079,7 @@ Toolbox.prototype = {
*/
closeSplitConsole() {
this._splitConsole = false;
- Services.prefs.setBoolPref(SPLITCONSOLE_ENABLED_PREF, false);
+ Services.prefs.setBoolPref(SPLITCONSOLE_OPEN_PREF, false);
this._refreshConsoleDisplay();
this.component.setIsSplitConsoleActive(false);