haikuwebkit/LayoutTests/accessibility/aria-sort-changed-notificat...

79 lines
2.9 KiB
HTML
Raw Permalink Normal View History

Add support for aria-sort change notifications. https://bugs.webkit.org/show_bug.cgi?id=221495 Reviewed by Chris Fleizach. Source/WebCore: Test: accessibility/aria-sort-changed-notification.html This patch adds support for aria-sort changes. Some code cleanup by using the notificationPlatformName helper function. * accessibility/AXLogger.cpp: (WebCore::operator<<): Logging of the new notification. * accessibility/AXObjectCache.cpp: Handles the aria-sort change notification. Updates the isolated tree. (WebCore::AXObjectCache::handleAttributeChange): (WebCore::AXObjectCache::updateIsolatedTree): * accessibility/AXObjectCache.h: * accessibility/ios/AXObjectCacheIOS.mm: (WebCore::AXObjectCache::notificationPlatformName): Helper to map AXCore notifications to platform notifications. (WebCore::AXObjectCache::postPlatformNotification): Handles the AXSortDirectionChanged notification. Some code cleanup using the notificationPlatformName helper. * accessibility/ios/WebAccessibilityObjectWrapperIOS.h: * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper postNotification:]): To be overridden by system AX bundles. (-[WebAccessibilityObjectWrapper accessibilitySortDirection]): Only ascending and descending sort directions are relevant for clients. * accessibility/isolatedtree/AXIsolatedTree.cpp: (WebCore::AXIsolatedTree::updateNodeProperty): Updates the SortDirection property. * accessibility/mac/AXObjectCacheMac.mm: (WebCore::AXObjectCache::postPlatformNotification): Handles the AXSortDirectionChanged notification. Tools: * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: (WTR::AccessibilityUIElement::sortDirection const): * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::sortDirection const): * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::currentStateValue const): (WTR::AccessibilityUIElement::sortDirection const): LayoutTests: * accessibility/aria-sort-changed-notification-expected.txt: Added. * accessibility/aria-sort-changed-notification.html: Added. * accessibility/aria-sort-expected.txt: * accessibility/aria-sort.html: Calls sortDirection property on the JS accessible element instead of retrieving the aria-sort attribute. This matches more accurately what an actual client would do. Changed the expected file accordingly. * accessibility/ios-simulator/aria-sort-ios-expected.txt: * accessibility/ios-simulator/aria-sort-ios.html: Same as in the Mac test above. * platform/ios/TestExpectations: Added the new test to be run on the ios-simulator. Canonical link: https://commits.webkit.org/233804@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-08 15:40:52 +00:00
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="../resources/accessibility-helper.js"></script>
</head>
<body>
<table id="content" role="grid">
<thead>
<tr aria-label="Header" role="row">
<th id="Account" role="columnheader" onclick="toggleAriaSort()" aria-sort="ascending" aria-label="Acount Name" title="Account Name">Account Name</th>
</tr>
</thead>
</table>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that changing the aria-sort value results in a SortDirectionChanged notification.");
window.jsTestIsAsync = true;
if (window.accessibilityController) {
var notificationCount = 0;
accessibilityController.addNotificationListener(function(element, notification) {
if (notification != "AXSortDirectionChanged")
return;
++notificationCount;
debug(notification + " notification for " + element.domIdentifier);
});
function toggleAriaSort(element) {
var sortingState = element.getAttribute("aria-sort");
if (sortingState == "ascending")
element.setAttribute("aria-sort", "descending");
else
element.setAttribute("aria-sort", "ascending");
}
var columnHeader = document.getElementById("Account");
var axColumnHeader = accessibilityController.accessibleElementById("Account");
shouldBe("axColumnHeader.sortDirection", "'AXAscendingSortDirection'");
debug("Toggling aria-sort");
toggleAriaSort(columnHeader);
setTimeout(async function() {
await waitFor(() => {
return notificationCount == 1;//axColumnHeader.sortDirection == "AXDescendingSortDirection";
});
shouldBe("axColumnHeader.sortDirection", "'AXDescendingSortDirection'");
debug("Setting aria-sort to a random value");
columnHeader.setAttribute("aria-sort", "blah blah blah");
await waitFor(() => {
return notificationCount == 2;//axColumnHeader.sortDirection == "AXUnknownSortDirection";
});
shouldBe("axColumnHeader.sortDirection", "'AXUnknownSortDirection'");
debug("Toggling aria-sort");
toggleAriaSort(columnHeader);
await waitFor(() => {
return notificationCount == 3;//axColumnHeader.sortDirection == "AXAscendingSortDirection";
});
shouldBe("axColumnHeader.sortDirection", "'AXAscendingSortDirection'");
shouldBe("notificationCount", "3");
document.getElementById("content").style.visibility = "hidden";
accessibilityController.removeNotificationListener();
finishJSTest();
}, 0);
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>