Skip to content

Commit

Permalink
AX: aria-hidden=false should be a synonym of undefined
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=277958
rdar://problem/133693990

Reviewed by NOBODY (OOPS!).

Per spec changes (see w3c/aria#2090), we should treat `aria-hidden=false` as undefined.

This patch removes support for aria-hidden=false, updating places where we relied on the behaviors of isNodeARIAVisible
with the new behavior. For example, we need to check if a child node is focused before deciding whether to skip it if it is
aria-hidden (tested by accessibility/datetime/input-date-field-labels-and-value-changes.html).

Tests that explicitly validate aria-hidden false were removed, and a new test to check that we are ignoring this property
has been added.

* LayoutTests/accessibility/aria-hidden-false-ignored-expected.txt: Added.
* LayoutTests/accessibility/aria-hidden-false-ignored.html: Added.
* LayoutTests/accessibility/aria-hidden-false-works-in-subtrees.html: Removed.
* LayoutTests/accessibility/aria-hidden-negates-no-visibility.html: Removed.
* LayoutTests/accessibility/aria-hidden-subtree-expected.txt: Added.
* LayoutTests/accessibility/aria-hidden-subtree.html: Added.
* LayoutTests/accessibility/aria-modal-expected.txt:
* LayoutTests/accessibility/aria-modal.html:
* LayoutTests/accessibility/aria-visible-element-roles.html: Removed.
* LayoutTests/accessibility/datetime/input-date-field-labels-and-value-changes.html:
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::isNodeVisible const):
(WebCore::AXObjectCache::getOrCreate):
(WebCore::isNodeFocused):
(WebCore::isNodeAriaVisible): Deleted.
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::textUnderElement const):
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::defaultObjectInclusion const):
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::addNodeOnlyChildren):
  • Loading branch information
Joshua Hoffman committed Aug 15, 2024
1 parent 96293e7 commit b3432d6
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 494 deletions.
11 changes: 11 additions & 0 deletions LayoutTests/accessibility/aria-hidden-false-ignored-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This test ensures that aria-hidden=false is treated like an undefined value.

PASS: !hiddenText === true
PASS: !invisibleText === true
PASS: !ariaHiddenText === true

PASS successfullyParsed is true

TEST COMPLETE

This text is hidden with aria-hidden
38 changes: 38 additions & 0 deletions LayoutTests/accessibility/aria-hidden-false-ignored.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/accessibility-helper.js"></script>
<script src="../resources/js-test.js"></script>
</head>
<body>

<div style="display: none">
<p id="hidden-text" aria-hidden="false">This text should be hidden</p>
</div>

<div style="visibility: hidden">
<p id="invisible-text" aria-hidden="false">This text should be invisible</p>
</div>

<div aria-hidden="true">
<p id="aria-hidden-text">This text is hidden with aria-hidden</p>
</div>

<script>
var output = "This test ensures that aria-hidden=false is treated like an undefined value.\n\n";

if (window.accessibilityController) {
var hiddenText = accessibilityController.accessibleElementById("hidden-text");
output += expect("!hiddenText", "true");
var invisibleText = accessibilityController.accessibleElementById("invisible-text");
output += expect("!invisibleText", "true");
var ariaHiddenText = accessibilityController.accessibleElementById("aria-hidden-text");
output += expect("!ariaHiddenText", "true");

debug(output);
finishJSTest();
}
</script>
</body>
</html>

152 changes: 0 additions & 152 deletions LayoutTests/accessibility/aria-hidden-false-works-in-subtrees.html

This file was deleted.

75 changes: 0 additions & 75 deletions LayoutTests/accessibility/aria-hidden-negates-no-visibility.html

This file was deleted.

19 changes: 19 additions & 0 deletions LayoutTests/accessibility/aria-hidden-subtree-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This test ensures that the entire subtree of an aria-hidden object is hidden.

DIV is aria-hidden=true:
PASS: !headingElement === true
PASS: !paragraphElement === true
PASS: !buttonElement === true
DIV has aria-hidden unset:
PASS: !!headingElement === true
PASS: !!paragraphElement === true
PASS: !!buttonElement === true

PASS successfullyParsed is true

TEST COMPLETE
Heading

This is a nested paragraph

Done
47 changes: 47 additions & 0 deletions LayoutTests/accessibility/aria-hidden-subtree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/accessibility-helper.js"></script>
<script src="../resources/js-test.js"></script>
</head>
<body>

<div id="container" aria-hidden="true">
<h1 id="heading">Heading</h1>
<div>
<p id="paragraph">This is a nested paragraph</p>
<button id="button" href="#">Done</button>
</div>
</div>

<script>
var output = "This test ensures that the entire subtree of an aria-hidden object is hidden.\n\n";

if (window.accessibilityController) {
window.jsTestIsAsync = true;

output += "DIV is aria-hidden=true:\n"
var headingElement = accessibilityController.accessibleElementById("heading");
output += expect("!headingElement", "true");
var paragraphElement = accessibilityController.accessibleElementById("paragraph");
output += expect("!paragraphElement", "true");
var buttonElement = accessibilityController.accessibleElementById("button");
output += expect("!buttonElement", "true");

output += "DIV has aria-hidden unset:\n";
document.getElementById("container").removeAttribute("aria-hidden");
setTimeout(async function() {
headingElement = accessibilityController.accessibleElementById("heading");
output += await expectAsync("!!headingElement", "true");
paragraphElement = accessibilityController.accessibleElementById("paragraph");
output += await expectAsync("!!paragraphElement", "true");
buttonElement = accessibilityController.accessibleElementById("button");
output += await expectAsync("!!buttonElement", "true");

debug(output);
finishJSTest();
}, 0);
}
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion LayoutTests/accessibility/aria-modal-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Dialog is displaying
PASS backgroundAccessible() is false
Dialog is displaying and aria-hidden=true
PASS backgroundAccessible() is true
Dialog is displaying and aria-hidden=false
Dialog is displaying and removed aria-hidden
PASS backgroundAccessible() is false
Dialog is not displaying with opacity 0
PASS backgroundAccessible() is true
Expand Down
6 changes: 3 additions & 3 deletions LayoutTests/accessibility/aria-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ <h3 id="myDialog">Just an example.</h3>
debug("Dialog is displaying and aria-hidden=true")
shouldBeTrue("backgroundAccessible()");

// Set aria-hidden=false.
document.getElementById("box").setAttribute("aria-hidden", "false");
// Unset aria hidden.
document.getElementById("box").removeAttribute("aria-hidden");
await waitFor(() => {
return !backgroundAccessible();
});
debug("Dialog is displaying and aria-hidden=false");
debug("Dialog is displaying and removed aria-hidden");
shouldBeFalse("backgroundAccessible()");

// Set opacity to 0 which should make the dialog invisible.
Expand Down
Loading

0 comments on commit b3432d6

Please sign in to comment.