Bug 1467381 - check Accessible::AccessKey and Accessible::KeyboardShortcut when filling up keyboardShortcut for accessible actor. r=pbro
authorYura Zenevich <yura.zenevich@gmail.com>
Thu, 14 Jun 2018 13:58:34 -0400
changeset 422975 45a968a577b741e70c5122e3ee118352a754425f
parent 422974 8dde5c1d895e4c063d5bda39029c9a01a178ebba
child 422976 e8d4a24e47a943db327206a4680fb75c156f9086
push id34160
push userdluca@mozilla.com
push dateTue, 19 Jun 2018 21:55:15 +0000
treeherdermozilla-central@e429320fcdd2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1467381
milestone62.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 1467381 - check Accessible::AccessKey and Accessible::KeyboardShortcut when filling up keyboardShortcut for accessible actor. r=pbro MozReview-Commit-ID: IkqfyL5cGGh
devtools/server/actors/accessibility.js
devtools/server/tests/browser/browser_accessibility_node.js
devtools/server/tests/browser/browser_accessibility_node_events.js
devtools/server/tests/browser/doc_accessibility.html
--- a/devtools/server/actors/accessibility.js
+++ b/devtools/server/actors/accessibility.js
@@ -240,17 +240,22 @@ const AccessibleActor = ActorClassWithSp
     }
     return this.rawAccessible.help;
   },
 
   get keyboardShortcut() {
     if (this.isDefunct) {
       return null;
     }
-    return this.rawAccessible.keyboardShortcut;
+    // Gecko accessibility exposes two key bindings: Accessible::AccessKey and
+    // Accessible::KeyboardShortcut. The former is used for accesskey, where the latter
+    // is used for global shortcuts defined by XUL menu items, etc. Here - do what the
+    // Windows implementation does: try AccessKey first, and if that's empty, use
+    // KeyboardShortcut.
+    return this.rawAccessible.accessKey || this.rawAccessible.keyboardShortcut;
   },
 
   get childCount() {
     if (this.isDefunct) {
       return 0;
     }
     return this.rawAccessible.childCount;
   },
@@ -679,19 +684,20 @@ const AccessibleWalkerActor = ActorClass
         break;
       case EVENT_DOCUMENT_ATTRIBUTES_CHANGED:
       case EVENT_OBJECT_ATTRIBUTE_CHANGED:
       case EVENT_TEXT_ATTRIBUTE_CHANGED:
         if (accessible) {
           events.emit(accessible, "attributes-change", accessible.attributes);
         }
         break;
+      // EVENT_ACCELERATOR_CHANGE is currently not fired by gecko accessibility.
       case EVENT_ACCELERATOR_CHANGE:
         if (accessible) {
-          events.emit(accessible, "shortcut-change", rawAccessible.keyboardShortcut);
+          events.emit(accessible, "shortcut-change", accessible.keyboardShortcut);
         }
         break;
       default:
         break;
     }
   },
 
   /**
--- a/devtools/server/tests/browser/browser_accessibility_node.js
+++ b/devtools/server/tests/browser/browser_accessibility_node.js
@@ -4,29 +4,30 @@
 
 "use strict";
 
 // Checks for the AccessibleActor
 
 add_task(async function() {
   const {client, walker, accessibility} =
     await initAccessibilityFrontForUrl(MAIN_DOMAIN + "doc_accessibility.html");
+  const modifiers = Services.appinfo.OS === "Darwin" ? "\u2303\u2325" : "Alt+Shift+";
 
   const a11yWalker = await accessibility.getWalker();
   await accessibility.enable();
   const buttonNode = await walker.querySelector(walker.rootNode, "#button");
   const accessibleFront = await a11yWalker.getAccessibleFor(buttonNode);
 
   checkA11yFront(accessibleFront, {
     name: "Accessible Button",
     role: "pushbutton",
     value: "",
     description: "Accessibility Test",
     help: "",
-    keyboardShortcut: "",
+    keyboardShortcut: modifiers + "b",
     childCount: 1,
     domNodeType: 1,
     indexInParent: 1,
     states: ["focusable", "selectable text", "opaque", "enabled", "sensitive"],
     actions: [ "Press" ],
     attributes: {
       "margin-top": "0px",
       display: "inline-block",
--- a/devtools/server/tests/browser/browser_accessibility_node_events.js
+++ b/devtools/server/tests/browser/browser_accessibility_node_events.js
@@ -4,16 +4,17 @@
 
 "use strict";
 
 // Checks for the AccessibleActor events
 
 add_task(async function() {
   const {client, walker, accessibility} =
     await initAccessibilityFrontForUrl(MAIN_DOMAIN + "doc_accessibility.html");
+  const modifiers = Services.appinfo.OS === "Darwin" ? "\u2303\u2325" : "Alt+Shift+";
 
   const a11yWalker = await accessibility.getWalker();
   await accessibility.enable();
   const rootNode = await walker.getRootNode();
   const a11yDoc = await a11yWalker.getAccessibleFor(rootNode);
   const buttonNode = await walker.querySelector(walker.rootNode, "#button");
   const accessibleFront = await a11yWalker.getAccessibleFor(buttonNode);
   const sliderNode = await walker.querySelector(walker.rootNode, "#slider");
@@ -21,17 +22,17 @@ add_task(async function() {
   const browser = gBrowser.selectedBrowser;
 
   checkA11yFront(accessibleFront, {
     name: "Accessible Button",
     role: "pushbutton",
     value: "",
     description: "Accessibility Test",
     help: "",
-    keyboardShortcut: "",
+    keyboardShortcut: modifiers + "b",
     childCount: 1,
     domNodeType: 1,
     indexInParent: 1,
     states: ["focusable", "selectable text", "opaque", "enabled", "sensitive"],
     actions: [ "Press" ],
     attributes: {
       "margin-top": "0px",
       display: "inline-block",
--- a/devtools/server/tests/browser/doc_accessibility.html
+++ b/devtools/server/tests/browser/doc_accessibility.html
@@ -1,12 +1,12 @@
 <!DOCTYPE HTML>
 <html>
   <head>
     <meta charset="utf-8">
   </head>
 <body>
   <h1 id="h1">Accessibility Test</h1>
-  <button id="button" aria-describedby="h1">Accessible Button</button>
+  <button id="button" aria-describedby="h1" accesskey="b">Accessible Button</button>
   <div id="slider" role="slider" aria-valuenow="5"
        aria-valuemin="0" aria-valuemax="7">slider</div>
 </body>
 </html>