Bug 614572 - Expose the correct new landmark role for HTML aside, header, footer, main and nav elements, r=Jamie
authorMarco Zehe <mzehe@mozilla.com>
Tue, 23 Oct 2018 06:11:59 +0000
changeset 490848 8ad2b19be6b9f41fde82dc95a9ae71bced32e64c
parent 490847 cc96d514beb84065d58268555e4f988269fe772a
child 490849 dfa1eb1d036fc0b11a449627c0a69702b3f6309f
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersJamie
bugs614572
milestone65.0a1
Bug 614572 - Expose the correct new landmark role for HTML aside, header, footer, main and nav elements, r=Jamie According to the HTML Accessibility API mappings spec, aside, footer, header, main and nav elements should be mapped to the WAI-ARIA landmark role exposure. For footer and header, this is only true if scoped to the body element. This patch changes the exposed roles to the new landmark mapping for the various platforms. Differential Revision: https://phabricator.services.mozilla.com/D9413
accessible/base/MarkupMap.h
accessible/html/HTMLElementAccessibles.cpp
accessible/tests/mochitest/elm/test_HTMLSpec.html
accessible/tests/mochitest/role/test_general.html
--- a/accessible/base/MarkupMap.h
+++ b/accessible/base/MarkupMap.h
@@ -19,17 +19,17 @@ MARKUPMAP(acronym,
 
 MARKUPMAP(article,
           New_HyperText,
           roles::ARTICLE,
           Attr(xmlroles, article))
 
 MARKUPMAP(aside,
           New_HyperText,
-          roles::NOTE)
+          roles::LANDMARK)
 
 MARKUPMAP(blockquote,
           New_HyperText,
           roles::BLOCKQUOTE)
 
 MARKUPMAP(dd,
           New_HTMLDtOrDd<HyperTextAccessibleWrap>,
           roles::DEFINITION)
@@ -114,16 +114,20 @@ MARKUPMAP(label,
 MARKUPMAP(legend,
           New_HTMLLegend,
           roles::LABEL)
 
 MARKUPMAP(li,
           New_HTMLListitem,
           0)
 
+MARKUPMAP(main,
+          New_HyperText,
+          roles::LANDMARK)
+
 MARKUPMAP(map,
           nullptr,
           roles::TEXT_CONTAINER)
 
 MARKUPMAP(math,
           New_HyperText,
           roles::MATHML_MATH)
 
@@ -288,17 +292,17 @@ MARKUPMAP(mscarry_,
 
 MARKUPMAP(msline_,
           New_HyperText,
           roles::MATHML_STACK_LINE,
           AttrFromDOM(position, position))
 
 MARKUPMAP(nav,
           New_HyperText,
-          roles::SECTION)
+          roles::LANDMARK)
 
 MARKUPMAP(ol,
           New_HTMLList,
           roles::LIST)
 
 MARKUPMAP(option,
           New_HTMLOption,
           0)
--- a/accessible/html/HTMLElementAccessibles.cpp
+++ b/accessible/html/HTMLElementAccessibles.cpp
@@ -218,37 +218,33 @@ HTMLHeaderOrFooterAccessible::NativeRole
                              nsGkAtoms::figure, nsGkAtoms::td)) {
       break;
     }
     parent = parent->GetParent();
   }
 
   // No sectioning or sectioning root elements found.
   if (!parent) {
-    if (mContent->IsHTMLElement(nsGkAtoms::header)) {
-      return roles::HEADER;
-    }
-
-    if (mContent->IsHTMLElement(nsGkAtoms::footer)) {
-      return roles::FOOTER;
-    }
+    return roles::LANDMARK;
   }
 
   return roles::SECTION;
 }
 
 nsAtom*
 HTMLHeaderOrFooterAccessible::LandmarkRole() const
 {
   if (!HasOwnContent())
     return nullptr;
 
   a11y::role r = const_cast<HTMLHeaderOrFooterAccessible*>(this)->Role();
-  if (r == roles::HEADER) {
-    return nsGkAtoms::banner;
-  }
+  if (r == roles::LANDMARK) {
+    if (mContent->IsHTMLElement(nsGkAtoms::header)) {
+      return nsGkAtoms::banner;
+    }
 
-  if (r == roles::FOOTER) {
-    return nsGkAtoms::contentinfo;
+    if (mContent->IsHTMLElement(nsGkAtoms::footer)) {
+      return nsGkAtoms::contentinfo;
+    }
   }
 
   return nullptr;
 }
--- a/accessible/tests/mochitest/elm/test_HTMLSpec.html
+++ b/accessible/tests/mochitest/elm/test_HTMLSpec.html
@@ -114,17 +114,17 @@
         states: STATE_READONLY,
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
       };
       testElm("article", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:aside
       obj = {
-        role: ROLE_NOTE,
+        role: ROLE_LANDMARK,
         attributes: { "xml-roles": "complementary" },
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
       };
       testElm("aside", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       obj = { // HTML:audio
         role: ROLE_GROUPING,
@@ -508,17 +508,17 @@
         ],
       };
       testElm("figure", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:footer
 
       obj = {
-        role: ROLE_FOOTER,
+        role: ROLE_LANDMARK,
         attributes: { "xml-roles": "contentinfo" },
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
       };
       testElm("footer", obj);
 
       obj = {
         role: ROLE_SECTION,
         absentAttributes: { "xml-roles": "contentinfo" },
@@ -610,17 +610,17 @@
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
       };
       testElm("h6", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:header
 
       obj = {
-        role: ROLE_HEADER,
+        role: ROLE_LANDMARK,
         attributes: { "xml-roles": "banner" },
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
       };
       testElm("header", obj);
 
       obj = {
         role: ROLE_SECTION,
         absentAttributes: { "xml-roles": "banner" },
@@ -973,17 +973,17 @@
       // HTML:link
 
       ok(!isAccessible("link"), "link element is not accessible");
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:main
 
       obj = {
-        todo_role: ROLE_GROUPING,
+        role: ROLE_LANDMARK,
         attributes: { "xml-roles": "main" },
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
       };
       testElm("main", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:map
 
@@ -1031,17 +1031,17 @@
       // HTML:meter
 
       todo(isAccessible("meter"), "meter element is not accessible");
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:nav
 
       obj = {
-        role: ROLE_SECTION,
+        role: ROLE_LANDMARK,
         attributes: { "xml-roles": "navigation" },
         interfaces: [ nsIAccessibleText, nsIAccessibleHyperText ],
       };
       testElm("nav", obj);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML:object (windowless and windowed plugins) and HTML:param
 
--- a/accessible/tests/mochitest/role/test_general.html
+++ b/accessible/tests/mochitest/role/test_general.html
@@ -16,29 +16,29 @@
 
   <script type="application/javascript">
     function doTests() {
       // landmark tests section
       testRole("frm", ROLE_FORM);
 
       // nsHyperTextAcc tests section
       // Test html:form.
-      testRole("nav", ROLE_SECTION);
-      testRole("header", ROLE_HEADER);
-      testRole("footer", ROLE_FOOTER);
+      testRole("nav", ROLE_LANDMARK);
+      testRole("header", ROLE_LANDMARK);
+      testRole("footer", ROLE_LANDMARK);
       testRole("article", ROLE_ARTICLE);
-      testRole("aside", ROLE_NOTE);
+      testRole("aside", ROLE_LANDMARK);
       testRole("section", ROLE_SECTION);
 
       // Bug 996821
       // Check that landmark elements get accessibles with styled overflow.
       testRole("section_overflow", ROLE_SECTION);
-      testRole("nav_overflow", ROLE_SECTION);
+      testRole("nav_overflow", ROLE_LANDMARK);
       testRole("header_overflow", ROLE_SECTION);
-      testRole("aside_overflow", ROLE_NOTE);
+      testRole("aside_overflow", ROLE_LANDMARK);
       testRole("footer_overflow", ROLE_SECTION);
       testRole("article_overflow", ROLE_ARTICLE);
 
       // test html:div
       testRole("sec", ROLE_SECTION);
 
       // Test html:blockquote
       testRole("quote", ROLE_BLOCKQUOTE);