From e0f3d9261cfd7dca27e41247fa27273185e13341 Mon Sep 17 00:00:00 2001 From: "tyler_w@apple.com" Date: Fri, 27 May 2022 15:49:14 +0000 Subject: [PATCH] AX: Update the isolated tree in response to dynamic aria-haspopup and aria-describedby changes https://bugs.webkit.org/show_bug.cgi?id=240968 Reviewed by Chris Fleizach. Testcases added to aria-describedby-on-input.html and element-haspopup.html to cover this change. * LayoutTests/accessibility/aria-describedby-on-input-expected.txt: * LayoutTests/accessibility/aria-describedby-on-input.html: * LayoutTests/accessibility/element-haspopup-expected.txt: * LayoutTests/accessibility/element-haspopup.html: * LayoutTests/platform/ios/accessibility/aria-describedby-on-input-expected.txt: Added. * LayoutTests/platform/ios/TestExpectations: * Source/WebCore/accessibility/AXLogger.cpp: (WebCore::operator<<): * Source/WebCore/accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::handleAttributeChange): (WebCore::AXObjectCache::updateIsolatedTree): * Source/WebCore/accessibility/AXObjectCache.h: Canonical link: https://commits.webkit.org/251049@main git-svn-id: http://svn.webkit.org/repository/webkit/trunk@294938 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- .../aria-describedby-on-input-expected.txt | 16 +++++--- .../accessibility/aria-describedby-on-input.html | 46 +++++++++++++++------- .../accessibility/element-haspopup-expected.txt | 43 ++++++++++---------- LayoutTests/accessibility/element-haspopup.html | 37 ++++++++++------- LayoutTests/platform/ios/TestExpectations | 2 + .../aria-describedby-on-input-expected.txt | 11 ++++++ Source/WebCore/accessibility/AXLogger.cpp | 6 +++ Source/WebCore/accessibility/AXObjectCache.cpp | 6 +++ Source/WebCore/accessibility/AXObjectCache.h | 2 + 9 files changed, 115 insertions(+), 54 deletions(-) rewrite LayoutTests/accessibility/aria-describedby-on-input-expected.txt (99%) rewrite LayoutTests/accessibility/element-haspopup-expected.txt (73%) create mode 100644 LayoutTests/platform/ios/accessibility/aria-describedby-on-input-expected.txt diff --git a/LayoutTests/accessibility/aria-describedby-on-input-expected.txt b/LayoutTests/accessibility/aria-describedby-on-input-expected.txt dissimilarity index 99% index c72e1460b571..070721878bbb 100644 --- a/LayoutTests/accessibility/aria-describedby-on-input-expected.txt +++ b/LayoutTests/accessibility/aria-describedby-on-input-expected.txt @@ -1,5 +1,11 @@ -This computer will self-destruct in minutes. -Allows you to specify the number of minutes after -which the computer will self-destruct. - -The accessibility description is "AXHelp: Allows you to specify the number of minutes after which the computer will self-destruct." +This test ensures input elements properly use the aria-describedby in their accessibility description. + +The accessibility description of #time is "AXHelp: Allows you to specify the number of minutes after which the computer will self-destruct." + +Updating aria-describedby of #time to #description3. +The accessibility description of #time is "AXHelp: Foobar." + +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/accessibility/aria-describedby-on-input.html b/LayoutTests/accessibility/aria-describedby-on-input.html index 97fd94a85af0..fd3df6b78c3c 100644 --- a/LayoutTests/accessibility/aria-describedby-on-input.html +++ b/LayoutTests/accessibility/aria-describedby-on-input.html @@ -1,23 +1,41 @@ - + + + + + +
This computer will self-destruct in minutes. +
Allows you to specify the number of minutes after
which the computer will self-destruct.
-
- - +
Foobar.
+
+ + + diff --git a/LayoutTests/accessibility/element-haspopup-expected.txt b/LayoutTests/accessibility/element-haspopup-expected.txt dissimilarity index 73% index 2154c7c5782e..dcce2b9787c8 100644 --- a/LayoutTests/accessibility/element-haspopup-expected.txt +++ b/LayoutTests/accessibility/element-haspopup-expected.txt @@ -1,21 +1,22 @@ -Link 1 Link 2 -Paragraph 1. - -Paragraph 2. - -Paragraph 3. - -This tests that an element will report that it has a popup correctly. - -On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". - - -PASS accessibilityController.accessibleElementById('link1').hasPopup is true -PASS accessibilityController.accessibleElementById('link2').hasPopup is false -PASS accessibilityController.accessibleElementById('paragraph1').hasPopup is true -PASS accessibilityController.accessibleElementById('paragraph2').hasPopup is false -PASS accessibilityController.accessibleElementById('paragraph3').hasPopup is false -PASS successfullyParsed is true - -TEST COMPLETE - +This tests that an element will report that it has a popup correctly. + +PASS: linkOne.hasPopup === true +PASS: accessibilityController.accessibleElementById('link2').hasPopup === false +PASS: accessibilityController.accessibleElementById('paragraph1').hasPopup === true +PASS: accessibilityController.accessibleElementById('paragraph2').hasPopup === false +PASS: accessibilityController.accessibleElementById('paragraph3').hasPopup === false + +Setting aria-haspopup to false for #link1. +PASS: linkOne.hasPopup === false + +PASS successfullyParsed is true + +TEST COMPLETE +Link 1 Link 2 +Paragraph 1. + +Paragraph 2. + +Paragraph 3. + + diff --git a/LayoutTests/accessibility/element-haspopup.html b/LayoutTests/accessibility/element-haspopup.html index 7192284e6eab..f3c88c7febb5 100644 --- a/LayoutTests/accessibility/element-haspopup.html +++ b/LayoutTests/accessibility/element-haspopup.html @@ -1,9 +1,10 @@ - + + - + Link 1 Link 2 @@ -20,23 +21,31 @@

Paragraph 3.

-

-
- + testOutput += expect("accessibilityController.accessibleElementById('paragraph1').hasPopup", "true"); + testOutput += expect("accessibilityController.accessibleElementById('paragraph2').hasPopup", "false"); + testOutput += expect("accessibilityController.accessibleElementById('paragraph3').hasPopup", "false"); + + testOutput += "\nSetting aria-haspopup to false for #link1.\n"; + document.getElementById("link1").ariaHasPopup = "false"; + setTimeout(async function() { + await waitFor(() => !linkOne.hasPopup ); + testOutput += expect("linkOne.hasPopup", "false"); - + debug(testOutput); + finishJSTest(); + }, 0); + } + + diff --git a/LayoutTests/platform/ios/TestExpectations b/LayoutTests/platform/ios/TestExpectations index 79011cc61939..9e4f383eb5f6 100644 --- a/LayoutTests/platform/ios/TestExpectations +++ b/LayoutTests/platform/ios/TestExpectations @@ -2116,10 +2116,12 @@ fast/dom/linkify-phone-numbers.html [ Pass ] accessibility/table-exposure-updates-dynamically.html [ Pass ] accessibility/aria-busy-updates-after-dynamic-change.html [ Pass ] +accessibility/aria-describedby-on-input.html [ Pass ] accessibility/aria-hidden-display-contents-element.html [ Pass ] accessibility/aria-readonly-updates-after-dynamic-change.html [ Pass ] accessibility/aria-required-updates-after-dynamic-change.html [ Pass ] accessibility/display-contents-element-roles.html [ Pass ] +accessibility/element-haspopup.html [ Pass ] accessibility/list-with-dynamically-changing-content.html [ Pass ] accessibility/node-only-object-element-rect.html [ Pass ] accessibility/text-updates-after-dynamic-change.html [ Pass ] diff --git a/LayoutTests/platform/ios/accessibility/aria-describedby-on-input-expected.txt b/LayoutTests/platform/ios/accessibility/aria-describedby-on-input-expected.txt new file mode 100644 index 000000000000..2fd67bfda634 --- /dev/null +++ b/LayoutTests/platform/ios/accessibility/aria-describedby-on-input-expected.txt @@ -0,0 +1,11 @@ +This test ensures input elements properly use the aria-describedby in their accessibility description. + +The accessibility description of #time is "AXHint: Allows you to specify the number of minutes after which the computer will self-destruct." + +Updating aria-describedby of #time to #description3. +The accessibility description of #time is "AXHint: Foobar." + +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/Source/WebCore/accessibility/AXLogger.cpp b/Source/WebCore/accessibility/AXLogger.cpp index e99540ff404b..eee8e50069dd 100644 --- a/Source/WebCore/accessibility/AXLogger.cpp +++ b/Source/WebCore/accessibility/AXLogger.cpp @@ -385,6 +385,9 @@ TextStream& operator<<(TextStream& stream, AXObjectCache::AXNotification notific case AXObjectCache::AXNotification::AXDisabledStateChanged: stream << "AXDisabledStateChanged"; break; + case AXObjectCache::AXNotification::AXDescribedByChanged: + stream << "AXDescribedByChanged"; + break; case AXObjectCache::AXNotification::AXFocusedUIElementChanged: stream << "AXFocusedUIElementChanged"; break; @@ -394,6 +397,9 @@ TextStream& operator<<(TextStream& stream, AXObjectCache::AXNotification notific case AXObjectCache::AXNotification::AXGrabbedStateChanged: stream << "AXGrabbedStateChanged"; break; + case AXObjectCache::AXNotification::AXHasPopupChanged: + stream << "AXHasPopupChanged"; + break; case AXObjectCache::AXNotification::AXIdAttributeChanged: stream << "AXIdAttributeChanged"; break; diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp index 94f0017165e4..4c8230189178 100644 --- a/Source/WebCore/accessibility/AXObjectCache.cpp +++ b/Source/WebCore/accessibility/AXObjectCache.cpp @@ -1938,6 +1938,8 @@ void AXObjectCache::handleAttributeChange(const QualifiedName& attrName, Element textChanged(element); else if (attrName == aria_checkedAttr) checkedStateChanged(element); + else if (attrName == aria_describedbyAttr) + postNotification(element, AXDescribedByChanged); else if (attrName == aria_grabbedAttr) postNotification(element, AXGrabbedStateChanged); else if (attrName == aria_posinsetAttr) @@ -1946,6 +1948,8 @@ void AXObjectCache::handleAttributeChange(const QualifiedName& attrName, Element selectedStateChanged(element); else if (attrName == aria_expandedAttr) handleAriaExpandedChange(element); + else if (attrName == aria_haspopupAttr) + postNotification(element, AXHasPopupChanged); else if (attrName == aria_hiddenAttr) { if (auto* parent = get(element->parentNode())) handleChildrenChanged(*parent); @@ -3503,8 +3507,10 @@ void AXObjectCache::updateIsolatedTree(const Vector