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
This commit is contained in:
Anna Yeddi 2024-01-23 17:50:40 +00:00
parent 496eb6907f
commit c449b4d460

View File

@ -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() {