From a7990cf932141babc2b9b108a53feac736e462b9 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Wed, 25 Jul 2018 18:26:27 +0200 Subject: [PATCH] Bug 1478410 - Fix split console close in codeMirror jsterm; r=bgrins. This patch removes the Esc handler from codeMirror to put it on the jsterm-container. This prevent the interference from codeMirror when we don't need to handle the event (i.e. it should bubbles up to the toolbox where the split console state is managed). The webconsole_split test is run with both old and new jsterm. MozReview-Commit-ID: BaLyj4wSdmv --HG-- extra : rebase_source : 6b549379839dc824a38ee49ffd859092cfbecb13 extra : source : de58a50eb0165665644b07fffd228e5478861e2e --- .../client/webconsole/components/JSTerm.js | 21 ++++++++++--------- .../mochitest/browser_webconsole_split.js | 15 ++++++++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/devtools/client/webconsole/components/JSTerm.js b/devtools/client/webconsole/components/JSTerm.js index 5023e442f50c..3471429b29c9 100644 --- a/devtools/client/webconsole/components/JSTerm.js +++ b/devtools/client/webconsole/components/JSTerm.js @@ -309,15 +309,6 @@ class JSTerm extends Component { return "CodeMirror.Pass"; }, - "Esc": () => { - if (this.autocompletePopup.isOpen) { - this.clearCompletion(); - return null; - } - - return "CodeMirror.Pass"; - }, - "PageUp": () => { if (this.autocompletePopup.isOpen) { this.complete(this.COMPLETE_PAGEUP); @@ -353,7 +344,9 @@ class JSTerm extends Component { } return "CodeMirror.Pass"; - } + }, + + "Esc": false, } }); @@ -362,6 +355,14 @@ class JSTerm extends Component { const cm = this.editor.codeMirror; cm.on("paste", (_, event) => this.props.onPaste(event)); cm.on("drop", (_, event) => this.props.onPaste(event)); + + this.node.addEventListener("keydown", event => { + if (event.keyCode === KeyCodes.DOM_VK_ESCAPE && this.autocompletePopup.isOpen) { + this.clearCompletion(); + event.preventDefault(); + event.stopPropagation(); + } + }); } } else if (this.inputNode) { this.inputNode.addEventListener("keypress", this._keyPress); diff --git a/devtools/client/webconsole/test/mochitest/browser_webconsole_split.js b/devtools/client/webconsole/test/mochitest/browser_webconsole_split.js index 4a593e70c2a2..8bfe6a6e338e 100644 --- a/devtools/client/webconsole/test/mochitest/browser_webconsole_split.js +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_split.js @@ -12,11 +12,20 @@ const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties"); // Test is slow on Linux EC2 instances - Bug 962931 -requestLongerTimeout(2); +requestLongerTimeout(4); add_task(async function() { - let toolbox; + // Run test with legacy JsTerm + await pushPref("devtools.webconsole.jsterm.codeMirror", false); + await performTests(); + // And then run it with the CodeMirror-powered one. + await pushPref("devtools.webconsole.jsterm.codeMirror", true); + await performTests(); +}); +async function performTests() { + let toolbox; + await pushPref("devtools.webconsole.jsterm.codeMirror", true); await addTab(TEST_URI); await testConsoleLoadOnDifferentPanel(); await testKeyboardShortcuts(); @@ -249,4 +258,4 @@ add_task(async function() { const pref = Services.prefs.getCharPref("devtools.toolbox.host"); is(pref, hostType, "host pref is " + hostType); } -}); +}