From 17f963096797ddaa3142d8ff0d063b7d5c9e09fd Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Mon, 31 Aug 2015 09:45:02 -0700 Subject: [PATCH] Bug 1199884 - Keep match roles empty in BaseTraversalRules that don't provide roles. r=yzen --- accessible/jsat/TraversalRules.jsm | 25 ++-- .../tests/mochitest/jsat/doc_traversal.html | 107 +++++++++--------- .../tests/mochitest/jsat/test_traversal.html | 3 + 3 files changed, 73 insertions(+), 62 deletions(-) diff --git a/accessible/jsat/TraversalRules.jsm b/accessible/jsat/TraversalRules.jsm index aa483e5cb5f9..610693f3451a 100644 --- a/accessible/jsat/TraversalRules.jsm +++ b/accessible/jsat/TraversalRules.jsm @@ -29,21 +29,23 @@ let gSkipEmptyImages = new PrefCache('accessibility.accessfu.skip_empty_images') function BaseTraversalRule(aRoles, aMatchFunc, aPreFilter) { this._explicitMatchRoles = new Set(aRoles); this._matchRoles = aRoles; - if (aRoles.indexOf(Roles.LABEL) < 0) { - this._matchRoles.push(Roles.LABEL); - } - if (aRoles.indexOf(Roles.INTERNAL_FRAME) < 0) { - // Used for traversing in to child OOP frames. - this._matchRoles.push(Roles.INTERNAL_FRAME); + if (aRoles.length) { + if (aRoles.indexOf(Roles.LABEL) < 0) { + this._matchRoles.push(Roles.LABEL); + } + if (aRoles.indexOf(Roles.INTERNAL_FRAME) < 0) { + // Used for traversing in to child OOP frames. + this._matchRoles.push(Roles.INTERNAL_FRAME); + } } this._matchFunc = aMatchFunc || function() { return Filters.MATCH; }; this.preFilter = aPreFilter || gSimplePreFilter; } BaseTraversalRule.prototype = { - getMatchRoles: function BaseTraversalRule_getmatchRoles(aRules) { - aRules.value = this._matchRoles; - return aRules.value.length; + getMatchRoles: function BaseTraversalRule_getmatchRoles(aRoles) { + aRoles.value = this._matchRoles; + return aRoles.value.length; }, match: function BaseTraversalRule_match(aAccessible) @@ -54,8 +56,9 @@ BaseTraversalRule.prototype = { Filters.MATCH | Filters.IGNORE_SUBTREE : Filters.IGNORE; } - let matchResult = this._explicitMatchRoles.has(role) ? - this._matchFunc(aAccessible) : Filters.IGNORE; + let matchResult = + (this._explicitMatchRoles.has(role) || !this._explicitMatchRoles.size) ? + this._matchFunc(aAccessible) : Filters.IGNORE; // If we are on a label that nests a checkbox/radio we should land on it. // It is a bigger touch target, and it reduces clutter. diff --git a/accessible/tests/mochitest/jsat/doc_traversal.html b/accessible/tests/mochitest/jsat/doc_traversal.html index 3e5ff2c62c4b..3a01cdd1ea3d 100644 --- a/accessible/tests/mochitest/jsat/doc_traversal.html +++ b/accessible/tests/mochitest/jsat/doc_traversal.html @@ -10,55 +10,58 @@ -

A small first heading

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

A larger second

-
ARIA is fun
- -
ARIA fun
-
My little togglebutton
-
ARIA fun
+
+

A small first heading

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

A larger second

+
ARIA is fun
+ +
ARIA fun
+
My little togglebutton
+
ARIA fun
+

Invisible header

Programming Language
@@ -141,8 +144,10 @@ -
Last sync:2 days ago
-
+
+
Last sync:2 days ago
+
+

This is a MathML formula diff --git a/accessible/tests/mochitest/jsat/test_traversal.html b/accessible/tests/mochitest/jsat/test_traversal.html index b95453b9f2bb..2da0346ce52d 100644 --- a/accessible/tests/mochitest/jsat/test_traversal.html +++ b/accessible/tests/mochitest/jsat/test_traversal.html @@ -127,6 +127,9 @@ 'switch-1', 'This is a MathML formula ', 'math-1', 'with some text after.']); + queueTraversalSequence(gQueue, docAcc, TraversalRules.Landmark, null, + ['header-1', 'main-1', 'footer-1']); + gQueue.invoke(); }