haikuwebkit/LayoutTests/accessibility/ios-simulator/img-with-svg-source.html

52 lines
2.5 KiB
HTML
Raw Permalink Normal View History

AX: @alt and bounds ignored when using img[src] points to an inaccessible SVG https://bugs.webkit.org/show_bug.cgi?id=160705 <rdar://problem/27771579> Reviewed by Chris Fleizach and Darin Adler. Source/WebCore: Tests: accessibility/img-with-svg-source.html accessibility/ios-simulator/img-with-svg-source.html The problem was caused by AccessibilityRenderObject::determineAccessibilityRole that was returning AccessibilityRole::SVGRoot for all images with a remote SVG source, regardless whether the SVG hierarchy contained some accessibility data or not. This resulted in VoiceOver reading the image like an empty group on Mac, or completely ignoring the image on iOS. The solution in this patch is to only return AccessibilityRole::SVGRoot if the SVG has some accessibility conveyable data. Added the method AccessibilitySVGRoot::hasAccessibleContent for this purpose. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::determineAccessibilityRole): (WebCore::AccessibilityRenderObject::remoteSVGRootElement const): Comment was missplaced, moved it to the right place. (WebCore::AccessibilityRenderObject::addRemoteSVGChildren): * accessibility/AccessibilitySVGRoot.cpp: (WebCore::AccessibilitySVGRoot::hasAccessibleContent const): * accessibility/AccessibilitySVGRoot.h: LayoutTests: * accessibility/img-with-svg-source-expected.txt: Added. * accessibility/img-with-svg-source.html: Added. * accessibility/ios-simulator/img-with-svg-source-expected.txt: Added. * accessibility/ios-simulator/img-with-svg-source.html: Added. * accessibility/svg-shape-labelled-expected.txt: * accessibility/svg-shape-labelled.html: Removed the <img> test cases since they are covered correctly in the new test img-with-svg-source.html. Canonical link: https://commits.webkit.org/233302@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271796 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-25 16:52:52 +00:00
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<style>img {background-color: #000;}</style>
<script src="../../resources/js-test-pre.js"></script>
<script src="../../resources/accessibility-helper.js"></script>
</head>
<!-- This test must run when all remote resources (SVG images) are loaded.
Thus add an onload event listener to body and run the test there. -->
<body onload="runTest()">
<!-- Used as baseline for an image traits. -->
<img id="pngImage1" src="../resources/cake.png" alt="1. png image">
<!-- Used as baseline for an image in an anchor traits. -->
<a href="https://apple.com"><img id="pngImage2" src="../resources/cake.png" alt="2. png image"></a>
<img id="image1" src="../resources/apple-logo.svg">
<img id="image2" src="../resources/apple-logo.svg" alt="2. svg image with alt text">
<img id="image3" role="img" src="../resources/apple-logo.svg" alt="3. svg image with role img" and alt text">
<a href="https://apple.com"><img id="image4" src="../resources/apple-logo.svg" alt="4. svg image in an anchor"></a>
<a href="https://apple.com"><img id="image5" role="img" src="../resources/apple-logo.svg" alt="5. svg image with role img in an anchor"></a>
<img id="image6" src="../resources/apple-logo.svg" aria-label="6. svg image with aria label">
<img id="image7" role="img" src="../resources/apple-logo.svg" aria-label="7. svg image with role img and aria label">
<img id="image8" src="../resources/apple-logo.svg" alt="8. svg image with size set" style="height: 200px; width: 200px;">
<img id="image9" role="img" src="../resources/apple-logo.svg" alt="9. svg image with role img and size set" style="height: 200px; width: 200px;">
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that images with SVG source are indeed exposed as images and not as SVG groups, if the SVG source is not accessible.");
function runTest() {
if (window.accessibilityController) {
pngImage1 = accessibilityController.accessibleElementById("pngImage1");
pngImage2 = accessibilityController.accessibleElementById("pngImage2");
for (i = 1; i < 10; ++i) {
image = accessibilityController.accessibleElementById("image" + i);
if (i < 4 || i > 5)
shouldBe("image.traits", "pngImage1.traits");
else
shouldBe("image.traits", "pngImage2.traits");
}
}
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>