Bug 1453894 - Give focus to console input when closing sidebar with Escape key; r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 16 Apr 2018 10:23:39 +0200
changeset 467416 212963ca6f2ba0108f411573deef62dc06746823
parent 467415 ced1f03536a4c5bf940a18139d25bd4f828251bb
child 467417 32bab10d9158958341dea029fd5f7f36b753619e
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1453894
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453894 - Give focus to console input when closing sidebar with Escape key; r=Honza. MozReview-Commit-ID: J9y6XkmKJ43
devtools/client/webconsole/new-webconsole.js
devtools/client/webconsole/test/mochitest/browser_webconsole_close_sidebar.js
--- a/devtools/client/webconsole/new-webconsole.js
+++ b/devtools/client/webconsole/new-webconsole.js
@@ -250,16 +250,17 @@ NewWebConsoleFrame.prototype = {
         Services.scriptloader.loadSubScript(
           "chrome://browser/content/browser-development-helpers.js", this.window);
         shortcuts.on("CmdOrCtrl+Alt+R", this.window.DevelopmentHelpers.quickRestart);
       }
     } else if (Services.prefs.getBoolPref(PREF_SIDEBAR_ENABLED)) {
       shortcuts.on("Esc", event => {
         if (!this.jsterm.autocompletePopup || !this.jsterm.autocompletePopup.isOpen) {
           this.newConsoleOutput.dispatchSidebarClose();
+          this.jsterm.focus();
         }
       });
     }
   },
   /**
    * Handler for page location changes.
    *
    * @param string uri
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_close_sidebar.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_close_sidebar.js
@@ -64,16 +64,18 @@ add_task(async function() {
   await showSidebar(hud);
 
   info("Send escape to hide sidebar");
   onSidebarShown = waitForNodeMutation(wrapper, { childList: true });
   EventUtils.synthesizeKey("KEY_Escape");
   await onSidebarShown;
   sidebar = hud.ui.document.querySelector(".sidebar");
   ok(!sidebar, "Sidebar hidden after sending esc");
+  let inputNode = hud.jsterm.inputNode;
+  ok(hasFocus(inputNode), "console input is focused after closing the sidebar");
 });
 
 async function showSidebar(hud) {
   let onMessage = waitForMessage(hud, "Object");
   ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     content.wrappedJSObject.console.log({a: 1});
   });
   await onMessage;