From c449b4d4601df27bfe15ef269fbf128a7097d636 Mon Sep 17 00:00:00 2001 From: Anna Yeddi Date: Tue, 23 Jan 2024 17:50:40 +0000 Subject: [PATCH] Bug 1874277 - Adding mochitest to ensure the search bar input field value is autoselected when it is focused. r=Standard8 Ensuring the test coverage is provided to avoid reappearance of the issue when re-focusing the Search bar with keyboard would not auto select the value of the input. The bug is being resolved by bug 1875654. Differential Revision: https://phabricator.services.mozilla.com/D199311 --- .../browser_searchbar_keyboard_navigation.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/browser/components/search/test/browser/browser_searchbar_keyboard_navigation.js b/browser/components/search/test/browser/browser_searchbar_keyboard_navigation.js index 4dbadf0d5477..c4a928f9840e 100644 --- a/browser/components/search/test/browser/browser_searchbar_keyboard_navigation.js +++ b/browser/components/search/test/browser/browser_searchbar_keyboard_navigation.js @@ -301,6 +301,23 @@ add_task(async function test_shift_tab() { !Services.focus.focusedElement.classList.contains("searchbar-textbox"), "the search input in the search bar should no longer be focused" ); + + // Return the focus to the search bar + EventUtils.synthesizeKey("KEY_Tab"); + ok( + Services.focus.focusedElement.classList.contains("searchbar-textbox"), + "the search bar should be focused" + ); + + // ... and confirm the input value was autoselected and is replaced. + EventUtils.synthesizeKey("fo"); + is( + Services.focus.focusedElement.value, + "fo", + "when the search bar was focused, the value should be autoselected" + ); + // Return to the expected value + EventUtils.synthesizeKey("o"); }); add_task(async function test_alt_down() {