Bug 245212

Summary: AX: Dynamic changes to subtrees of AccessibilityNodeObjects can cause missing or stale content
Product: WebKit Reporter: Tyler Wilcock <tyler_w>
Component: AccessibilityAssignee: Tyler Wilcock <tyler_w>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Tyler Wilcock 2022-09-15 00:35:54 PDT
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
Comment 1 Radar WebKit Bug Importer 2022-09-15 00:36:05 PDT
<rdar://problem/99956378>
Comment 2 Tyler Wilcock 2022-09-15 00:38:56 PDT
Created attachment 462352 [details]
Patch
Comment 3 Andres Gonzalez 2022-09-15 06:58:07 PDT
(In reply to Tyler Wilcock from comment #2)
> Created attachment 462352 [details]
> Patch

Good catch!

--- a/LayoutTests/accessibility/display-contents-dynamically-added-children.html
+++ a/LayoutTests/accessibility/display-contents-dynamically-added-children.html

+    function traversePage() {
...
+                let textContent = accessibilityController.platformName === "ios" ? searchResult.description : searchResult.stringValue;
+                testOutput += `\n${textContent}`;

This could be a single line.

+            }
+            testOutput += "\n";
+        }
+    }

Don't really need this second \n.

You also have 

function dumpAccessibilityTree(accessibilityObject, stopElement, indent, allAttributesIfNeeded, getValueFromTitle, includeSubrole) 

in accessibility-helper.js that would also do the trick.
Comment 4 Andres Gonzalez 2022-09-15 07:02:39 PDT
Shouldn't the bug title reflect that this is a display:contents problem?
Comment 5 Tyler Wilcock 2022-09-15 14:59:44 PDT
(In reply to Andres Gonzalez from comment #4)
> Shouldn't the bug title reflect that this is a display:contents problem?
This isn't specific to display:contents. Any AccessibilityNodeObject is affected.

Also, I acknowledge and agree with your suggestions regarding the test. I would prefer not to wait 12 hours for another round of EWS, so I can try to cover those changes in a later patch.
Comment 6 EWS 2022-09-15 15:39:32 PDT
Committed 254534@main (c6e7fc8ecc94): <https://commits.webkit.org/254534@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 462352 [details].