Skip to content

Commit

Permalink
AX: aria-describedby text can become stale after the targeted element…
Browse files Browse the repository at this point in the history
… changes its subtree

https://bugs.webkit.org/show_bug.cgi?id=273584
rdar://problem/127390465

Reviewed by Andres Gonzalez.

When an object targeted by aria-describedby changes its subtree, we need to re-compute AXPropertyName::{AccessibilityText, ExtendedDescription}
for the described object. We already did this for aria-labelledby relationships, so this patch hooks into the same
method to check for describedby relationships too.

* LayoutTests/accessibility/dynamic-aria-describedby-subtree-expected.txt: Added.
* LayoutTests/accessibility/dynamic-aria-describedby-subtree.html: Added.
* LayoutTests/platform/glib/TestExpectations: Skip new test.
* LayoutTests/platform/ios/TestExpectations: Enable new test.
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::updateDependentProperties):

Canonical link: https://commits.webkit.org/278318@main
  • Loading branch information
twilco committed May 3, 2024
1 parent 53e1699 commit 65862d8
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This test ensures that we update an element's description when it's described-by changes subtree dynamically.

PASS: accessibilityController.accessibleElementById('button').customContent === 'description: Always'
PASS: accessibilityController.accessibleElementById('button').customContent === 'description: Sometimes Always'

PASS successfullyParsed is true

TEST COMPLETE
Sometimes
Always
Press
32 changes: 32 additions & 0 deletions LayoutTests/accessibility/dynamic-aria-describedby-subtree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!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="tooltip" role="tooltip">
<div id="initially-hidden" style="display:none">Sometimes</div>Always
</div>
<button id="button" aria-describedby="tooltip">Press</button>

<script>
var output = "This test ensures that we update an element's description when it's described-by changes subtree dynamically.\n\n";

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

output += expect("accessibilityController.accessibleElementById('button').customContent", "'description: Always'");
document.getElementById("initially-hidden").style.display = "block";
setTimeout(async function() {
output += await expectAsync("accessibilityController.accessibleElementById('button').customContent", "'description: Sometimes Always'");

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

3 changes: 3 additions & 0 deletions LayoutTests/platform/glib/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ accessibility/shadow-dom-hit-test.html [ Skip ]
# AccessibilityUIElement::isAttributeSupported needs to be updated to handle AXSelectedRows.
accessibility/aria-table-selection-support.html [ Skip ]

# AccessibilityUIElement::customContent is not implemented.
accessibility/dynamic-aria-describedby-subtree.html [ Skip ]

# Timing out since added in https://bugs.webkit.org/show_bug.cgi?id=263715
accessibility/focus-inside-modal.html [ Skip ]
# Timing out since added in https://bugs.webkit.org/show_bug.cgi?id=249283.
Expand Down
1 change: 1 addition & 0 deletions LayoutTests/platform/ios/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,7 @@ accessibility/display-contents/element-roles.html [ Pass ]
accessibility/display-contents/object-ordering.html [ Pass ]
accessibility/display-contents/table.html [ Pass ]
accessibility/display-flex-shadow-dom-accname.html [ Pass ]
accessibility/dynamic-aria-describedby-subtree.html [ Pass ]
accessibility/dynamic-text.html [ Pass ]
accessibility/dynamically-ignored-canvas.html [ Pass ]
accessibility/editable-webpage-focused-ui-element.html [ Pass ]
Expand Down
14 changes: 9 additions & 5 deletions Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,18 @@ void AXIsolatedTree::updateDependentProperties(AccessibilityObject& axObject)
{
ASSERT(isMainThread());

auto updateLabeledObjects = [this] (const AccessibilityObject& label) {
auto labeledObjects = label.labelForObjects();
for (const auto& labeledObject : labeledObjects) {
auto updateRelatedObjects = [this] (const AccessibilityObject& object) {
for (const auto& labeledObject : object.labelForObjects()) {
if (RefPtr axObject = downcast<AccessibilityObject>(labeledObject.get()))
queueNodeUpdate(axObject->objectID(), NodeUpdateOptions::nodeUpdate());
}

for (const auto& describedByObject : object.descriptionForObjects()) {
if (RefPtr axObject = downcast<AccessibilityObject>(describedByObject.get()))
queueNodeUpdate(axObject->objectID(), { { AXPropertyName::AccessibilityText, AXPropertyName::ExtendedDescription } });
}
};
updateLabeledObjects(axObject);
updateRelatedObjects(axObject);

// When a row gains or loses cells, the column count of the table can change.
bool updateTableAncestorColumns = is<AccessibilityTableRow>(axObject);
Expand All @@ -798,7 +802,7 @@ void AXIsolatedTree::updateDependentProperties(AccessibilityObject& axObject)
break;
}

updateLabeledObjects(*ancestor);
updateRelatedObjects(*ancestor);
}
}

Expand Down

0 comments on commit 65862d8

Please sign in to comment.