Skip to content

Commit

Permalink
AX: Fix multiple-label-input test in ITM mode
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260174
rdar://113872525

Reviewed by Andres Gonzalez.

This patch resolves an issue where innerHTML and innerText changes to labels were not updating their corresponding input element's AX title.

* LayoutTests/accessibility-isolated-tree/TestExpectations
* LayoutTests/platform/glib/accessibility/multiple-label-input-expected.txt

* LayoutTests/accessibility/multiple-label-input.html
* LayoutTests/accessibility/multiple-label-input-expected.txt:

Added check for using innerHTML—only checked for innerText functionality previously.

* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::updateIsolatedTree):

If static text changes and its parent is a <label>, update the corresponding control.

* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::updateNodeAndDependentProperties):

Check if a label is being modified (using innerText). If it is, update the corresponding control.

Canonical link: https://commits.webkit.org/266919@main
  • Loading branch information
hoffmanjoshua authored and AndresGonzalezApple committed Aug 15, 2023
1 parent 0c02598 commit 28bfc96
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
3 changes: 0 additions & 3 deletions LayoutTests/accessibility-isolated-tree/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ accessibility/frame-disconnect-textmarker-cache-crash.html [ Timeout ]
accessibility/mac/combobox-activedescendant-notifications.html [ Timeout ]
accessibility/mac/relationships-in-frames.html [ Timeout ]

# Times out because `innerText` changes on linked <label>s don't update cached AXTitle value.
accessibility/multiple-label-input.html [ Timeout ]

# Text failures
accessibility/dialog-showModal.html [ Failure ]
accessibility/dynamically-ignored-canvas.html [ Failure ]
Expand Down
6 changes: 5 additions & 1 deletion LayoutTests/accessibility/multiple-label-input-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ document.getElementById('label3').innerText = 'choice';
AXTitle: Enter choice
AXDescription:
AXHelp:
document.getElementById('label3').innerHTML = 'decision';
AXTitle: Enter decision
AXDescription:
AXHelp:

PASS successfullyParsed is true

TEST COMPLETE
Enter choice
Enter decision
7 changes: 7 additions & 0 deletions LayoutTests/accessibility/multiple-label-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
});
output += `${newText}\n`;

output += evalAndReturn("document.getElementById('label3').innerHTML = 'decision';");
await waitFor(() => {
newText = platformTextAlternatives(input);
return newText.includes("decision");
});
output += `${newText}\n`;

debug(output);
finishJSTest();
}, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ document.getElementById('label2').remove();
document.getElementById('label3').innerText = 'choice';
AXTitle: Enter choice
AXDescription:
document.getElementById('label3').innerHTML = 'decision';
AXTitle: Enter decision
AXDescription:

PASS successfullyParsed is true

TEST COMPLETE
Enter choice
Enter decision
8 changes: 7 additions & 1 deletion Source/WebCore/accessibility/AXObjectCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4083,11 +4083,17 @@ void AXObjectCache::updateIsolatedTree(const Vector<std::pair<RefPtr<Accessibili
case AXPressedStateChanged:
case AXRowSpanChanged:
case AXSelectedChildrenChanged:
case AXTextChanged:
case AXTextSecurityChanged:
case AXValueChanged:
updateNode(notification.first);
break;
case AXTextChanged:
updateNode(notification.first);
if (RefPtr axParent = notification.first->parentObject(); axParent && axParent->isLabel()) {
if (RefPtr correspondingControl = axParent->correspondingControlForLabelElement())
updateNode(correspondingControl.get());
}
break;
case AXLanguageChanged:
case AXRowCountChanged:
updateNode(notification.first);
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ void AXIsolatedTree::updateNodeAndDependentProperties(AccessibilityObject& axObj

updateNode(axObject);

if (RefPtr correspondingControl = axObject.isLabel() ? axObject.correspondingControlForLabelElement() : nullptr)
updateNode(*correspondingControl);

// When a row gains or loses cells, the column count of the table can change.
bool updateTableAncestorColumns = is<AccessibilityTableRow>(axObject);
for (auto* ancestor = axObject.parentObject(); ancestor; ancestor = ancestor->parentObject()) {
Expand Down

0 comments on commit 28bfc96

Please sign in to comment.