AX: Several ARIA roles with presentational children are exposing children
authorjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2017 21:51:04 +0000 (21:51 +0000)
committerjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2017 21:51:04 +0000 (21:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177502

Reviewed by Chris Fleizach.

Source/WebCore:

Add MenuItemCheckboxRole, MenuItemRadioRole, and SplitterRole to the list
of AccessibilityRole types which cannot have children. In the case of
DocumentMathRole, only treat children as presentational (excluded from the
accessibility tree) if the element is not MathML.

Test: accessibility/presentational-children.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::canHaveChildren const):

LayoutTests:

* accessibility/presentational-children-expected.txt: Added.
* accessibility/presentational-children.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/presentational-children-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/presentational-children.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp

index aae6c0c..8413e79 100644 (file)
@@ -1,3 +1,13 @@
+2017-09-26  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: Several ARIA roles with presentational children are exposing children
+        https://bugs.webkit.org/show_bug.cgi?id=177502
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/presentational-children-expected.txt: Added.
+        * accessibility/presentational-children.html: Added.
+
 2017-09-26  Megan Gardner  <megan_gardner@apple.com>
 
         Add helper functions to write better selection tests
diff --git a/LayoutTests/accessibility/presentational-children-expected.txt b/LayoutTests/accessibility/presentational-children-expected.txt
new file mode 100644 (file)
index 0000000..d5c7a19
--- /dev/null
@@ -0,0 +1,23 @@
+This tests that roles with children presentational true report no children.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+button childrenCount: 0
+checkbox childrenCount: 0
+img childrenCount: 0
+math childrenCount: 0
+menuitemcheckbox childrenCount: 0
+menuitemradio childrenCount: 0
+option childrenCount: 0
+progressbar childrenCount: 0
+radio childrenCount: 0
+scrollbar childrenCount: 0
+separator childrenCount: 0
+slider childrenCount: 0
+switch childrenCount: 0
+tab childrenCount: 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/presentational-children.html b/LayoutTests/accessibility/presentational-children.html
new file mode 100644 (file)
index 0000000..02e6da4
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<div id="content">
+  <div role="button" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="checkbox" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="img" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="math" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="menu">
+    <div role="menuitemcheckbox" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+    <div role="menuitemradio" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  </div>
+  <div role="listbox">
+    <div role="option" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  </div>
+  <div role="progressbar" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="radio" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="scrollbar" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="separator" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="slider" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="switch" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  <div role="tablist">
+    <div role="tab" tabindex="0" class="ex"><div>a</div><div>b</div></div>
+  </div>
+</div>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests that roles with children presentational true report no children.");
+    if (window.accessibilityController) {
+        var elements = document.querySelectorAll(".ex");
+        var count = elements.length;
+        for (var i = 0; i < count; i++) {
+           var el = elements[i];
+            el.focus();
+            debug(el.getAttribute("role") + " childrenCount: " + accessibilityController.focusedElement.childrenCount);
+        }
+        document.getElementById("content").style.visibility = "hidden";
+    }
+</script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index e1e9637..2b6a5c0 100644 (file)
@@ -1,3 +1,20 @@
+2017-09-26  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: Several ARIA roles with presentational children are exposing children
+        https://bugs.webkit.org/show_bug.cgi?id=177502
+
+        Reviewed by Chris Fleizach.
+
+        Add MenuItemCheckboxRole, MenuItemRadioRole, and SplitterRole to the list
+        of AccessibilityRole types which cannot have children. In the case of
+        DocumentMathRole, only treat children as presentational (excluded from the
+        accessibility tree) if the element is not MathML.
+
+        Test: accessibility/presentational-children.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::canHaveChildren const):
+
 2017-09-26  Basuke Suzuki  <Basuke.Suzuki@sony.com>
 
         [Curl] Introduce CurlResponse to hold response information among threads.
index 696e18d..165d975 100644 (file)
@@ -382,6 +382,14 @@ bool AccessibilityNodeObject::canHaveChildren() const
     case ScrollBarRole:
     case ProgressIndicatorRole:
     case SwitchRole:
+    case MenuItemCheckboxRole:
+    case MenuItemRadioRole:
+    case SplitterRole:
+        return false;
+    case DocumentMathRole:
+#if ENABLE(MATHML)
+        return node()->isMathMLElement();
+#endif
         return false;
     default:
         return true;