From 7a27eea6209d72f9138201ce7bd4e115b407c8ae Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Mon, 21 May 2018 10:16:46 -0700 Subject: [PATCH] Bug 1461366 - Focus the Browser Console window after opening;r=nchevobbe This allows keyboard shortcuts to work right away when the input field isn't present. MozReview-Commit-ID: COmmybkUu0m --HG-- extra : rebase_source : 1e40fc7be3e97b990b1b3839482618eb9b7f166b --- devtools/client/webconsole/new-webconsole.js | 4 ++++ .../test/mochitest/browser_console_open_or_focus.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/devtools/client/webconsole/new-webconsole.js b/devtools/client/webconsole/new-webconsole.js index 730a33566a1d..ebb3dc846907 100644 --- a/devtools/client/webconsole/new-webconsole.js +++ b/devtools/client/webconsole/new-webconsole.js @@ -241,6 +241,10 @@ NewWebConsoleFrame.prototype = { shortcuts.on(clearShortcut, () => this.jsterm.clearOutput(true)); if (this.isBrowserConsole) { + // Make sure keyboard shortcuts work immediately after opening + // the Browser Console (Bug 1461366). + this.window.focus(); + shortcuts.on(l10n.getStr("webconsole.close.key"), this.window.top.close.bind(this.window.top)); diff --git a/devtools/client/webconsole/test/mochitest/browser_console_open_or_focus.js b/devtools/client/webconsole/test/mochitest/browser_console_open_or_focus.js index 718b84d96551..d245fd976874 100644 --- a/devtools/client/webconsole/test/mochitest/browser_console_open_or_focus.js +++ b/devtools/client/webconsole/test/mochitest/browser_console_open_or_focus.js @@ -20,6 +20,8 @@ add_task(async function() { hud = HUDService.getBrowserConsole(); + ok(hud.ui.document.hasFocus(), "Focus in the document"); + console.log(TEST_MESSAGE); await waitFor(() => findMessage(hud, TEST_MESSAGE));