[tbb-commits] [tor-browser] 162/311: Bug 1757376: Continue post processing of Enter key when any keyup event is detected on search bar. r=adw a=dmeehan
gitolite role
git at cupani.torproject.org
Tue Apr 26 15:29:22 UTC 2022
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 8d0efd28891e158bef4f6cee697be46d0114df8e
Author: Daisuke Akatsuka <daisuke at 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=dmeehan
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);
+});
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tbb-commits
mailing list