Skip to content

Commit

Permalink
[A11y] Ensure aside tag has complementary role with role="complementary"
Browse files Browse the repository at this point in the history
When the aside element explicitly has the role="complementary",
it should retain this role regardless of whether it's nested within
article, nav, section, or another complementary element.

Bug: None
Test: All/DumpAccessibilityTreeTest.AccessibilityLandmark/*
Change-Id: Ia2a4f317d054a20755b0a1ab3af4c99bdc4a5232
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4999348
Commit-Queue: Joone Hur <joone@chromium.org>
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1222655}
  • Loading branch information
Joone Hur authored and Chromium LUCI CQ committed Nov 10, 2023
1 parent 8425b50 commit 4ff914b
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,12 @@ android.webkit.WebView focusable focused scrollable
++android.view.View
++++android.widget.TextView name='This should NOT have complementary role.'
++android.view.View role_description='main'
++++android.view.View role_description='complementary' name='This should have complementary role.'
++android.view.View role_description='article'
++++android.view.View role_description='complementary' name='This should have complementary role.'
++android.view.View role_description='complementary'
++++android.view.View role_description='complementary' name='This should have complementary role.'
++android.view.View role_description='navigation'
++++android.view.View role_description='complementary' name='This should have complementary role.'
++android.view.View
++++android.view.View role_description='complementary' name='This should have complementary role.'
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@
++[landmark] xml-roles:main
++++[landmark] xml-roles:complementary
++++++[static] name='This should have complementary role.'
++[article]
++++[landmark] xml-roles:complementary
++++++[static] name='This should have complementary role.'
++[landmark] xml-roles:complementary
++++[landmark] xml-roles:complementary
++++++[static] name='This should have complementary role.'
++[landmark] xml-roles:navigation
++++[landmark] xml-roles:complementary
++++++[static] name='This should have complementary role.'
++[section]
++++[landmark] xml-roles:complementary
++++++[static] name='This should have complementary role.'
20 changes: 20 additions & 0 deletions content/test/data/accessibility/html/landmark-expected-blink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,23 @@ rootWebArea
++++++++++complementary
++++++++++++staticText name='This should have complementary role.'
++++++++++++++inlineTextBox name='This should have complementary role.'
++++++article
++++++++genericContainer ignored
++++++++++complementary
++++++++++++staticText name='This should have complementary role.'
++++++++++++++inlineTextBox name='This should have complementary role.'
++++++complementary
++++++++genericContainer ignored
++++++++++complementary
++++++++++++staticText name='This should have complementary role.'
++++++++++++++inlineTextBox name='This should have complementary role.'
++++++navigation
++++++++genericContainer ignored
++++++++++complementary
++++++++++++staticText name='This should have complementary role.'
++++++++++++++inlineTextBox name='This should have complementary role.'
++++++section
++++++++genericContainer ignored
++++++++++complementary
++++++++++++staticText name='This should have complementary role.'
++++++++++++++inlineTextBox name='This should have complementary role.'
20 changes: 20 additions & 0 deletions content/test/data/accessibility/html/landmark-expected-fuchsia.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,23 @@ UNKNOWN focusable has_input_focus
++++++++++UNKNOWN
++++++++++++STATIC_TEXT label='This should have complementary role.'
++++++++++++++UNKNOWN label='This should have complementary role.'
++++++UNKNOWN
++++++++UNKNOWN hidden
++++++++++UNKNOWN
++++++++++++STATIC_TEXT label='This should have complementary role.'
++++++++++++++UNKNOWN label='This should have complementary role.'
++++++UNKNOWN
++++++++UNKNOWN hidden
++++++++++UNKNOWN
++++++++++++STATIC_TEXT label='This should have complementary role.'
++++++++++++++UNKNOWN label='This should have complementary role.'
++++++UNKNOWN
++++++++UNKNOWN hidden
++++++++++UNKNOWN
++++++++++++STATIC_TEXT label='This should have complementary role.'
++++++++++++++UNKNOWN label='This should have complementary role.'
++++++UNKNOWN
++++++++UNKNOWN hidden
++++++++++UNKNOWN
++++++++++++STATIC_TEXT label='This should have complementary role.'
++++++++++++++UNKNOWN label='This should have complementary role.'
12 changes: 12 additions & 0 deletions content/test/data/accessibility/html/landmark-expected-mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ AXWebArea AXRoleDescription='HTML content'
++AXGroup AXSubrole=AXLandmarkMain AXRoleDescription='main'
++++AXGroup AXSubrole=AXLandmarkComplementary AXRoleDescription='complementary'
++++++AXStaticText AXRoleDescription='text' AXValue='This should have complementary role.'
++AXGroup AXSubrole=AXDocumentArticle AXRoleDescription='article'
++++AXGroup AXSubrole=AXLandmarkComplementary AXRoleDescription='complementary'
++++++AXStaticText AXRoleDescription='text' AXValue='This should have complementary role.'
++AXGroup AXSubrole=AXLandmarkComplementary AXRoleDescription='complementary'
++++AXGroup AXSubrole=AXLandmarkComplementary AXRoleDescription='complementary'
++++++AXStaticText AXRoleDescription='text' AXValue='This should have complementary role.'
++AXGroup AXSubrole=AXLandmarkNavigation AXRoleDescription='navigation'
++++AXGroup AXSubrole=AXLandmarkComplementary AXRoleDescription='complementary'
++++++AXStaticText AXRoleDescription='text' AXValue='This should have complementary role.'
++AXGroup AXRoleDescription='group'
++++AXGroup AXSubrole=AXLandmarkComplementary AXRoleDescription='complementary'
++++++AXStaticText AXRoleDescription='text' AXValue='This should have complementary role.'
12 changes: 12 additions & 0 deletions content/test/data/accessibility/html/landmark-expected-uia-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ Document
++Group
++++Group
++++++Text Name='This should have complementary role.'
++Group
++++Group
++++++Text Name='This should have complementary role.'
++Group
++++Group
++++++Text Name='This should have complementary role.'
++Group
++++Group
++++++Text Name='This should have complementary role.'
++Group
++++Group
++++++Text Name='This should have complementary role.'
12 changes: 12 additions & 0 deletions content/test/data/accessibility/html/landmark-expected-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_LANDMARK xml-roles:main
++++IA2_ROLE_LANDMARK xml-roles:complementary
++++++ROLE_SYSTEM_STATICTEXT name='This should have complementary role.'
++ROLE_SYSTEM_DOCUMENT READONLY
++++IA2_ROLE_LANDMARK xml-roles:complementary
++++++ROLE_SYSTEM_STATICTEXT name='This should have complementary role.'
++IA2_ROLE_LANDMARK xml-roles:complementary
++++IA2_ROLE_LANDMARK xml-roles:complementary
++++++ROLE_SYSTEM_STATICTEXT name='This should have complementary role.'
++IA2_ROLE_LANDMARK xml-roles:navigation
++++IA2_ROLE_LANDMARK xml-roles:complementary
++++++ROLE_SYSTEM_STATICTEXT name='This should have complementary role.'
++IA2_ROLE_SECTION
++++IA2_ROLE_LANDMARK xml-roles:complementary
++++++ROLE_SYSTEM_STATICTEXT name='This should have complementary role.'
5 changes: 5 additions & 0 deletions content/test/data/accessibility/html/landmark.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,10 @@
<nav><div><aside>This should NOT have complementary role.</aside></div></nav>
<section><div><aside>This should NOT have complementary role.</aside></div></section>
<main><div><aside>This should have complementary role.</aside></div></main>

<article><div><aside role="complementary">This should have complementary role.</aside></div></article>
<aside><div><aside role="complementary">This should have complementary role.</aside></div></aside>
<nav><div><aside role="complementary">This should have complementary role.</aside></div></nav>
<section><div><aside role="complementary">This should have complementary role.</aside></div></section>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,10 @@ bool AXNodeObject::IsDescendantOfLandmarkDisallowedElement() const {
if (!GetNode())
return false;

if (AriaRoleAttribute() == ax::mojom::blink::Role::kComplementary) {
return false;
}

auto role_names = GetLandmarkIsNotAllowedAncestorRoles(RoleValue());

for (AXObject* parent = ParentObjectUnignored(); parent;
Expand Down

0 comments on commit 4ff914b

Please sign in to comment.