This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.8.0esr-11.0-1 in repository tor-browser.
commit 2700678659a06f79730018b9400960bf6f8be969 Author: Daisuke Akatsuka daisuke@birchill.co.jp AuthorDate: Tue Mar 15 02:16:40 2022 +0000
Bug 1757376: Continue post processing of Enter key when any keyup event is detected on URL bar. r=adw a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D140908 --- browser/components/urlbar/UrlbarInput.jsm | 26 ++++++++++++---------- .../urlbar/tests/browser/browser_enter.js | 22 ++++++++++++++++++ 2 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/browser/components/urlbar/UrlbarInput.jsm b/browser/components/urlbar/UrlbarInput.jsm index d6192040dbf4e..b2f76bdee2f4a 100644 --- a/browser/components/urlbar/UrlbarInput.jsm +++ b/browser/components/urlbar/UrlbarInput.jsm @@ -3176,10 +3176,17 @@ class UrlbarInput { }
async _on_keyup(event) { - if ( - event.keyCode === KeyEvent.DOM_VK_RETURN && - this._keyDownEnterDeferred - ) { + if (event.keyCode === KeyEvent.DOM_VK_CONTROL) { + this._isKeyDownWithCtrl = false; + } + + this._toggleActionOverride(event); + + // Pressing Enter key while pressing Meta key, and next, even when releasing + // Enter key before releasing Meta key, the keyup event is not fired. + // Therefore, if Enter keydown is detecting, continue the post processing + // for Enter key when any keyup event is detected. + if (this._keyDownEnterDeferred) { if (this._keyDownEnterDeferred.loadedContent) { try { const loadingBrowser = await this._keyDownEnterDeferred.promise; @@ -3189,24 +3196,19 @@ class UrlbarInput { // Make sure the domain name stays visible for spoof protection and usability. this.selectionStart = this.selectionEnd = 0; } - this._keyDownEnterDeferred = null; } catch (ex) { // Not all the Enter actions in the urlbar will cause a navigation, then it // is normal for this to be rejected. // If _keyDownEnterDeferred was rejected on keydown, we don't nullify it here // to ensure not overwriting the new value created by keydown. } - return; + } else { + // Discard the _keyDownEnterDeferred promise to receive any key inputs immediately. + this._keyDownEnterDeferred.resolve(); }
- // Discard the _keyDownEnterDeferred promise to receive any key inputs immediately. - this._keyDownEnterDeferred.resolve(); this._keyDownEnterDeferred = null; - } else if (event.keyCode === KeyEvent.DOM_VK_CONTROL) { - this._isKeyDownWithCtrl = false; } - - this._toggleActionOverride(event); }
_on_compositionstart(event) { diff --git a/browser/components/urlbar/tests/browser/browser_enter.js b/browser/components/urlbar/tests/browser/browser_enter.js index 41f3b81712d87..439496bd9bde9 100644 --- a/browser/components/urlbar/tests/browser/browser_enter.js +++ b/browser/components/urlbar/tests/browser/browser_enter.js @@ -303,3 +303,25 @@ add_task(async function typeCharWhileProcessingEnter() { // Cleanup. BrowserTestUtils.removeTab(tab); }); + +add_task(async function keyupEnterWhilePressingMeta() { + const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); + + info("Keydown Meta+Enter"); + gURLBar.focus(); + gURLBar.value = ""; + EventUtils.synthesizeKey("KEY_Enter", { type: "keydown", metaKey: true }); + + // Pressing Enter key while pressing Meta key, and next, even when releasing + // Enter key before releasing Meta key, the keyup event is not fired. + // Therefor, we fire Meta keyup event only. + info("Keyup Meta"); + EventUtils.synthesizeKey("KEY_Meta", { type: "keyup" }); + + // Check whether we can input on URL bar. + EventUtils.synthesizeKey("a"); + is(gURLBar.value, "a", "Can input a char"); + + // Cleanup. + BrowserTestUtils.removeTab(tab); +});