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>
Thu, 20 Jun 2019 22:06:51 +0000 (22:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jun 2019 22:06:51 +0000 (22:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194754

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

Source/WebCore:

Test: accessibility/img-alt-attribute-unassigned-value.html

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

LayoutTests:

* accessibility/img-alt-attribute-unassigned-value-expected.txt: Added.
* accessibility/img-alt-attribute-unassigned-value.html: Added.
* inspector/dom/getAccessibilityPropertiesForNode-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/accessibility/img-alt-attribute-unassigned-value-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/img-alt-attribute-unassigned-value.html [new file with mode: 0644]
LayoutTests/inspector/dom/getAccessibilityPropertiesForNode-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp

index 47c6893..cb6c98e 100644 (file)
@@ -1,3 +1,14 @@
+2019-06-20  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
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/img-alt-attribute-unassigned-value-expected.txt: Added.
+        * accessibility/img-alt-attribute-unassigned-value.html: Added.
+        * inspector/dom/getAccessibilityPropertiesForNode-expected.txt:
+
 2019-06-20  Saam Barati  <sbarati@apple.com>
 
         [WHLSL] Property resolver needs to recurse on newValueExpression for RMW operations
diff --git a/LayoutTests/accessibility/img-alt-attribute-unassigned-value-expected.txt b/LayoutTests/accessibility/img-alt-attribute-unassigned-value-expected.txt
new file mode 100644 (file)
index 0000000..9182a28
--- /dev/null
@@ -0,0 +1,15 @@
+
+
+
+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 "cake2"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/img-alt-attribute-unassigned-value.html b/LayoutTests/accessibility/img-alt-attribute-unassigned-value.html
new file mode 100644 (file)
index 0000000..dd19b7e
--- /dev/null
@@ -0,0 +1,41 @@
+<!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>
+    <img alt="cake2" 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 3 images, but one has an alt attribute that is unassigned, 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");
+    // accessiblityController should see the <img> element w/o alt attribute as an image,
+    // and use the filename as the alt text. currently it returns an empty string.
+    // this issue is documented here: <rdar://problem/51669261>
+    // shouldBeEqualToString("platformValueForW3CName(imagesGroup.childAtIndex(1))", "cake.png");
+    shouldBeEqualToString("platformValueForW3CName(imagesGroup.childAtIndex(1))", "cake2");
+}
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
+
index 9efa3ee..3250199 100644 (file)
@@ -326,7 +326,7 @@ Total elements to be tested: 122.
 <img src="data:image/gif..." alt="x" aria-hidden="true">
     exists: true
     label: x
-    role: img
+    role: presentation
     ignored: true
     ignoredByDefault: true
     hidden: true
@@ -339,7 +339,7 @@ Total elements to be tested: 122.
 <img src="data:image/gif..." alt="">
     exists: true
     label: 
-    role: img
+    role: presentation
     ignored: true
 
 <img src="data:image/gif...">
@@ -350,7 +350,7 @@ Total elements to be tested: 122.
 <img src="./404.gif">
     exists: true
     label: 
-    role: img
+    role: presentation
     ignored: true
 
 <input style="display:none;">
@@ -361,7 +361,7 @@ Total elements to be tested: 122.
 <input aria-hidden="true">
     exists: true
     label: 
-    role: 
+    role: presentation
     focused: false
     ignored: true
     ignoredByDefault: true
@@ -906,7 +906,7 @@ Total elements to be tested: 122.
 <span aria-hidden="true"></span>
     exists: true
     label: 
-    role: 
+    role: presentation
     ignored: true
     ignoredByDefault: true
     hidden: true
@@ -915,7 +915,7 @@ Total elements to be tested: 122.
 <span></span>
     exists: true
     label: 
-    role: 
+    role: presentation
     ignored: true
     ignoredByDefault: true
     parentNodeId: exists
@@ -923,7 +923,7 @@ Total elements to be tested: 122.
 <div aria-hidden="true"></div>
     exists: true
     label: 
-    role: 
+    role: presentation
     ignored: true
     ignoredByDefault: true
     hidden: true
@@ -932,7 +932,7 @@ Total elements to be tested: 122.
 <div></div>
     exists: true
     label: 
-    role: 
+    role: presentation
     ignored: true
     parentNodeId: exists
 
@@ -961,14 +961,14 @@ Total elements to be tested: 122.
 <div><div></div></div>
     exists: true
     label: 
-    role: 
+    role: presentation
     ignored: true
     parentNodeId: exists
 
 <script style="display:block;"></script>
     exists: true
     label: 
-    role: 
+    role: presentation
     ignored: true
     parentNodeId: exists
 
index 62eeb84..3ab049d 100644 (file)
@@ -1,3 +1,15 @@
+2019-06-20  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
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/img-alt-attribute-unassigned-value.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::computedRoleString const):
+
 2019-06-20  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(r245912): Crash in TextIterator::range via visiblePositionForIndexUsingCharacterIterator
index 89603df..0b33d28 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 (role == AccessibilityRole::Image && 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 "";