Bug 1544447 - add support for numpad enter key and add tests to check activation works, r=Jamie
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 23 Apr 2019 11:44:36 +0000
changeset 470472 515cfc853f2a8372dcc9139f8b90a4e7fd038744
parent 470471 06b93c66c6e0b3d948e1b225757596a3270d0e51
child 470473 913c397010c2c9ba8ba0f28a1eae5e30e410dbe9
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1544447
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1544447 - add support for numpad enter key and add tests to check activation works, r=Jamie Differential Revision: https://phabricator.services.mozilla.com/D28431
browser/components/customizableui/PanelMultiView.jsm
browser/components/customizableui/test/browser_PanelMultiView_keyboard.js
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -1639,16 +1639,17 @@ var PanelView = class extends Associated
         // the arrow key shouldn't do anything.
         let button = this.selectedElement;
         if (!button || !button.classList.contains("subviewbutton-nav")) {
           break;
         }
         // Fall-through...
       }
       case "Space":
+      case "NumpadEnter":
       case "Enter": {
         if (tabOnly()) {
           break;
         }
         let button = this.selectedElement;
         if (!button)
           break;
         stop();
--- a/browser/components/customizableui/test/browser_PanelMultiView_keyboard.js
+++ b/browser/components/customizableui/test/browser_PanelMultiView_keyboard.js
@@ -249,8 +249,24 @@ add_task(async function testDynamicButto
   gMainButton2.disabled = true;
   await openPopup();
   await expectFocusAfterKey("ArrowDown", gMainButton1);
   await expectFocusAfterKey("ArrowDown", gMainButton3);
   gMainButton2.disabled = false;
   await expectFocusAfterKey("ArrowUp", gMainButton2);
   await hidePopup();
 });
+
+add_task(async function testActivation() {
+  function checkActivated(elem, activationFn, reason) {
+    let activated = false;
+    elem.onclick = function() { activated = true; };
+    activationFn();
+    ok(activated, "Should have activated button after " + reason);
+    elem.onclick = null;
+  }
+  await openPopup();
+  await expectFocusAfterKey("ArrowDown", gMainButton1);
+  checkActivated(gMainButton1, () => EventUtils.synthesizeKey("KEY_Enter"), "pressing enter");
+  checkActivated(gMainButton1, () => EventUtils.synthesizeKey(" "), "pressing space");
+  checkActivated(gMainButton1, () => EventUtils.synthesizeKey("KEY_Enter", {code: "NumpadEnter"}), "pressing numpad enter");
+  await hidePopup();
+});