зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1425972 - Add a test for tab navigation in the browser panel. r=Gijs
MozReview-Commit-ID: L3C65YgRYd5 --HG-- extra : rebase_source : 9de26250aa9f18cf69818898e04b6b49b136b899
This commit is contained in:
Родитель
acb5488eff
Коммит
92dc6aecdf
|
@ -142,3 +142,39 @@ add_task(async function testLeftRightKeys() {
|
|||
await promise;
|
||||
});
|
||||
|
||||
add_task(async function testTabKey() {
|
||||
let promise = promisePanelShown(window);
|
||||
PanelUI.show();
|
||||
await promise;
|
||||
|
||||
let buttons = gHelperInstance._getNavigableElements(PanelUI.mainView);
|
||||
|
||||
for (let button of buttons) {
|
||||
if (button.disabled)
|
||||
continue;
|
||||
EventUtils.synthesizeKey("KEY_Tab", { code: "Tab" });
|
||||
Assert.equal(document.commandDispatcher.focusedElement, button,
|
||||
"The correct button should be focused after tabbing");
|
||||
}
|
||||
|
||||
EventUtils.synthesizeKey("KEY_Tab", { code: "Tab" });
|
||||
Assert.equal(document.commandDispatcher.focusedElement, buttons[0],
|
||||
"Pressing tab should cycle around and select the first button again");
|
||||
|
||||
for (let i = buttons.length - 1; i >= 0; --i) {
|
||||
let button = buttons[i];
|
||||
if (button.disabled)
|
||||
continue;
|
||||
EventUtils.synthesizeKey("Tab", { code: "Tab", shiftKey: true });
|
||||
Assert.equal(document.commandDispatcher.focusedElement, button,
|
||||
"The correct button should be focused after shift + tabbing");
|
||||
}
|
||||
|
||||
EventUtils.synthesizeKey("KEY_Tab", { code: "Tab", shiftKey: true });
|
||||
Assert.equal(document.commandDispatcher.focusedElement, buttons[buttons.length - 1],
|
||||
"Pressing shift + tab should cycle around and select the last button again");
|
||||
|
||||
promise = promisePanelHidden(window);
|
||||
PanelUI.hide();
|
||||
await promise;
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче