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 413883 212963ca6f2ba0108f411573deef62dc06746823
parent 413882 ced1f03536a4c5bf940a18139d25bd4f828251bb
child 413884 32bab10d9158958341dea029fd5f7f36b753619e
push id33853
push usercbrindusan@mozilla.com
push dateTue, 17 Apr 2018 09:51:13 +0000
treeherdermozilla-central@8b0ba3f7d099 [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;