mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1580822 - a11y focus lost when selecting the first one-off search button or the search settings button. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D45692 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a7c5dffa9c
commit
a355f15d53
@ -24,6 +24,10 @@ function isEventForAutocompleteItem(event) {
|
||||
return event.accessible.role == ROLE_COMBOBOX_OPTION;
|
||||
}
|
||||
|
||||
function isEventForOneOffButton(event) {
|
||||
return event.accessible.role == ROLE_PUSHBUTTON;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for an autocomplete search to finish.
|
||||
* This is necessary to ensure predictable results, as these searches are
|
||||
@ -134,6 +138,12 @@ async function runTests() {
|
||||
event = await focused;
|
||||
testStates(event.accessible, STATE_FOCUSED);
|
||||
|
||||
info("Ensuring autocomplete focus on arrow up for search settings button");
|
||||
focused = waitForEvent(EVENT_FOCUS, isEventForOneOffButton);
|
||||
EventUtils.synthesizeKey("KEY_ArrowUp");
|
||||
event = await focused;
|
||||
testStates(event.accessible, STATE_FOCUSED);
|
||||
|
||||
info("Ensuring text box focus when text is typed");
|
||||
focused = waitForEvent(EVENT_FOCUS, textBox);
|
||||
EventUtils.sendString("z");
|
||||
@ -154,12 +164,20 @@ async function runTests() {
|
||||
await focused;
|
||||
testStates(textBox, STATE_FOCUSED);
|
||||
|
||||
info("Ensuring autocomplete focus on arrow down & up");
|
||||
info("Ensuring autocomplete focus on arrow down (4)");
|
||||
focused = waitForEvent(EVENT_FOCUS, isEventForAutocompleteItem);
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
// With the quantumbar enabled, we only get one result here, and arrow down
|
||||
// selects a one-off search button. We arrow back up to re-select the
|
||||
// autocomplete result.
|
||||
event = await focused;
|
||||
testStates(event.accessible, STATE_FOCUSED);
|
||||
|
||||
info("Ensuring one-off search button focus on arrow down");
|
||||
focused = waitForEvent(EVENT_FOCUS, isEventForOneOffButton);
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
event = await focused;
|
||||
testStates(event.accessible, STATE_FOCUSED);
|
||||
|
||||
info("Ensuring autocomplete focus on arrow up");
|
||||
focused = waitForEvent(EVENT_FOCUS, isEventForAutocompleteItem);
|
||||
EventUtils.synthesizeKey("KEY_ArrowUp");
|
||||
event = await focused;
|
||||
testStates(event.accessible, STATE_FOCUSED);
|
||||
|
@ -299,6 +299,12 @@ class SearchOneOffs {
|
||||
}
|
||||
if (val) {
|
||||
val.setAttribute("selected", "true");
|
||||
if (!val.engine) {
|
||||
// If the button doesn't have an engine, then clear the popup's
|
||||
// selection to indicate that pressing Return while the button is
|
||||
// selected will do the button's command, not search.
|
||||
this.selectedAutocompleteIndex = -1;
|
||||
}
|
||||
}
|
||||
this._selectedButton = val;
|
||||
|
||||
@ -313,12 +319,6 @@ class SearchOneOffs {
|
||||
}
|
||||
}
|
||||
|
||||
if (val && !val.engine) {
|
||||
// If the button doesn't have an engine, then clear the popup's
|
||||
// selection to indicate that pressing Return while the button is
|
||||
// selected will do the button's command, not search.
|
||||
this.selectedAutocompleteIndex = -1;
|
||||
}
|
||||
let event = new CustomEvent("SelectedOneOffButtonChanged", {
|
||||
previousSelectedButton: previousButton,
|
||||
});
|
||||
@ -924,16 +924,18 @@ class SearchOneOffs {
|
||||
}
|
||||
if (this.selectedAutocompleteIndex == numListItems - 1) {
|
||||
// Moving down from the last item in the list to the buttons.
|
||||
if (!allowEmptySelection) {
|
||||
this.selectedAutocompleteIndex = -1;
|
||||
if (this.textbox && typeof textboxUserValue == "string") {
|
||||
this.textbox.value = textboxUserValue;
|
||||
}
|
||||
}
|
||||
this.selectedButtonIndex = 0;
|
||||
if (allowEmptySelection) {
|
||||
// Let the autocomplete controller remove selection in the list
|
||||
// and revert the typed text in the textbox.
|
||||
return false;
|
||||
}
|
||||
if (this.textbox && typeof textboxUserValue == "string") {
|
||||
this.textbox.value = textboxUserValue;
|
||||
}
|
||||
this.selectedAutocompleteIndex = -1;
|
||||
return true;
|
||||
}
|
||||
if (this.selectedButton) {
|
||||
|
Loading…
Reference in New Issue
Block a user