diff --git a/accessible/jsat/Presentation.jsm b/accessible/jsat/Presentation.jsm index f222a6e3d5e2..60352b9fcc4e 100644 --- a/accessible/jsat/Presentation.jsm +++ b/accessible/jsat/Presentation.jsm @@ -507,7 +507,8 @@ B2GPresenter.prototype.pivotChanged = pattern: this.PIVOT_CHANGE_HAPTIC_PATTERN, isKey: Utils.isActivatableOnFingerUp(aContext.accessible), reason: this.pivotChangedReasons[aReason], - isUserInput: aIsUserInput + isUserInput: aIsUserInput, + hints: aContext.interactionHints } } }; diff --git a/accessible/jsat/Utils.jsm b/accessible/jsat/Utils.jsm index 7ddc42ee5637..be35d61f6b4f 100644 --- a/accessible/jsat/Utils.jsm +++ b/accessible/jsat/Utils.jsm @@ -828,6 +828,25 @@ PivotContext.prototype = { } }, + /** + * Get interaction hints for the context ancestry. + * @return {Array} Array of interaction hints. + */ + get interactionHints() { + let hints = []; + this.newAncestry.concat(this.accessible).reverse().forEach(aAccessible => { + let hint = Utils.getAttributes(aAccessible)['moz-hint']; + if (hint) { + hints.push(hint); + } else if (aAccessible.actionCount > 0) { + hints.push({ + string: Utils.AccRetrieval.getStringRole(aAccessible.role) + '-hint' + }); + } + }); + return hints; + }, + /* * A subtree generator function, used to generate a flattened * list of the accessible's subtree in pre or post order. diff --git a/accessible/tests/mochitest/jsat/a11y.ini b/accessible/tests/mochitest/jsat/a11y.ini index 9cba66ab6125..3d8de34c0ea9 100644 --- a/accessible/tests/mochitest/jsat/a11y.ini +++ b/accessible/tests/mochitest/jsat/a11y.ini @@ -15,6 +15,7 @@ skip-if = buildapp == 'mulet' skip-if = buildapp == 'mulet' [test_explicit_names.html] [test_gesture_tracker.html] +[test_hints.html] [test_landmarks.html] [test_live_regions.html] [test_output.html] diff --git a/accessible/tests/mochitest/jsat/output.js b/accessible/tests/mochitest/jsat/output.js index 406432caaf98..cd9b2a9f5fec 100644 --- a/accessible/tests/mochitest/jsat/output.js +++ b/accessible/tests/mochitest/jsat/output.js @@ -99,3 +99,16 @@ function testOutput(expected, aAccOrElmOrID, aOldAccOrElmOrID, aOutputKind) { } testObjectOutput(aAccOrElmOrID, generator); } + +function testHints(expected, aAccOrElmOrID, aOldAccOrElmOrID) { + var accessible = getAccessible(aAccOrElmOrID); + var oldAccessible = aOldAccOrElmOrID !== null ? + getAccessible(aOldAccOrElmOrID || 'root') : null; + var context = new PivotContext(accessible, oldAccessible); + var hints = context.interactionHints; + + isDeeply(hints, expected, + "Context hitns are correct for " + aAccOrElmOrID + + " (hints: " + JSON.stringify(hints) + ") ==" + + " (expected: " + JSON.stringify(expected) + ")"); +} diff --git a/accessible/tests/mochitest/jsat/test_hints.html b/accessible/tests/mochitest/jsat/test_hints.html new file mode 100644 index 000000000000..19b44911b73c --- /dev/null +++ b/accessible/tests/mochitest/jsat/test_hints.html @@ -0,0 +1,85 @@ + +
+