This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch geckoview-99.0.1-11.0-1 in repository tor-browser.
commit 0856b6f3cb53f8ccff82d15b2d665fe7f2a8a077 Author: Daisuke Akatsuka daisuke@birchill.co.jp AuthorDate: Tue Mar 15 02:16:41 2022 +0000
Bug 1757376: Continue post processing of Enter key when any keyup event is detected on search bar. r=adw a=pascalc
Depends on D140908
Differential Revision: https://phabricator.services.mozilla.com/D141058 --- browser/components/search/content/searchbar.js | 9 +++--- .../search/test/browser/browser_searchbar_enter.js | 35 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/browser/components/search/content/searchbar.js b/browser/components/search/content/searchbar.js index a9e596eacac90..46af46f05d85b 100644 --- a/browser/components/search/content/searchbar.js +++ b/browser/components/search/content/searchbar.js @@ -815,10 +815,11 @@ };
this.textbox.onkeyup = event => { - if ( - event.keyCode === KeyEvent.DOM_VK_RETURN && - this._needBrowserFocusAtEnterKeyUp - ) { + // 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._needBrowserFocusAtEnterKeyUp) { this._needBrowserFocusAtEnterKeyUp = false; gBrowser.selectedBrowser.focus(); } diff --git a/browser/components/search/test/browser/browser_searchbar_enter.js b/browser/components/search/test/browser/browser_searchbar_enter.js index ab5e2dc892d74..04e94ceafce82 100644 --- a/browser/components/search/test/browser/browser_searchbar_enter.js +++ b/browser/components/search/test/browser/browser_searchbar_enter.js @@ -119,3 +119,38 @@ add_task(async function typeCharWhileProcessingEnter() { // Cleanup. await BrowserTestUtils.closeWindow(win); }); + +add_task(async function keyupEnterWhilePressingMeta() { + const win = await BrowserTestUtils.openNewBrowserWindow(); + const browser = win.gBrowser.selectedBrowser; + const searchBar = win.BrowserSearch.searchBar; + + info("Keydown Meta+Enter"); + searchBar.textbox.focus(); + searchBar.textbox.value = ""; + EventUtils.synthesizeKey( + "KEY_Enter", + { type: "keydown", metaKey: true }, + win + ); + + // 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" }, win); + + await TestUtils.waitForCondition( + () => browser.ownerDocument.activeElement === browser, + "Wait for focus to be moved to the browser" + ); + info("The focus is moved to the browser"); + + info("Check whether we can input on the search bar"); + searchBar.textbox.focus(); + EventUtils.synthesizeKey("a", {}, win); + is(searchBar.textbox.value, "a", "Can input a char"); + + // Cleanup. + await BrowserTestUtils.closeWindow(win); +});