Bug 1425972 - Add a test for interleaved arrow and tab navigation in the browser panel. r?Gijs
MozReview-Commit-ID: DBIop59CWCG
--- a/browser/components/customizableui/test/browser_panel_keyboard_navigation.js
+++ b/browser/components/customizableui/test/browser_panel_keyboard_navigation.js
@@ -173,8 +173,35 @@ add_task(async function testTabKey() {
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;
});
+
+add_task(async function testInterleavedTabAndArrowKeys() {
+ let promise = promisePanelShown(window);
+ PanelUI.show();
+ await promise;
+
+ let buttons = gHelperInstance._getNavigableElements(PanelUI.mainView);
+ let tab = false;
+
+ for (let button of buttons) {
+ if (button.disabled)
+ continue;
+ if (tab) {
+ EventUtils.synthesizeKey("KEY_Tab", { code: "Tab" });
+ } else {
+ EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" });
+ }
+ tab = !tab;
+ }
+
+ Assert.equal(document.commandDispatcher.focusedElement, buttons[buttons.length - 1],
+ "The last button should be focused after a mix of Tab and ArrowDown");
+
+ promise = promisePanelHidden(window);
+ PanelUI.hide();
+ await promise;
+});