AX: aria-label not being used correctly in accessible name calculation of heading
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jul 2016 23:47:53 +0000 (23:47 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jul 2016 23:47:53 +0000 (23:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160009

Reviewed by Chris Fleizach.

Source/WebCore:

Actually we are exposing the correct information for heading objects. On macOS,
VoiceOver should handle the logic that picks the right information to speak.
On iOS, VoiceOver is speaking the static text child instead of the heading object.
So we should set the accessibilityLabel of the static text based on the parent's
alternate label.

Test: accessibility/ios-simulator/heading-with-aria-label.html

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper _accessibilityTraitsFromAncestors]):

LayoutTests:

* accessibility/ios-simulator/heading-with-aria-label-expected.txt: Added.
* accessibility/ios-simulator/heading-with-aria-label.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/ios-simulator/heading-with-aria-label-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/heading-with-aria-label.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm

index 5d6b76d..48a1e3d 100644 (file)
@@ -1,3 +1,13 @@
+2016-07-21  Nan Wang  <n_wang@apple.com>
+
+        AX: aria-label not being used correctly in accessible name calculation of heading
+        https://bugs.webkit.org/show_bug.cgi?id=160009
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ios-simulator/heading-with-aria-label-expected.txt: Added.
+        * accessibility/ios-simulator/heading-with-aria-label.html: Added.
+
 2016-07-21  Ryan Haddad  <ryanhaddad@apple.com>
 
         Move expected.txt file for editing/deleting/delete-emoji.html from mac-elcapitan to mac-yosemite
diff --git a/LayoutTests/accessibility/ios-simulator/heading-with-aria-label-expected.txt b/LayoutTests/accessibility/ios-simulator/heading-with-aria-label-expected.txt
new file mode 100644 (file)
index 0000000..26dcd32
--- /dev/null
@@ -0,0 +1,13 @@
+visible text visible text
+This tests that if heading has aria-label, it will override the visible text as necessary.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS heading1Text.traits == heading2Text.traits is true
+PASS heading1Text.description is 'AXLabel: test label'
+PASS heading2Text.description is 'AXLabel: visible text'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/heading-with-aria-label.html b/LayoutTests/accessibility/ios-simulator/heading-with-aria-label.html
new file mode 100644 (file)
index 0000000..23e1eb6
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+var successfullyParsed = false;
+</script>
+</head>
+<body id="body">
+
+<span id="heading1" role="heading" aria-label="test label">visible text</span>
+<span id="heading2" role="heading">visible text</span>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that if heading has aria-label, it will override the visible text as necessary.");
+
+    if (window.accessibilityController) {
+
+        var heading1Text = accessibilityController.accessibleElementById("heading1").childAtIndex(0);
+        var heading2Text = accessibilityController.accessibleElementById("heading2").childAtIndex(0);
+        
+        // Get the trait so that the label will be set.
+        shouldBeTrue("heading1Text.traits == heading2Text.traits");
+        
+        shouldBe("heading1Text.description", "'AXLabel: test label'");
+        shouldBe("heading2Text.description", "'AXLabel: visible text'");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
index c38f51f..9d4cd24 100644 (file)
@@ -1,3 +1,21 @@
+2016-07-21  Nan Wang  <n_wang@apple.com>
+
+        AX: aria-label not being used correctly in accessible name calculation of heading
+        https://bugs.webkit.org/show_bug.cgi?id=160009
+
+        Reviewed by Chris Fleizach.
+
+        Actually we are exposing the correct information for heading objects. On macOS, 
+        VoiceOver should handle the logic that picks the right information to speak.
+        On iOS, VoiceOver is speaking the static text child instead of the heading object.
+        So we should set the accessibilityLabel of the static text based on the parent's 
+        alternate label.
+
+        Test: accessibility/ios-simulator/heading-with-aria-label.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper _accessibilityTraitsFromAncestors]):
+
 2016-07-21  Saam Barati  <sbarati@apple.com>
 
         op_add/ValueAdd should be an IC in all JIT tiers
index 894da9f..d33ae5a 100644 (file)
@@ -598,8 +598,15 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
                 // to the heading level. If it was a static text element, we need to store
                 // the value as the label, because the heading level needs to the value.
                 AccessibilityObjectWrapper* wrapper = parent->wrapper();
-                if (role == StaticTextRole) 
-                    [self setAccessibilityLabel:m_object->stringValue()];                
+                if (role == StaticTextRole) {
+                    // We should only set the text value as the label when there's no
+                    // alternate text on the heading parent.
+                    NSString *headingLabel = [wrapper accessibilityLabel];
+                    if (![headingLabel length])
+                        [self setAccessibilityLabel:m_object->stringValue()];
+                    else
+                        [self setAccessibilityLabel:headingLabel];
+                }
                 [self setAccessibilityValue:[wrapper accessibilityValue]];
                 break;
             }