Title: [293345] trunk
Revision
293345
Author
cfleiz...@apple.com
Date
2022-04-25 13:49:06 -0700 (Mon, 25 Apr 2022)

Log Message

AX: Don't expose aria-roledescription value on "generic" elements (e.g. div and span) unless explicit role value is also defined
https://bugs.webkit.org/show_bug.cgi?id=174248
<rdar://problem/33178050>

Reviewed by Andres Gonzalez.

Source/WebCore:

ARIA spec states to not expose the role description on "generic" elements.
https://www.w3.org/TR/wai-aria/#aria-roledescription

Test: accessibility/ignored-aria-role-description.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::supportsARIARoleDescription const):
(WebCore::AccessibilityObject::roleDescription const):
* accessibility/AccessibilityObject.h:

LayoutTests:

* accessibility/ignored-aria-role-description-expected.txt: Added.
* accessibility/ignored-aria-role-description.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293344 => 293345)


--- trunk/LayoutTests/ChangeLog	2022-04-25 20:48:11 UTC (rev 293344)
+++ trunk/LayoutTests/ChangeLog	2022-04-25 20:49:06 UTC (rev 293345)
@@ -1,3 +1,14 @@
+2022-04-25  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Don't expose aria-roledescription value on "generic" elements (e.g. div and span) unless explicit role value is also defined
+        https://bugs.webkit.org/show_bug.cgi?id=174248
+        <rdar://problem/33178050>
+
+        Reviewed by Andres Gonzalez.
+
+        * accessibility/ignored-aria-role-description-expected.txt: Added.
+        * accessibility/ignored-aria-role-description.html: Added.
+
 2022-04-25  Antti Koivisto  <an...@apple.com>
 
         [CSS Typed OM] Fix AttributeStyleMap.get for list values

Added: trunk/LayoutTests/accessibility/ignored-aria-role-description-expected.txt (0 => 293345)


--- trunk/LayoutTests/accessibility/ignored-aria-role-description-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ignored-aria-role-description-expected.txt	2022-04-25 20:49:06 UTC (rev 293345)
@@ -0,0 +1,13 @@
+This tests that generic elements are not allowed to have role descriptions.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+div role: AXRoleDescription: group
+span text role: AXRoleDescription: group
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+div
+span

Added: trunk/LayoutTests/accessibility/ignored-aria-role-description.html (0 => 293345)


--- trunk/LayoutTests/accessibility/ignored-aria-role-description.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ignored-aria-role-description.html	2022-04-25 20:49:06 UTC (rev 293345)
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<div id="content" role="group">
+<div aria-roledescription="test role">div</div>
+<span aria-roledescription="test role">span</span>
+</div>
+
+<script>
+    description("This tests that generic elements are not allowed to have role descriptions.");
+
+    if (window.accessibilityController) {
+        let output = "";
+
+        // The DIV will show up in the hierarchy, but don't allow it to have a custom role description.
+        let divRole = accessibilityController.accessibleElementById("content").childAtIndex(0);
+        // The span should NOT show up in the hierarchy (even though it has an aria role description).
+        let spanText = accessibilityController.accessibleElementById("content").childAtIndex(1);
+        
+        output += `div role: ${divRole.roleDescription}\n`;
+        output += `span text role: ${spanText.roleDescription}\n`;
+ 
+        debug(output);
+    }
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (293344 => 293345)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2022-04-25 20:48:11 UTC (rev 293344)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2022-04-25 20:49:06 UTC (rev 293345)
@@ -1859,6 +1859,7 @@
 #////////////////////////////////////////////////////////////////////////////////////////
 
 accessibility/dialog-properties.html [ Skip ]
+accessibility/ignored-aria-role-description.html [ Skip ]
 
 # These tests require platform support.
 media/media-allowed-codecs.html

Modified: trunk/LayoutTests/platform/win/TestExpectations (293344 => 293345)


--- trunk/LayoutTests/platform/win/TestExpectations	2022-04-25 20:48:11 UTC (rev 293344)
+++ trunk/LayoutTests/platform/win/TestExpectations	2022-04-25 20:49:06 UTC (rev 293345)
@@ -463,6 +463,7 @@
 
 # Probably wrong role after adding children to list (AXGroup instead of AXList).
 accessibility/list-with-dynamically-changing-content.html [ Skip ]
+accessibility/ignored-aria-role-description.html [ Skip ]
 
 # Need to implement AccessibilityUIElement::clearSelectedChildren()
 accessibility/aria-listbox-clear-selection-crash.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (293344 => 293345)


--- trunk/Source/WebCore/ChangeLog	2022-04-25 20:48:11 UTC (rev 293344)
+++ trunk/Source/WebCore/ChangeLog	2022-04-25 20:49:06 UTC (rev 293345)
@@ -1,3 +1,21 @@
+2022-04-25  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Don't expose aria-roledescription value on "generic" elements (e.g. div and span) unless explicit role value is also defined
+        https://bugs.webkit.org/show_bug.cgi?id=174248
+        <rdar://problem/33178050>
+
+        Reviewed by Andres Gonzalez.
+
+        ARIA spec states to not expose the role description on "generic" elements.
+        https://www.w3.org/TR/wai-aria/#aria-roledescription
+
+        Test: accessibility/ignored-aria-role-description.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::supportsARIARoleDescription const):
+        (WebCore::AccessibilityObject::roleDescription const):
+        * accessibility/AccessibilityObject.h:
+
 2022-04-25  Tim Nguyen  <n...@apple.com>
 
         Unprefix html.css, fullscreen.css and pdfjs-extras

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (293344 => 293345)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-04-25 20:48:11 UTC (rev 293344)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-04-25 20:49:06 UTC (rev 293345)
@@ -2704,14 +2704,29 @@
     }
 }
 
+// ARIA spec: User agents must not expose the aria-roledescription property if the element to which aria-roledescription is applied does not have a valid WAI-ARIA role or does not have an implicit WAI-ARIA role semantic.
+bool AccessibilityObject::supportsARIARoleDescription() const
+{
+    auto role = this->roleValue();
+    switch (role) {
+    case AccessibilityRole::Div:
+    case AccessibilityRole::Unknown:
+        return false;
+    default:
+        return true;
+    }
+}
+
 String AccessibilityObject::roleDescription() const
 {
     // aria-roledescription takes precedence over any other rule.
-    String roleDescription = stripLeadingAndTrailingHTMLSpaces(getAttribute(aria_roledescriptionAttr));
-    if (!roleDescription.isEmpty())
-        return roleDescription;
+    if (supportsARIARoleDescription()) {
+        auto roleDescription = stripLeadingAndTrailingHTMLSpaces(getAttribute(aria_roledescriptionAttr));
+        if (!roleDescription.isEmpty())
+            return roleDescription;
+    }
 
-    roleDescription = rolePlatformDescription();
+    auto roleDescription = rolePlatformDescription();
     if (!roleDescription.isEmpty())
         return roleDescription;
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (293344 => 293345)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2022-04-25 20:48:11 UTC (rev 293344)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2022-04-25 20:49:06 UTC (rev 293345)
@@ -298,6 +298,7 @@
     WEBCORE_EXPORT static bool isARIAControl(AccessibilityRole);
     bool supportsCheckedState() const override;
 
+    bool supportsARIARoleDescription() const;
     bool supportsARIAOwns() const override { return false; }
     bool isActiveDescendantOfFocusedContainer() const override;
     void ariaActiveDescendantReferencingElements(AccessibilityChildrenVector&) const override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to