Bug 1425972 - Add a test for interleaved arrow and tab navigation in the browser panel. r?Gijs draft
authorIan Moody <moz-ian@perix.co.uk>
Wed, 20 Dec 2017 02:19:35 +0000
changeset 713589 22ec81fa25992187460a2bd0a3eea393a5b74f6a
parent 713588 8b2daeac3fa18c1434adb06523415f2553a0ac42
child 713590 0a27c06cf656f51e3017a73078f16224cc723e62
push id93683
push usermoz-ian@perix.co.uk
push dateWed, 20 Dec 2017 17:13:57 +0000
reviewersGijs
bugs1425972
milestone59.0a1
Bug 1425972 - Add a test for interleaved arrow and tab navigation in the browser panel. r?Gijs MozReview-Commit-ID: DBIop59CWCG
browser/components/customizableui/test/browser_panel_keyboard_navigation.js
--- 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;
+});