Bug 1201146 - Introduce "Section" traversal rule. r=yzen
authorEitan Isaacson <eitan@monotonous.org>
Fri, 04 Sep 2015 10:04:19 -0700
changeset 293565 553b9819842d49ef376fa6ab82251d7c24e5d8d6
parent 293564 d7fed4b3bb8a776e60f993516311992ca7b64f07
child 293566 7ac366b0a2eac89b131b5c36bd23323209ee537a
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen
bugs1201146
milestone43.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 1201146 - Introduce "Section" traversal rule. r=yzen
accessible/jsat/Traversal.jsm
accessible/tests/mochitest/jsat/doc_traversal.html
accessible/tests/mochitest/jsat/test_traversal_helper.html
--- a/accessible/jsat/Traversal.jsm
+++ b/accessible/jsat/Traversal.jsm
@@ -219,16 +219,38 @@ this.TraversalRules = { // jshint ignore
 
   Landmark: new BaseTraversalRule(
     [],
     function Landmark_match(aAccessible) {
       return Utils.getLandmarkName(aAccessible) ? Filters.MATCH :
         Filters.IGNORE;
     }, null, true),
 
+  /* A rule for Android's section navigation, lands on landmarks, regions, and
+     on headings to aid navigation of traditionally structured documents */
+  Section: new BaseTraversalRule(
+    [],
+    function Section_match(aAccessible) {
+      if (aAccessible.role === Roles.HEADING) {
+        return Filters.MATCH;
+      }
+
+      let matchedRole = Utils.matchRoles(aAccessible, [
+        'banner',
+        'complementary',
+        'contentinfo',
+        'main',
+        'navigation',
+        'search',
+        'region'
+        ]);
+
+      return matchedRole ? Filters.MATCH : Filters.IGNORE;
+    }, null, true),
+
   Entry: new BaseTraversalRule(
     [Roles.ENTRY,
      Roles.PASSWORD_TEXT]),
 
   FormElement: new BaseTraversalRule(
     [Roles.PUSHBUTTON,
      Roles.SPINBUTTON,
      Roles.TOGGLE_BUTTON,
--- a/accessible/tests/mochitest/jsat/doc_traversal.html
+++ b/accessible/tests/mochitest/jsat/doc_traversal.html
@@ -77,26 +77,30 @@
         <li id="listitem-3-3">Clojure</li>
         <li id="listitem-3-4"><strong>Standard</strong> Lisp</li>
         <li id="listitem-3-5"><a id="link-0" href="#">Common</a> Lisp</li>
         <li id="listitem-3-6"><input id="checkbox-1-5" type="checkbox"> LeLisp</li>
       </ol>
     </li>
     <li id="listitem-2-3">JavaScript</li>
   </ul>
-  <h6 id="heading-5">The last (visible) one!</h6>
-  <img id="image-1" src="http://example.com" alt="">
-  <img id="image-2" src="../moz.png" alt="stuff">
-  <div id="image-3" tabindex="0" role="img">Not actually an image</div>
-  <h4 id="heading-6" aria-hidden="true">Hidden header</h4>
-  <a id="link-1" href="http://www.mozilla.org">Link</a>
-  <a id="anchor-1">Words</a>
-  <a id="link-2" href="http://www.mozilla.org">Link the second</a>
-  <a id="anchor-2">Sentences</a>
-  <a id="link-3" href="http://www.example.com">Link the third</a>
+  <section>
+    <h6 id="heading-5">The last (visible) one!</h6>
+    <img id="image-1" src="http://example.com" alt="">
+    <img id="image-2" src="../moz.png" alt="stuff">
+    <div id="image-3" tabindex="0" role="img">Not actually an image</div>
+  </section>
+  <section>
+    <h4 id="heading-6" aria-hidden="true">Hidden header</h4>
+    <a id="link-1" href="http://www.mozilla.org">Link</a>
+    <a id="anchor-1">Words</a>
+    <a id="link-2" href="http://www.mozilla.org">Link the second</a>
+    <a id="anchor-2">Sentences</a>
+    <a id="link-3" href="http://www.example.com">Link the third</a>
+  </section>
   <hr id="separator-1">
   <h6 id="heading-6"></h6>
   <table id="table-1">
   <tr>
     <td>3</td>
     <td>1</td>
   </tr>
   <tr>
--- a/accessible/tests/mochitest/jsat/test_traversal_helper.html
+++ b/accessible/tests/mochitest/jsat/test_traversal_helper.html
@@ -78,17 +78,19 @@
       vc = docAcc.virtualCursor;
 
       testTraversalHelper('Landmark',
         ['heading-1', 'heading-2', 'statusbar-1']);
 
       testTraversalHelper('List',
         ['Programming Language', 'listitem-2-1', 'listitem-3-1']);
 
-      vc.position = null;
+      testTraversalHelper('Section',
+        ['heading-1', 'heading-2', 'heading-3',
+         'heading-5', 'link-1', 'statusbar-1']);
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addLoadEvent(function () {
       /* We open a new browser because we need to test with a top-level content
          document. */