[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 55/76: Bug 1757376: Continue post processing of Enter key when any keyup event is detected on search bar. r=adw a=RyanVM



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 76782b5eb62f54774e4315ee3f40982abe763378
Author: Daisuke Akatsuka <daisuke@xxxxxxxxxxxxxx>
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=RyanVM
    
    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 cd8c16c042ccd..c4af503ca5d7d 100644
--- a/browser/components/search/content/searchbar.js
+++ b/browser/components/search/content/searchbar.js
@@ -807,10 +807,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.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits