Bug 1470922 - Use keyup event in toolbox to toggle the split console; r=bgrins. draft
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Wed, 25 Jul 2018 14:43:58 +0200
changeset 822504 1454ad76a6c0d74872f6cec7fc4171e3211f6261
parent 822503 ccbde6f6bfa99c9572b4d3cfbf84b57ab14606e9
child 822505 e8bf5cc705f35f14b9ca1c60d55ce2250a0d069b
push id117397
push userbmo:nchevobbe@mozilla.com
push dateWed, 25 Jul 2018 13:01:34 +0000
reviewersbgrins
bugs1470922
milestone63.0a1
Bug 1470922 - Use keyup event in toolbox to toggle the split console; r=bgrins. The fact that we now handle the Esc key in JsTerm via CodeMirror was preventing the event to bubble up to the toolbox (even when returning CodeMirror.Pass). This may be related to the fact that hitting Escape should not result in a keypress event (only keys that produce a character value should) in HTML document. Using keyup makes the issue go away and is more consistent with the web way. MozReview-Commit-ID: 3DIBQu4wVLM
devtools/client/framework/toolbox.js
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -138,17 +138,17 @@ function Toolbox(target, selectedTool, h
   this._toolUnregistered = this._toolUnregistered.bind(this);
   this._onWillNavigate = this._onWillNavigate.bind(this);
   this._refreshHostTitle = this._refreshHostTitle.bind(this);
   this.toggleNoAutohide = this.toggleNoAutohide.bind(this);
   this.showFramesMenu = this.showFramesMenu.bind(this);
   this.handleKeyDownOnFramesButton = this.handleKeyDownOnFramesButton.bind(this);
   this.showFramesMenuOnKeyDown = this.showFramesMenuOnKeyDown.bind(this);
   this._updateFrames = this._updateFrames.bind(this);
-  this._splitConsoleOnKeypress = this._splitConsoleOnKeypress.bind(this);
+  this._splitConsoleOnKeyup = this._splitConsoleOnKeyup.bind(this);
   this.destroy = this.destroy.bind(this);
   this.highlighterUtils = getHighlighterUtils(this);
   this._highlighterReady = this._highlighterReady.bind(this);
   this._highlighterHidden = this._highlighterHidden.bind(this);
   this._applyCacheSettings = this._applyCacheSettings.bind(this);
   this._applyServiceWorkersTestingSettings =
     this._applyServiceWorkersTestingSettings.bind(this);
   this._saveSplitConsoleHeight = this._saveSplitConsoleHeight.bind(this);
@@ -851,17 +851,17 @@ Toolbox.prototype = {
 
     return button;
   },
 
   _buildOptions: function() {
     this.shortcuts.on(L10N.getStr("toolbox.help.key"), this.toggleOptions);
   },
 
-  _splitConsoleOnKeypress: function(e) {
+  _splitConsoleOnKeyup: function(e) {
     if (e.keyCode === KeyCodes.DOM_VK_ESCAPE) {
       this.toggleSplitConsole();
       // If the debugger is paused, don't let the ESC key stop any pending
       // navigation.
       if (this._threadClient.state == "paused") {
         e.preventDefault();
       }
     }
@@ -917,26 +917,26 @@ Toolbox.prototype = {
                    event.preventDefault();
                  });
     this.shortcuts.on(L10N.getStr("toolbox.toggleHost.key"),
                  event => {
                    this.switchToPreviousHost();
                    event.preventDefault();
                  });
 
-    this.doc.addEventListener("keypress", this._splitConsoleOnKeypress);
+    this.doc.addEventListener("keyup", this._splitConsoleOnKeyup);
     this.doc.addEventListener("focus", this._onFocus, true);
     this.win.addEventListener("unload", this.destroy);
     this.win.addEventListener("message", this._onBrowserMessage, true);
   },
 
   _removeHostListeners: function() {
     // The host iframe's contentDocument may already be gone.
     if (this.doc) {
-      this.doc.removeEventListener("keypress", this._splitConsoleOnKeypress);
+      this.doc.removeEventListener("keyup", this._splitConsoleOnKeyup);
       this.doc.removeEventListener("focus", this._onFocus, true);
       this.win.removeEventListener("unload", this.destroy);
       this.win.removeEventListener("message", this._onBrowserMessage, true);
     }
   },
 
   // Called whenever the chrome send a message
   _onBrowserMessage: function(event) {