Bug 1392926 - Only expose the Region landmark role if a section element has been explicitly named by the author, r=surkov
authorMarco Zehe <mzehe@mozilla.com>
Mon, 28 Aug 2017 10:48:09 +0200
changeset 377345 4b4b2af957d43556ac7755206ebed521d14a8a33
parent 377344 66888a531974251a1c238f366cce4f38846e4ff5
child 377346 81c100a42bb60c4d0a1f0a52cf33ebe250bdbcc3
push id94261
push usermzehe@mozilla.com
push dateTue, 29 Aug 2017 05:29:55 +0000
treeherdermozilla-inbound@4b4b2af957d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1392926
milestone57.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 1392926 - Only expose the Region landmark role if a section element has been explicitly named by the author, r=surkov MozReview-Commit-ID: 6B0TSy8lqck
accessible/base/MarkupMap.h
accessible/generic/HyperTextAccessible.cpp
accessible/tests/mochitest/attributes/test_xml-roles.html
accessible/tests/mochitest/elm/test_HTMLSpec.html
accessible/tests/mochitest/jsat/doc_traversal.html
--- a/accessible/base/MarkupMap.h
+++ b/accessible/base/MarkupMap.h
@@ -313,18 +313,17 @@ MARKUPMAP(progress,
           0)
 
 MARKUPMAP(q,
           New_HyperText,
           0)
 
 MARKUPMAP(section,
           New_HyperText,
-          roles::SECTION,
-          Attr(xmlroles, region))
+          roles::SECTION)
 
 MARKUPMAP(summary,
           New_HTMLSummary,
           roles::SUMMARY)
 
 MARKUPMAP(time,
           New_HyperText,
           0,
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -1170,16 +1170,23 @@ HyperTextAccessible::LandmarkRole() cons
   if (mContent->IsHTMLElement(nsGkAtoms::aside)) {
     return nsGkAtoms::complementary;
   }
 
   if (mContent->IsHTMLElement(nsGkAtoms::main)) {
     return nsGkAtoms::main;
   }
 
+  // Only return xml-roles "region" if the section has an accessible name.
+  if (mContent->IsHTMLElement(nsGkAtoms::section)) {
+    nsAutoString name;
+    const_cast<HyperTextAccessible*>(this)->Name(name);
+    return name.IsEmpty() ? nullptr : nsGkAtoms::region;
+  }
+
   return nullptr;
 }
 
 int32_t
 HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType)
 {
   nsIFrame* hyperFrame = GetFrame();
   if (!hyperFrame)
--- a/accessible/tests/mochitest/attributes/test_xml-roles.html
+++ b/accessible/tests/mochitest/attributes/test_xml-roles.html
@@ -22,17 +22,17 @@
       testAttrs("nav", {"xml-roles": "navigation"}, true);
       testAttrs("header", {"xml-roles": "banner"}, true);
       testAbsentAttrs("article_header", {"xml-roles": "banner"});
       testAbsentAttrs("section_header", {"xml-roles": "banner"});
       testAttrs("footer", {"xml-roles": "contentinfo"}, true);
       testAbsentAttrs("article_footer", {"xml-roles": "contentinfo"});
       testAbsentAttrs("section_footer", {"xml-roles": "contentinfo"});
       testAttrs("aside", {"xml-roles": "complementary"}, true);
-      testAttrs("section", {"xml-roles": "region"}, true);
+      testAbsentAttrs("section", {"xml-roles": "region"}, true);
       testAttrs("main", {"xml-roles": "main"}, true); // // ARIA override
       testAttrs("form", {"xml-roles": "form"}, true);
       testAttrs("feed", {"xml-roles": "feed"}, true);
       testAttrs("article", {"xml-roles": "article"}, true);
       testAttrs("main_element", {"xml-roles": "main"}, true);
       testAttrs("figure", {"xml-roles": "figure"}, true);
 
       testAttrs("search", {"xml-roles": "searchbox"}, true);
--- a/accessible/tests/mochitest/elm/test_HTMLSpec.html
+++ b/accessible/tests/mochitest/elm/test_HTMLSpec.html
@@ -1151,24 +1151,33 @@
         children: [
           { role: ROLE_TEXT_LEAF }, // plain text
           { role: ROLE_TEXT_LEAF } // HTML:samp text
         ]
       };
       testElm("samp_container", obj);
 
       // ////////////////////////////////////////////////////////////////////////
-      // HTML:section
+      // HTML:section without an accessible name
+
+      obj = {
+        role: ROLE_SECTION,
+        absentAttributes: { "xml-roles": "region" },
+        interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ]
+      };
+      testElm("section", obj);
+
+      // HTML:section with an accessible name
 
       obj = {
         role: ROLE_SECTION,
         attributes: { "xml-roles": "region" },
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ]
       };
-      testElm("section", obj);
+      testElm("named_section", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:small contained by paragraph
 
       obj = {
         role: ROLE_PARAGRAPH,
         textAttrs: {
           0: { },
@@ -1643,16 +1652,17 @@
   <ruby id="ruby">
     漢 <rp>(</rp><rt>Kan</rt><rp>)</rp>
     字 <rp>(</rp><rt>ji</rt><rp>)</rp>
   </ruby>
 
   <p id="s_container">normal<s>striked</s></p>
   <p id="samp_container">normal<samp>sample</samp></p>
   <section id="section">section</section>
+  <section id="named_section" aria-label="foo">named section</section>
   <p id="small_container">normal<small>small</small></p>
   <span id="span"></span>
   <p id="strong_container">normal<strong>strong</strong></p>
   <p id="sub_container">normal<sub>sub</sub></p>
   <p id="sup_container">normal<sup>sup</sup></p>
 
   <svg id="svg"></svg>
   <textarea id="textarea"></textarea>
--- a/accessible/tests/mochitest/jsat/doc_traversal.html
+++ b/accessible/tests/mochitest/jsat/doc_traversal.html
@@ -83,17 +83,17 @@
     <li id="listitem-2-3">JavaScript</li>
   </ul>
   <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>
+  <section aria-label="Some region">
     <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">