Commit 0a9debb
[a11y] [Interop] Ignore ARIA roles that lack required parent context
According to the CORE-AAM and HTML-AAM specifications, if an explicit
ARIA role token (like listitem or option) is used on an element but it
is not contained within its required parent context (e.g., a listitem
must be owned by a list; an option must be owned by a listbox), the
user agent must ignore the role token and fallback to the next role
in the string or the native host element's role.
This CL fixes this in Blink accessibility by implementing a
context-aware role determination loop:
1. Implement AXObject::HasRequiredParentContext() to verify if listitem
or option elements have a valid owner, checking both DOM parent
chain traversal (reentrancy-free) and the relation cache (for
aria-owns).
2. Implement AXObject::FirstValidRoleInRoleStringWithContext() to
iterate through all role attribute tokens and return the first valid
role that satisfies its parent context. Ensure empty tokens
resulting from whitespace-only roles are safely skipped to avoid
fatal C++ DCHECK failures.
3. Update AXObject::DetermineAriaRole() to use the new context-valid
role, meaning orphaned listitems and options now cleanly fallback.
4. Add a public AXRelationCache* RelationCache() getter to
AXObjectCacheImpl for AXObject's checks.
5. Add a public AXObject::UpdateRole() to re-evaluate and cache the
role in place when its required parent context changes dynamically
(e.g., via aria-owns reparenting inside MapOwnedChildren()).
6. Support presentational containers. Update DOM parent walking loops
in IsOrphanedListItem() and IsOrphanedOption() to safely skip over
ignored, presentational wrapper elements (role="presentation" or
role="none").
7. Add C++ unit tests in ax_object_test.cc to cover orphaned role
fallbacks, aria-owns allowed roles, and presentational skips.
8. Update focusgroup unittests in ax_node_object_test.cc to wrap
explicit listitems in valid role="list" parents so they are
compliant and not orphans.
9. Update layout tests in web_tests/accessibility/ by wrapping
orphaned option elements in valid role="listbox" containers,
and update expected baseline text files.
10. Update DumpAccessibility browser tests in content/test/data/ and
focusgroup WPT layout tests in web_tests/ by wrapping orphaned
elements in valid list/listbox containers, and regenerate
expected test baseline dumps (including Blink, AuraLinux, and Mac
platforms).
11. Update AXTreeDistiller browser tests mock HTML to wrap orphaned
listitems in a valid list container.
This fixes WPT failures in roles-generic.html,
list-roles.tentative.html, and listbox-roles.tentative.html.
Bug: 341369184, 341362249
Change-Id: I04f17e398e0e61148375a96456899241ba69c969
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7841776
Reviewed-by: David Grogan <dgrogan@chromium.org>
Commit-Queue: Lucas Radaelli <lucasradaelli@google.com>
Reviewed-by: Jacques Newman <janewman@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1631553}1 parent 0ab57ba commit 0a9debb
1 file changed
Lines changed: 9 additions & 3 deletions
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
100 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
| |||
0 commit comments