Bug 1184220 - typing in the searchbar should de-select the settings or opensearch buttons at the bottom of the search panel, r=Gijs.

This commit is contained in:
Florian Quèze 2015-09-11 14:18:15 +02:00
parent ca912b8eea
commit d933cfc8ee
2 changed files with 21 additions and 0 deletions

View File

@ -1143,6 +1143,10 @@
let isOneOffSelected =
this.selectedButton &&
this.selectedButton.classList.contains("searchbar-engine-one-off-item");
// Typing de-selects the settings or opensearch buttons at the bottom
// of the search panel, as typing shows the user intends to search.
if (this.selectedButton && !isOneOffSelected)
this.selectedButton = null;
if (textbox.value) {
self.removeAttribute("showonlysettings");
groupText = headerSearchText.previousSibling.value +

View File

@ -152,6 +152,23 @@ add_task(function* test_arrows() {
"the textfield value should be back to initial value");
});
add_task(function* test_typing_clears_button_selection() {
is(Services.focus.focusedElement, textbox.inputField,
"the search bar should be focused"); // from the previous test.
ok(!textbox.selectedButton, "no button should be selected");
EventUtils.synthesizeKey("VK_UP", {});
is(textbox.selectedButton.getAttribute("anonid"), "search-settings",
"the settings item should be selected");
// Type a character.
EventUtils.synthesizeKey("a", {});
ok(!textbox.selectedButton, "the settings item should be de-selected");
// Remove the character.
EventUtils.synthesizeKey("VK_BACK_SPACE", {});
});
add_task(function* test_tab() {
is(Services.focus.focusedElement, textbox.inputField,
"the search bar should be focused"); // from the previous test.