-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AX: Dynamic changes to subtrees of AccessibilityNodeObjects can cause…
… missing or stale content https://bugs.webkit.org/show_bug.cgi?id=245212 rdar://problem/99956378 Reviewed by Andres Gonzalez. AccessibilityNodeObject is missing a few key method implementations that can cause incorrect AX tree construction (either missing or stale content) after dynamic page updates. These methods are: - updateChildrenIfNecessary - setNeedsToUpdateChildren - needsToUpdateChildren - setNeedsToUpdateSubtree In this patch, we move these method implementations from AccessibilityRenderObject to AccessibilityNodeObject, ensuring both types of objects share this logic. * LayoutTests/accessibility/display-contents-dynamically-added-children-expected.txt: Added. * LayoutTests/accessibility/display-contents-dynamically-added-children.html: Added. * LayoutTests/platform/glib/TestExpectations: Skip new test. * LayoutTests/platform/ios/TestExpectations: * LayoutTests/platform/ios/accessibility/display-contents-dynamically-added-children-expected.txt: Added. * LayoutTests/platform/mac-wk1/TestExpectations: Skip new test. * LayoutTests/platform/win/TestExpectations: Skip new test. * Source/WebCore/accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::updateChildrenIfNecessary): * Source/WebCore/accessibility/AccessibilityNodeObject.h: * Source/WebCore/accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::updateChildrenIfNecessary): Moved to AccessibilityNodeObject. * Source/WebCore/accessibility/AccessibilityRenderObject.h: Canonical link: https://commits.webkit.org/254534@main
- Loading branch information
Showing
11 changed files
with
128 additions
and
16 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
LayoutTests/accessibility/display-contents-dynamically-added-children-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
This test ensures that we include dynamically added content in the AX tree when said content is added as a subtree of a display:contents element. | ||
|
||
Traversing page based on initial state. | ||
|
||
AXRole: AXWebArea | ||
|
||
AXRole: AXGroup | ||
|
||
Adding list elements to #div-to-insert-into and performing another page traversal. | ||
|
||
AXRole: AXWebArea | ||
|
||
AXRole: AXGroup | ||
|
||
AXRole: AXList | ||
|
||
AXRole: AXGroup | ||
|
||
AXRole: AXListMarker | ||
|
||
AXRole: AXStaticText | ||
AXValue: List item one | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
List item one |
59 changes: 59 additions & 0 deletions
59
LayoutTests/accessibility/display-contents-dynamically-added-children.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!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="display-contents-div" aria-label="Div with display:contents" style="display:contents"> | ||
<div id="div-to-insert-into"> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
var testOutput = "This test ensures that we include dynamically added content in the AX tree when said content is added as a subtree of a display:contents element.\n\n"; | ||
|
||
var axRoot = accessibilityController.rootElement; | ||
function traversePage() { | ||
let searchResult = null; | ||
while (true) { | ||
searchResult = axRoot.uiElementForSearchPredicate(searchResult, true, "AXAnyTypeSearchKey", "", false); | ||
if (!searchResult) | ||
break; | ||
const role = searchResult.role; | ||
testOutput += `\n${role}`; | ||
if (role.includes("StaticText")) { | ||
let textContent = accessibilityController.platformName === "ios" ? searchResult.description : searchResult.stringValue; | ||
testOutput += `\n${textContent}`; | ||
} | ||
testOutput += "\n"; | ||
} | ||
} | ||
|
||
if (window.accessibilityController) { | ||
window.jsTestIsAsync = true; | ||
|
||
testOutput += "Traversing page based on initial state.\n"; | ||
traversePage(); | ||
|
||
testOutput += "\nAdding list elements to #div-to-insert-into and performing another page traversal.\n"; | ||
|
||
const ul = document.createElement("ul"); | ||
const li = document.createElement("li"); | ||
li.innerHTML = "List item one"; | ||
ul.appendChild(li); | ||
document.getElementById("div-to-insert-into").appendChild(ul); | ||
setTimeout(async function() { | ||
await waitFor(() => axRoot.uiElementForSearchPredicate(axRoot, true, "AXListSearchKey", "", false)); | ||
traversePage(); | ||
|
||
debug(testOutput); | ||
finishJSTest(); | ||
}, 0); | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...Tests/platform/ios/accessibility/display-contents-dynamically-added-children-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
This test ensures that we include dynamically added content in the AX tree when said content is added as a subtree of a display:contents element. | ||
|
||
Traversing page based on initial state. | ||
|
||
WebArea | ||
|
||
Div | ||
|
||
Adding list elements to #div-to-insert-into and performing another page traversal. | ||
|
||
ListMarker | ||
|
||
StaticText | ||
AXLabel: List item one | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
List item one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters