Web Inspector: AXI: Audit: image label test is throwing spurious errors on elements...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jun 2019 16:42:39 +0000 (16:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jun 2019 16:42:39 +0000 (16:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194754
<rdar://problem/48144534>

Patch by Greg Doolittle <gr3g@apple.com> on 2019-06-11
Reviewed by Chris Fleizach.

Source/WebCore:

Tests: accessibility/img-alt-attribute-empty-string.html
       accessibility/img-alt-attribute-no-value.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::computedRoleString const):

LayoutTests:

* accessibility/img-alt-attribute-empty-string-expected.txt: Added.
* accessibility/img-alt-attribute-empty-string.html: Added.
* accessibility/img-alt-attribute-no-value-expected.txt: Added.
* accessibility/img-alt-attribute-no-value.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246320 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/img-alt-attribute-empty-string-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/img-alt-attribute-empty-string.html [new file with mode: 0644]
LayoutTests/accessibility/img-alt-attribute-no-value-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/img-alt-attribute-no-value.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp

index a7eb1a6..ae700c1 100644 (file)
@@ -1,3 +1,16 @@
+2019-06-11  Greg Doolittle  <gr3g@apple.com>
+
+        Web Inspector: AXI: Audit: image label test is throwing spurious errors on elements with existing alt attr, but no value: <img alt>
+        https://bugs.webkit.org/show_bug.cgi?id=194754
+        <rdar://problem/48144534>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/img-alt-attribute-empty-string-expected.txt: Added.
+        * accessibility/img-alt-attribute-empty-string.html: Added.
+        * accessibility/img-alt-attribute-no-value-expected.txt: Added.
+        * accessibility/img-alt-attribute-no-value.html: Added.
+
 2019-06-11  Shawn Roberts  <sroberts@apple.com>
 
         http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html is a flaky failure and timeout
diff --git a/LayoutTests/accessibility/img-alt-attribute-empty-string-expected.txt b/LayoutTests/accessibility/img-alt-attribute-empty-string-expected.txt
new file mode 100644 (file)
index 0000000..29d0074
--- /dev/null
@@ -0,0 +1,15 @@
+
+
+
+This tests that img elements with alt attribute of empty string are ignored.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS imagesGroup.childrenCount is 2
+PASS platformValueForW3CName(imagesGroup.childAtIndex(0)) is "cake"
+PASS platformValueForW3CName(imagesGroup.childAtIndex(1)) is "more cake"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/img-alt-attribute-empty-string.html b/LayoutTests/accessibility/img-alt-attribute-empty-string.html
new file mode 100644 (file)
index 0000000..e691573
--- /dev/null
@@ -0,0 +1,38 @@
+<!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="cake" src="resources/cake.png"><br>
+    <img alt="" src="resources/cake.png" class="empty-string"><br>
+    <img alt="more cake" src="resources/cake.png"><br>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that img elements with alt attribute of empty string are ignored.");
+
+    if (window.accessibilityController) {
+
+        document.getElementById("images").focus();
+        var imagesGroup = accessibilityController.focusedElement;
+        // <img alt="" /> should be ignored, so the count should be 2:
+        shouldBe("imagesGroup.childrenCount", "2"); 
+        // make sure alt text is being read before and after
+        shouldBeEqualToString("platformValueForW3CName(imagesGroup.childAtIndex(0))", "cake");
+        shouldBeEqualToString("platformValueForW3CName(imagesGroup.childAtIndex(1))", "more cake");
+    }
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
+
diff --git a/LayoutTests/accessibility/img-alt-attribute-no-value-expected.txt b/LayoutTests/accessibility/img-alt-attribute-no-value-expected.txt
new file mode 100644 (file)
index 0000000..392d42a
--- /dev/null
@@ -0,0 +1,16 @@
+
+
+
+
+This tests that img elements with an alt attribute and no assigned value are ignored.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS imagesGroup.childrenCount is 2
+PASS platformValueForW3CName(imagesGroup.childAtIndex(0)) is "cake0"
+PASS platformValueForW3CName(imagesGroup.childAtIndex(1)) is "cake3"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/img-alt-attribute-no-value.html b/LayoutTests/accessibility/img-alt-attribute-no-value.html
new file mode 100644 (file)
index 0000000..73bd741
--- /dev/null
@@ -0,0 +1,44 @@
+<!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="unassigned-alt cake1" src="resources/cake.png"><br>
+    <img class="no-alt cake2" src="resources/cake.png"><br>
+    <img alt="cake3" src="resources/cake.png"><br>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+description("This tests that img elements with an alt attribute and no assigned value are ignored.");
+if (window.accessibilityController) {
+    document.getElementById("images").focus();
+    var imagesGroup = accessibilityController.focusedElement;
+    // there are 4 images, but one has an alt attribute that is unassigned so it should be
+    // ignored. there is a second image without any alt attribute at all. this image should
+    // not be ignored. accessibilityController fails to recognize it. this has been
+    // documented in <rdar://problem/51283943>.
+    // as a result the image count is 2, but it should be 3.
+    shouldBe("imagesGroup.childrenCount", "2");
+    // make sure alt text is being read before and after
+    shouldBeEqualToString("platformValueForW3CName(imagesGroup.childAtIndex(0))", "cake0");
+    // accessiblityController should see the <img> element w/o alt attribute as an image,
+    // but it erroneously classifies it as presentation.. so it won't find the image and use the filename as alt text
+    // shouldBeEqualToString("platformValueForW3CName(imagesGroup.childAtIndex(2))", "cake.png");
+    shouldBeEqualToString("platformValueForW3CName(imagesGroup.childAtIndex(1))", "cake3");
+}
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
+
index 417520a..5b234e8 100644 (file)
@@ -1,3 +1,17 @@
+2019-06-11  Greg Doolittle  <gr3g@apple.com>
+
+        Web Inspector: AXI: Audit: image label test is throwing spurious errors on elements with existing alt attr, but no value: <img alt>
+        https://bugs.webkit.org/show_bug.cgi?id=194754
+        <rdar://problem/48144534>
+
+        Reviewed by Chris Fleizach.
+
+        Tests: accessibility/img-alt-attribute-empty-string.html
+               accessibility/img-alt-attribute-no-value.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::computedRoleString const):
+
 2019-06-11  Sihui Liu  <sihui_liu@apple.com>
 
         Add a quirk for washingtonpost.com and nytimes.com
index 56cb15b..541acce 100644 (file)
@@ -2493,6 +2493,9 @@ String AccessibilityObject::computedRoleString() const
     // FIXME: Need a few special cases that aren't in the RoleMap: option, etc. http://webkit.org/b/128296
     AccessibilityRole role = roleValue();
 
+    if (accessibilityIsIgnored())
+        return reverseAriaRoleMap().get(static_cast<int>(AccessibilityRole::Presentational));
+
     // We do not compute a role string for generic block elements with user-agent assigned roles.
     if (role == AccessibilityRole::Group || role == AccessibilityRole::TextGroup)
         return "";