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:
Ian Moody 2017-12-20 00:18:19 +00:00
Родитель acb5488eff
Коммит 92dc6aecdf
1 изменённых файлов: 36 добавлений и 0 удалений

Просмотреть файл

@ -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;
});