haikuwebkit/LayoutTests/accessibility/children-changed-sends-noti...

75 lines
2.2 KiB
HTML
Raw Permalink Normal View History

Programmatically-inserted children lack accessibility events https://bugs.webkit.org/show_bug.cgi?id=100275 Reviewed by Chris Fleizach. Source/WebCore: Test: accessibility/children-changed-sends-notification.html Emit children-changed::add and children-changed::remove whenever an object has been added/removed to the accessibility hierarchy, that is, when a new AtkObject is being attached/detached. * accessibility/AXObjectCache.h: (WebCore::AXObjectCache::detachWrapper): Added a new parameter and updated all the prototypes in different ports. * accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::~AXObjectCache): Call detachWrapper() specifying that we do it because the cache is being destroyed. (WebCore::AXObjectCache::remove): Call detachWrapper() specifying that we do it because an accessible element is being destroyed. * accessibility/atk/AXObjectCacheAtk.cpp: (WebCore::AXObjectCache::detachWrapper): Emit the children-changed signal when needed. We rely on the cached reference to the parent AtkObject (using the implementation of atk_object_get_parent from the AtkObject class) to find the right object to emit the signal from here, since the accessibility hierarchy from WebCore will no longer be accessible at this point. (WebCore::AXObjectCache::attachWrapper): Emit the children-change signal from here unless we are in the middle of a layout update, trying to provide as much information (e.g. the offset) as possible. (WebCore::AXObjectCache::postPlatformNotification): Make sure we update (touch) the subtree under an accessibility object whenever we receive AXChildrenChanded from WebCore, to ensure that those objects will also be visible rightaway to ATs, and that those get properly notified of the event at that very same moment. * accessibility/ios/AXObjectCacheIOS.mm: (WebCore::AXObjectCache::detachWrapper): Updated function signature. * accessibility/mac/AXObjectCacheMac.mm: (WebCore::AXObjectCache::detachWrapper): Ditto. * accessibility/win/AXObjectCacheWin.cpp: (WebCore::AXObjectCache::detachWrapper): Ditto. * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::children): Add the option ot request the AccessibilityChildrenVector without updating it if needed, to avoid maybe recreating the child subtree when trying to get the offset of a newly attached element from attachWrapper. * accessibility/AccessibilityObject.h: Tools: Update DRT and WebKitTestRunner to handle the children-changed signal properly, considering the detail and optional parameters. * DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp: Updated. (axObjectEventListener): * WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp: Updated. LayoutTests: Add new test to chack that children-changed signals are properly emitted when adding/removing elements in the accessibility hierarchy. * accessibility/children-changed-sends-notification-expected.txt: Added. * accessibility/children-changed-sends-notification.html: Added. Update test to filter out unrelated non-loading events. * accessibility/loading-iframe-sends-notification.html: Updated. Skip the test on the Mac as it does not expose these kind of notifications when children are being added or removed. * platform/mac/TestExpectations: Skip newly added test. Canonical link: https://commits.webkit.org/144028@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-12-20 11:52:17 +00:00
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
buildAccessibilityTree() needs to be removed from individual layout tests https://bugs.webkit.org/show_bug.cgi?id=95286 Reviewed by Chris Fleizach. Extracted two functions to 'dump' and 'touch' the accessibility hierarchies out of different layout tests and into a single file, living in LayoutTests/resources/accessibility-helper.js * resources/accessibility-helper.js: Added. (dumpAccessibilityTree): New, based on buildAccessibilityTree() for the cases where it was used to actually 'dump' it into the output. (touchAccessibilityTree): Same, but for the cases where we don't want to dump the accessibility tree, just to make sure is generated. Updated affected layout tests to use the newly added helper functions. * accessibility/adjacent-continuations-cause-assertion-failure.html: Updated. * accessibility/children-changed-sends-notification.html: Ditto. * accessibility/deleting-iframe-destroys-axcache.html: Ditto. * accessibility/div-within-anchors-causes-crash.html: Ditto. * accessibility/first-letter-text-transform-causes-crash.html: Ditto. * accessibility/image-map-update-parent-crash.html: Ditto. * accessibility/table-with-empty-thead-causes-crash.html: Ditto. * platform/efl/accessibility/media-emits-object-replacement.html: Ditto. * platform/gtk/accessibility/entry-and-password.html: Ditto. * platform/gtk/accessibility/media-emits-object-replacement.html: Ditto. * platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html: Ditto. Updated Mac specific expectations not to print the "End of test" element. * platform/mac-wk2/accessibility/deleting-iframe-destroys-axcache-expected.txt: Updated. * platform/mac/accessibility/adjacent-continuations-cause-assertion-failure-expected.txt: Ditto. * platform/mac/accessibility/deleting-iframe-destroys-axcache-expected.txt: Ditto. * platform/mac/accessibility/div-within-anchors-causes-crash-expected.txt: Ditto. Canonical link: https://commits.webkit.org/152610@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170806 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-07-04 15:31:57 +00:00
<script src="../resources/accessibility-helper.js"></script>
Programmatically-inserted children lack accessibility events https://bugs.webkit.org/show_bug.cgi?id=100275 Reviewed by Chris Fleizach. Source/WebCore: Test: accessibility/children-changed-sends-notification.html Emit children-changed::add and children-changed::remove whenever an object has been added/removed to the accessibility hierarchy, that is, when a new AtkObject is being attached/detached. * accessibility/AXObjectCache.h: (WebCore::AXObjectCache::detachWrapper): Added a new parameter and updated all the prototypes in different ports. * accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::~AXObjectCache): Call detachWrapper() specifying that we do it because the cache is being destroyed. (WebCore::AXObjectCache::remove): Call detachWrapper() specifying that we do it because an accessible element is being destroyed. * accessibility/atk/AXObjectCacheAtk.cpp: (WebCore::AXObjectCache::detachWrapper): Emit the children-changed signal when needed. We rely on the cached reference to the parent AtkObject (using the implementation of atk_object_get_parent from the AtkObject class) to find the right object to emit the signal from here, since the accessibility hierarchy from WebCore will no longer be accessible at this point. (WebCore::AXObjectCache::attachWrapper): Emit the children-change signal from here unless we are in the middle of a layout update, trying to provide as much information (e.g. the offset) as possible. (WebCore::AXObjectCache::postPlatformNotification): Make sure we update (touch) the subtree under an accessibility object whenever we receive AXChildrenChanded from WebCore, to ensure that those objects will also be visible rightaway to ATs, and that those get properly notified of the event at that very same moment. * accessibility/ios/AXObjectCacheIOS.mm: (WebCore::AXObjectCache::detachWrapper): Updated function signature. * accessibility/mac/AXObjectCacheMac.mm: (WebCore::AXObjectCache::detachWrapper): Ditto. * accessibility/win/AXObjectCacheWin.cpp: (WebCore::AXObjectCache::detachWrapper): Ditto. * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::children): Add the option ot request the AccessibilityChildrenVector without updating it if needed, to avoid maybe recreating the child subtree when trying to get the offset of a newly attached element from attachWrapper. * accessibility/AccessibilityObject.h: Tools: Update DRT and WebKitTestRunner to handle the children-changed signal properly, considering the detail and optional parameters. * DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp: Updated. (axObjectEventListener): * WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp: Updated. LayoutTests: Add new test to chack that children-changed signals are properly emitted when adding/removing elements in the accessibility hierarchy. * accessibility/children-changed-sends-notification-expected.txt: Added. * accessibility/children-changed-sends-notification.html: Added. Update test to filter out unrelated non-loading events. * accessibility/loading-iframe-sends-notification.html: Updated. Skip the test on the Mac as it does not expose these kind of notifications when children are being added or removed. * platform/mac/TestExpectations: Skip newly added test. Canonical link: https://commits.webkit.org/144028@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-12-20 11:52:17 +00:00
</head>
<body>
<p id="description"></p>
<p id="paragraph">Plain text paragraph <a id="testLink" href="#">with a link at the end</a></p>
<div id="console"></div>
<script>
window.jsTestIsAsync = true;
description("This test ensures that a notification is being emitted when children are added or removed for an accessibility object");
function runTest() {
window.paragraphNotificationCount = 0;
window.globalNotificationCount = 0;
if (window.accessibilityController) {
var axWebArea = accessibilityController.rootElement.childAtIndex(0);
// Ensure the accessibility hierarchy is generated.
touchAccessibilityTree(axWebArea);
window.paragraph = axWebArea.childAtIndex(1);
paragraph.addNotificationListener(function(notification) {
paragraphNotificationCount++;
debug("PARAGRAPH notification: " + notification);
});
accessibilityController.addNotificationListener(function(element, notification) {
if (!element.isEqual(paragraph))
return;
globalNotificationCount++;
debug("GLOBAL notification: " + notification + " on element with role " + element.role);
});
}
var par = document.getElementById('paragraph');
window.newChild = document.createElement('button');
par.appendChild(newChild);
// Ensure the new child is added.
touchAccessibilityTree(axWebArea);
Programmatically-inserted children lack accessibility events https://bugs.webkit.org/show_bug.cgi?id=100275 Reviewed by Chris Fleizach. Source/WebCore: Test: accessibility/children-changed-sends-notification.html Emit children-changed::add and children-changed::remove whenever an object has been added/removed to the accessibility hierarchy, that is, when a new AtkObject is being attached/detached. * accessibility/AXObjectCache.h: (WebCore::AXObjectCache::detachWrapper): Added a new parameter and updated all the prototypes in different ports. * accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::~AXObjectCache): Call detachWrapper() specifying that we do it because the cache is being destroyed. (WebCore::AXObjectCache::remove): Call detachWrapper() specifying that we do it because an accessible element is being destroyed. * accessibility/atk/AXObjectCacheAtk.cpp: (WebCore::AXObjectCache::detachWrapper): Emit the children-changed signal when needed. We rely on the cached reference to the parent AtkObject (using the implementation of atk_object_get_parent from the AtkObject class) to find the right object to emit the signal from here, since the accessibility hierarchy from WebCore will no longer be accessible at this point. (WebCore::AXObjectCache::attachWrapper): Emit the children-change signal from here unless we are in the middle of a layout update, trying to provide as much information (e.g. the offset) as possible. (WebCore::AXObjectCache::postPlatformNotification): Make sure we update (touch) the subtree under an accessibility object whenever we receive AXChildrenChanded from WebCore, to ensure that those objects will also be visible rightaway to ATs, and that those get properly notified of the event at that very same moment. * accessibility/ios/AXObjectCacheIOS.mm: (WebCore::AXObjectCache::detachWrapper): Updated function signature. * accessibility/mac/AXObjectCacheMac.mm: (WebCore::AXObjectCache::detachWrapper): Ditto. * accessibility/win/AXObjectCacheWin.cpp: (WebCore::AXObjectCache::detachWrapper): Ditto. * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::children): Add the option ot request the AccessibilityChildrenVector without updating it if needed, to avoid maybe recreating the child subtree when trying to get the offset of a newly attached element from attachWrapper. * accessibility/AccessibilityObject.h: Tools: Update DRT and WebKitTestRunner to handle the children-changed signal properly, considering the detail and optional parameters. * DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp: Updated. (axObjectEventListener): * WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp: Updated. LayoutTests: Add new test to chack that children-changed signals are properly emitted when adding/removing elements in the accessibility hierarchy. * accessibility/children-changed-sends-notification-expected.txt: Added. * accessibility/children-changed-sends-notification.html: Added. Update test to filter out unrelated non-loading events. * accessibility/loading-iframe-sends-notification.html: Updated. Skip the test on the Mac as it does not expose these kind of notifications when children are being added or removed. * platform/mac/TestExpectations: Skip newly added test. Canonical link: https://commits.webkit.org/144028@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-12-20 11:52:17 +00:00
window.setTimeout(function() {
var link = document.getElementById('testLink');
link.style.display = 'none';
// Ensure the accessibility hierarchy is regenerated.
touchAccessibilityTree(axWebArea);
shouldBe("paragraphNotificationCount", "globalNotificationCount");
shouldBe("globalNotificationCount", "2");
if (window.accessibilityController) {
paragraph.removeNotificationListener();
accessibilityController.removeNotificationListener();
}
finishJSTest();
}, 0);
}
runTest();
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>