Skip to content

Commit

Permalink
AX: Fix to handle author error roles
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261542
rdar://problem/115462091

Reviewed by Tyler Wilcock.

This commit fixes the wai-aria/role/form-roles test[1]. According to the
ARIA spec[2], in situations where an author has not specified names for
the form and region landmarks, it is considered as authoring error. If a
valid fallback role had been specified, or if the element had an implicit
ARIA role, then user agents would continue to expose that role instead.

[1]: https://wpt.fyi/results/wai-aria/role/form-roles.html
[2]: https://w3c.github.io/aria/#document-handling_author-errors_roles

* LayoutTests/accessibility/aria-namefrom-author.html:
* LayoutTests/accessibility/roles-computedRoleString.html:
* LayoutTests/imported/w3c/web-platform-tests/wai-aria/role/form-roles-expected.txt:
* LayoutTests/platform/mac/accessibility/roles-computedRoleString-expected.txt:
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAriaRoleAttribute const):

Canonical link: https://commits.webkit.org/268025@main
  • Loading branch information
hs85jeong authored and twilco committed Sep 15, 2023
1 parent 3df2a59 commit 3d6388b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 36 deletions.
55 changes: 27 additions & 28 deletions LayoutTests/accessibility/aria-namefrom-author.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,32 @@
<div id="test12" class="test" role="math">math</div>
<div id="test13" class="test" role="note">note</div>
<div id="test14" class="test" role="table">table</div>
<div id="test15" class="test" role="form">form</div>
<div id="test16" class="test" role="grid">grid</div>
<div id="test17" class="test" role="group">group</div>
<div id="test18" class="test" role="img">img</div>
<div id="test19" class="test" role="list">list</div>
<div id="test20" class="test" role="listbox">listbox</div>
<div id="test21" class="test" role="application">application</div>
<div id="test22" class="test" role="banner">banner</div>
<div id="test23" class="test" role="complementary">complementary</div>
<div id="test24" class="test" role="contentinfo">contentinfo</div>
<div id="test25" class="test" role="navigation">navigation</div>
<div id="test26" class="test" role="main">main</div>
<div id="test27" class="test" role="search">search</div>
<div id="test28" class="test" role="menu">menu</div>
<div id="test29" class="test" role="menubar">menubar</div>
<div id="test30" class="test" role="progressbar">progressbar</div>
<div id="test31" class="test" role="radiogroup">radiogroup</div>
<div id="test32" class="test" role="scrollbar">scrollbar</div>
<div id="test33" class="test" role="slider">slider</div>
<div id="test34" class="test" role="spinbutton">spinbutton</div>
<div id="test35" class="test" role="separator">separator</div>
<div id="test36" class="test" role="tablist">tablist</div>
<div id="test37" class="test" role="tabpanel">tabpanel</div>
<div id="test38" class="test" role="textbox">textbox</div>
<div id="test39" class="test" role="toolbar">toolbar</div>
<div id="test40" class="test" role="treegrid">treegrid</div>
<div id="test41" class="test" role="tree">tree</div>
<div id="test15" class="test" role="grid">grid</div>
<div id="test16" class="test" role="group">group</div>
<div id="test17" class="test" role="img">img</div>
<div id="test18" class="test" role="list">list</div>
<div id="test19" class="test" role="listbox">listbox</div>
<div id="test20" class="test" role="application">application</div>
<div id="test21" class="test" role="banner">banner</div>
<div id="test22" class="test" role="complementary">complementary</div>
<div id="test23" class="test" role="contentinfo">contentinfo</div>
<div id="test24" class="test" role="navigation">navigation</div>
<div id="test25" class="test" role="main">main</div>
<div id="test26" class="test" role="search">search</div>
<div id="test27" class="test" role="menu">menu</div>
<div id="test28" class="test" role="menubar">menubar</div>
<div id="test29" class="test" role="progressbar">progressbar</div>
<div id="test30" class="test" role="radiogroup">radiogroup</div>
<div id="test31" class="test" role="scrollbar">scrollbar</div>
<div id="test32" class="test" role="slider">slider</div>
<div id="test33" class="test" role="spinbutton">spinbutton</div>
<div id="test34" class="test" role="separator">separator</div>
<div id="test35" class="test" role="tablist">tablist</div>
<div id="test36" class="test" role="tabpanel">tabpanel</div>
<div id="test37" class="test" role="textbox">textbox</div>
<div id="test38" class="test" role="toolbar">toolbar</div>
<div id="test39" class="test" role="treegrid">treegrid</div>
<div id="test40" class="test" role="tree">tree</div>


<div role="button" id="button" aria-label="text">button text</div>
Expand All @@ -62,7 +61,7 @@
description("This tests all the cases where nameFrom: author is used instead of nameFrom: contents. This means that if these elements are used in aria-labelledby they should not return their inner text. The button should retain its aria-label.");

var labelledby = "";
for (var k = 1; k < 42; k++) {
for (var k = 1; k < 41; k++) {
labelledby += "test" + k + " ";
}
document.getElementById("button").setAttribute("aria-labelledby", labelledby);
Expand Down
6 changes: 5 additions & 1 deletion LayoutTests/accessibility/roles-computedRoleString.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ <h2 id="section-label">X</h2>
<div role="directory" data-role="list" data-platform="atspi,mac" class="ex">X</div><!-- FIXME: should be directory -->
<div role="document" data-role="document" data-platform="atspi,mac" class="ex">X</div>
<div role="figure" data-role="figure" data-platform="atspi,mac" class="ex">X</div>
<div role="form" data-role="form" data-platform="atspi,mac" class="ex">X</div>
<div role="form" data-role="generic" data-platform="atspi,mac" class="ex" data-note=":not([aria-label]:not([aria-labelledby])">X</div>
<div role="form" data-role="form" data-platform="atspi,mac" class="ex" aria-label="x" data-note="[aria-label]">X</div>
<div role="form" data-role="form" data-platform="atspi,mac" class="ex" aria-labelledby="form-label" data-note="[aria-labelledby]">
<h2 id="form-label">X</h2>
</div>
<div role="graphics-document" data-role="document" data-platform="atspi,mac" class="ex">X</div>
<div role="graphics-object" data-role="group" data-platform="atspi,mac" class="ex">X</div>
<div role="graphics-symbol" data-role="image" data-platform="atspi,mac" class="ex">X</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Verifies 9.1 Roles - handling author errors and the form role.
x
x

FAIL form without label assert_equals: <nav role="form" data-testname="form without label" data-expectedrole="navigation" class="ex">x</nav> expected "navigation" but got "form"
PASS form without label
PASS form with label

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ PASS div[role="dialog"] -> dialog.
PASS div[role="directory"] -> list.
PASS div[role="document"] -> document.
PASS div[role="figure"] -> figure.
PASS div[role="form"] -> form.
PASS div[role="form"]:not([aria-label]:not([aria-labelledby]) -> generic.
PASS div[role="form"][aria-label] -> form.
PASS div[role="form"][aria-labelledby] -> form.
PASS div[role="graphics-document"] -> document.
PASS div[role="graphics-object"] -> group.
PASS div[role="graphics-symbol"] -> image.
Expand Down
10 changes: 5 additions & 5 deletions Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2865,11 +2865,11 @@ AccessibilityRole AccessibilityNodeObject::determineAriaRoleAttribute() const
if (role == AccessibilityRole::Presentational && supportsARIAAttributes())
role = AccessibilityRole::Unknown;

// The ARIA spec states, "Authors must give each element with role region a brief label that
// describes the purpose of the content in the region." The Core AAM states, "Special case:
// if the region does not have an accessible name, do not expose the element as a landmark.
// Use the native host language role of the element instead."
if (role == AccessibilityRole::LandmarkRegion && !hasAttribute(aria_labelAttr) && !hasAttribute(aria_labelledbyAttr))
// https://w3c.github.io/aria/#document-handling_author-errors_roles
// In situations where an author has not specified names for the form and
// region landmarks, it is considered an authoring error. The user agent
// MUST treat such element as if no role had been provided.
if ((role == AccessibilityRole::LandmarkRegion || role == AccessibilityRole::Form) && !hasAttribute(aria_labelAttr) && !hasAttribute(aria_labelledbyAttr))
role = AccessibilityRole::Unknown;

if (static_cast<int>(role))
Expand Down

0 comments on commit 3d6388b

Please sign in to comment.