Bug 1425972 - Add a test for subview navigation on space keydown. r?Gijs draft
authorIan Moody <moz-ian@perix.co.uk>
Wed, 20 Dec 2017 16:48:19 +0000
changeset 713590 0a27c06cf656f51e3017a73078f16224cc723e62
parent 713589 22ec81fa25992187460a2bd0a3eea393a5b74f6a
child 744370 7625464b6a1809818e1f9f8b826be206b18cf3a1
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 subview navigation on space keydown. r?Gijs MozReview-Commit-ID: Hb5WlqOtibS
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
@@ -200,8 +200,39 @@ add_task(async function testInterleavedT
 
   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;
 });
+
+add_task(async function testSpaceDownAfterTabNavigation() {
+  let promise = promisePanelShown(window);
+  PanelUI.show();
+  await promise;
+
+  let buttons = gHelperInstance._getNavigableElements(PanelUI.mainView);
+  let button;
+
+  for (button of buttons) {
+    if (button.disabled)
+      continue;
+    EventUtils.synthesizeKey("KEY_Tab", { code: "Tab" });
+    if (button.id == kHelpButtonId) {
+      break;
+    }
+  }
+
+  Assert.equal(document.commandDispatcher.focusedElement, button,
+               "Help button should be focused after tabbing to it.");
+
+  // Pressing down space on a button that points to a subview should navigate us
+  // there, before keyup.
+  promise = BrowserTestUtils.waitForEvent(PanelUI.helpView, "ViewShown");
+  EventUtils.synthesizeKey(" ", { code: "Space", type: "keydown" });
+  await promise;
+
+  promise = promisePanelHidden(window);
+  PanelUI.hide();
+  await promise;
+});