haikuwebkit/LayoutTests/accessibility/img-alt-attribute-unassigne...

43 lines
1.7 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="../resources/accessibility-helper.js"></script>
</head>
<body id="body">
<div tabindex="0" role="group" id="images">
<img alt="cake0" src="resources/cake.png" /><br />
<img alt class="cake1 unassigned-alt" src="resources/cake.png" /><br />
Empty alt attribute does not ignore the image for accessibility clients in Safari. https://bugs.webkit.org/show_bug.cgi?id=212432 Source/WebCore: Reviewed by Chris Fleizach. Test: accessibility/img-alt-attribute-unassigned-empty.html - AccessibilityRenderObject::computeAccessibilityIsIgnored was handling the case of images too late, after checking for ariaRoleAttribute(). So if an image had a role attribute, it was exposed regardless whether its alt attribute was an empty string. This change moves the handling of images above the check for ariaroleAttribute and hence honors the empty alt attribute rule. - Also images that have an aria-label attribute are now exposed. - Added logging of AccessibilityObjectInclusion. - Changed signature of log(RefPtr<AXCoreObject>) as pointed out by Darin Adler in a separate review. * accessibility/AXLogger.cpp: (WebCore::AXLogger::log): (WebCore::operator<<): * accessibility/AXLogger.h: * accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::determineAccessibilityRole): (WebCore::AccessibilityNodeObject::isImage const): Moved to base class. * accessibility/AccessibilityNodeObject.h: * accessibility/AccessibilityObject.h: * accessibility/AccessibilityObjectInterface.h: (WebCore::AXCoreObject::isImage const): * accessibility/AccessibilityRenderObject.cpp: (WebCore::objectInclusionFromAltText): (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const): (WebCore::AccessibilityRenderObject::determineAccessibilityRole): (WebCore::AccessibilityRenderObject::updateRoleAfterChildrenCreation): * accessibility/isolatedtree/AXIsolatedObject.cpp: (WebCore::AXIsolatedObject::initializeAttributeData): * accessibility/isolatedtree/AXIsolatedObject.h: LayoutTests: <rdar://problem/60597768> Reviewed by Chris Fleizach. * accessibility/img-alt-attribute-unassigned-empty-expected.txt: Renamed from LayoutTests/accessibility/img-alt-attribute-unassigned-value-expected.txt. * accessibility/img-alt-attribute-unassigned-empty.html: Renamed from LayoutTests/accessibility/img-alt-attribute-unassigned-value.html. Added the test case for alt="" in addition to unassigned alt. * accessibility/self-referencing-aria-labelledby.html: Removed unnecessary alt="" since now that causes the image element not to be exposed. Canonical link: https://commits.webkit.org/225283@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262224 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-27 23:41:22 +00:00
<img alt="" class="cake1 empty-alt" src="resources/cake.png" /><br />
<img alt="cake2" src="resources/cake.png" /><br />
</div>
<p id="description"></p>
<div id="console"></div>
<script>
description(
Empty alt attribute does not ignore the image for accessibility clients in Safari. https://bugs.webkit.org/show_bug.cgi?id=212432 Source/WebCore: Reviewed by Chris Fleizach. Test: accessibility/img-alt-attribute-unassigned-empty.html - AccessibilityRenderObject::computeAccessibilityIsIgnored was handling the case of images too late, after checking for ariaRoleAttribute(). So if an image had a role attribute, it was exposed regardless whether its alt attribute was an empty string. This change moves the handling of images above the check for ariaroleAttribute and hence honors the empty alt attribute rule. - Also images that have an aria-label attribute are now exposed. - Added logging of AccessibilityObjectInclusion. - Changed signature of log(RefPtr<AXCoreObject>) as pointed out by Darin Adler in a separate review. * accessibility/AXLogger.cpp: (WebCore::AXLogger::log): (WebCore::operator<<): * accessibility/AXLogger.h: * accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::determineAccessibilityRole): (WebCore::AccessibilityNodeObject::isImage const): Moved to base class. * accessibility/AccessibilityNodeObject.h: * accessibility/AccessibilityObject.h: * accessibility/AccessibilityObjectInterface.h: (WebCore::AXCoreObject::isImage const): * accessibility/AccessibilityRenderObject.cpp: (WebCore::objectInclusionFromAltText): (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const): (WebCore::AccessibilityRenderObject::determineAccessibilityRole): (WebCore::AccessibilityRenderObject::updateRoleAfterChildrenCreation): * accessibility/isolatedtree/AXIsolatedObject.cpp: (WebCore::AXIsolatedObject::initializeAttributeData): * accessibility/isolatedtree/AXIsolatedObject.h: LayoutTests: <rdar://problem/60597768> Reviewed by Chris Fleizach. * accessibility/img-alt-attribute-unassigned-empty-expected.txt: Renamed from LayoutTests/accessibility/img-alt-attribute-unassigned-value-expected.txt. * accessibility/img-alt-attribute-unassigned-empty.html: Renamed from LayoutTests/accessibility/img-alt-attribute-unassigned-value.html. Added the test case for alt="" in addition to unassigned alt. * accessibility/self-referencing-aria-labelledby.html: Removed unnecessary alt="" since now that causes the image element not to be exposed. Canonical link: https://commits.webkit.org/225283@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262224 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-27 23:41:22 +00:00
'This tests that img elements with an alt attribute and no assigned value, or an empty alt value, are ignored.',
);
if (window.accessibilityController) {
document.getElementById('images').focus();
var imagesGroup = accessibilityController.focusedElement;
Empty alt attribute does not ignore the image for accessibility clients in Safari. https://bugs.webkit.org/show_bug.cgi?id=212432 Source/WebCore: Reviewed by Chris Fleizach. Test: accessibility/img-alt-attribute-unassigned-empty.html - AccessibilityRenderObject::computeAccessibilityIsIgnored was handling the case of images too late, after checking for ariaRoleAttribute(). So if an image had a role attribute, it was exposed regardless whether its alt attribute was an empty string. This change moves the handling of images above the check for ariaroleAttribute and hence honors the empty alt attribute rule. - Also images that have an aria-label attribute are now exposed. - Added logging of AccessibilityObjectInclusion. - Changed signature of log(RefPtr<AXCoreObject>) as pointed out by Darin Adler in a separate review. * accessibility/AXLogger.cpp: (WebCore::AXLogger::log): (WebCore::operator<<): * accessibility/AXLogger.h: * accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::determineAccessibilityRole): (WebCore::AccessibilityNodeObject::isImage const): Moved to base class. * accessibility/AccessibilityNodeObject.h: * accessibility/AccessibilityObject.h: * accessibility/AccessibilityObjectInterface.h: (WebCore::AXCoreObject::isImage const): * accessibility/AccessibilityRenderObject.cpp: (WebCore::objectInclusionFromAltText): (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const): (WebCore::AccessibilityRenderObject::determineAccessibilityRole): (WebCore::AccessibilityRenderObject::updateRoleAfterChildrenCreation): * accessibility/isolatedtree/AXIsolatedObject.cpp: (WebCore::AXIsolatedObject::initializeAttributeData): * accessibility/isolatedtree/AXIsolatedObject.h: LayoutTests: <rdar://problem/60597768> Reviewed by Chris Fleizach. * accessibility/img-alt-attribute-unassigned-empty-expected.txt: Renamed from LayoutTests/accessibility/img-alt-attribute-unassigned-value-expected.txt. * accessibility/img-alt-attribute-unassigned-empty.html: Renamed from LayoutTests/accessibility/img-alt-attribute-unassigned-value.html. Added the test case for alt="" in addition to unassigned alt. * accessibility/self-referencing-aria-labelledby.html: Removed unnecessary alt="" since now that causes the image element not to be exposed. Canonical link: https://commits.webkit.org/225283@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262224 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-27 23:41:22 +00:00
// there are 4 images, but one has an alt attribute that is unassigned and another has an empty alt, so it should be
// ignored. as a result, the image count is 2.
shouldBe('imagesGroup.childrenCount', '2');
// make sure alt text is being read before and after
shouldBeEqualToString(
'platformValueForW3CName(imagesGroup.childAtIndex(0))',
'cake0',
);
shouldBeEqualToString(
'platformValueForW3CName(imagesGroup.childAtIndex(1))',
'cake2',
);
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>