AX: role=treeitem accessible name not spoken to VoiceOver macOS when using string...
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 00:11:00 +0000 (00:11 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 00:11:00 +0000 (00:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164950
<rdar://problem/29337573>

Reviewed by Chris Fleizach.

Source/WebCore:

From the spec: https://www.w3.org/TR/wai-aria-practices/#TreeView
The element with role treeitem missing a label is labeled by its child elements.

Test: accessibility/mac/aria-tree-item-name.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::alternativeText):

LayoutTests:

* accessibility/mac/aria-tree-item-name-expected.txt: Added.
* accessibility/mac/aria-tree-item-name.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/mac/aria-tree-item-name-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/aria-tree-item-name.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp

index 514df0e..7f7a07d 100644 (file)
@@ -1,3 +1,14 @@
+2017-01-11  Nan Wang  <n_wang@apple.com>
+
+        AX: role=treeitem accessible name not spoken to VoiceOver macOS when using string contained inside element
+        https://bugs.webkit.org/show_bug.cgi?id=164950
+        <rdar://problem/29337573>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/aria-tree-item-name-expected.txt: Added.
+        * accessibility/mac/aria-tree-item-name.html: Added.
+
 2017-01-11  Myles C. Maxfield  <mmaxfield@apple.com>
 
         ASSERTION FAILED: run->m_stop > 0 in *WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment
diff --git a/LayoutTests/accessibility/mac/aria-tree-item-name-expected.txt b/LayoutTests/accessibility/mac/aria-tree-item-name-expected.txt
new file mode 100644 (file)
index 0000000..d2d9693
--- /dev/null
@@ -0,0 +1,17 @@
+Release Notes
+Power Search
+Power Search
+item 2
+
+This tests that name calculation is correct for treeitems.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS item0.description is 'AXDescription: Release Notes'
+PASS item1.description is 'AXDescription: item 1'
+PASS item2.description is 'AXDescription: item 2'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/aria-tree-item-name.html b/LayoutTests/accessibility/mac/aria-tree-item-name.html
new file mode 100644 (file)
index 0000000..ab357d5
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<ul id="tree" role="tree" aria-label="Help Topics">
+  <li id="item0" role="treeitem" aria-expanded="true">Release Notes
+    <ul role="group">
+      <li id="item1" role="treeitem" aria-label="item 1">Power Search</li>
+      <li id="item2" role="treeitem" aria-labelledby="label">Power Search</li>
+    </ul>
+  </li>
+</ul>
+
+<p id="label">item 2</p>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that name calculation is correct for treeitems.");
+
+    if (window.accessibilityController) {
+    
+          // Treeitems missing a label are labeled by child elements.
+          var item0 = accessibilityController.accessibleElementById("item0");
+          shouldBe("item0.description", "'AXDescription: Release Notes'");
+          
+          // aria-label case.
+          var item1 = accessibilityController.accessibleElementById("item1");
+          shouldBe("item1.description", "'AXDescription: item 1'");
+          
+          // aria-labelledby case.
+          var item2 = accessibilityController.accessibleElementById("item2");
+          shouldBe("item2.description", "'AXDescription: item 2'");
+    }
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index e1fcdd8..705e6e6 100644 (file)
@@ -1,3 +1,19 @@
+2017-01-11  Nan Wang  <n_wang@apple.com>
+
+        AX: role=treeitem accessible name not spoken to VoiceOver macOS when using string contained inside element
+        https://bugs.webkit.org/show_bug.cgi?id=164950
+        <rdar://problem/29337573>
+
+        Reviewed by Chris Fleizach.
+
+        From the spec: https://www.w3.org/TR/wai-aria-practices/#TreeView
+        The element with role treeitem missing a label is labeled by its child elements.
+
+        Test: accessibility/mac/aria-tree-item-name.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::alternativeText):
+
 2017-01-11  Brent Fulgham  <bfulgham@apple.com>
 
         [GTK] Unreviewed build fix after r210600.
index 06259c0..2b0e46d 100644 (file)
@@ -1363,6 +1363,10 @@ void AccessibilityNodeObject::alternativeText(Vector<AccessibilityText>& textOrd
             textOrder.append(AccessibilityText(accessibleNameForNode(captionForFigure->node()), AlternativeText));
     }
     
+    // Tree items missing a label are labeled by all child elements.
+    if (isTreeItem() && ariaLabel.isEmpty() && ariaLabeledByAttribute().isEmpty())
+        textOrder.append(AccessibilityText(accessibleNameForNode(node), AlternativeText));
+    
 #if ENABLE(MATHML)
     if (node->isMathMLElement())
         textOrder.append(AccessibilityText(getAttribute(MathMLNames::alttextAttr), AlternativeText));