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
--- 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) {