AX: VoiceOver on iOS ignores aria-checked on menuitemradio and menuitemcheckbox
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2016 22:25:17 +0000 (22:25 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Aug 2016 22:25:17 +0000 (22:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161118

Reviewed by Chris Fleizach.

Source/WebCore:

Added checkboxOrRadioValue and toggle trait to menuitemradio and menuitemcheckbox.

Test: accessibility/ios-simulator/menuitem-checked.html

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

LayoutTests:

* accessibility/ios-simulator/menuitem-checked-expected.txt: Added.
* accessibility/ios-simulator/menuitem-checked.html: Added.

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

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

index 64fc890..5cd1c55 100644 (file)
@@ -1,3 +1,13 @@
+2016-08-24  Nan Wang  <n_wang@apple.com>
+
+        AX: VoiceOver on iOS ignores aria-checked on menuitemradio and menuitemcheckbox
+        https://bugs.webkit.org/show_bug.cgi?id=161118
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ios-simulator/menuitem-checked-expected.txt: Added.
+        * accessibility/ios-simulator/menuitem-checked.html: Added.
+
 2016-08-24  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, update expectations of iOS simulator WK1 css3 tests
diff --git a/LayoutTests/accessibility/ios-simulator/menuitem-checked-expected.txt b/LayoutTests/accessibility/ios-simulator/menuitem-checked-expected.txt
new file mode 100644 (file)
index 0000000..b7fba9d
--- /dev/null
@@ -0,0 +1,22 @@
+
+Item one
+Item two
+Item three
+Item four
+Item five
+This tests that menu items can report the right value whether it's checked.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS radio.traits != menuItem1.traits is true
+PASS menuItem1.stringValue is 'AXValue: 1'
+PASS menuItem2.stringValue is 'AXValue: 0'
+PASS menuItem1.traits == menuItem3.traits is true
+PASS menuItem3.stringValue is 'AXValue: 1'
+PASS menuItem4.stringValue is 'AXValue: 0'
+PASS menuItem5.traits != menuItem4.traits is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/menuitem-checked.html b/LayoutTests/accessibility/ios-simulator/menuitem-checked.html
new file mode 100644 (file)
index 0000000..1632f9d
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<input id="radio" type="radio" name="group">
+<div id="menuitem1" role="menuitemradio" aria-checked="true">Item one</div>
+<div id="menuitem2" role="menuitemradio" aria-checked="false">Item two</div>
+
+<div id="menuitem3" role="menuitemcheckbox" aria-checked="true">Item three</div>
+<div id="menuitem4" role="menuitemcheckbox" aria-checked="false">Item four</div>
+
+<div id="menuitem5" role="menuitem">Item five</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that menu items can report the right value whether it's checked.");
+
+    if (window.accessibilityController) {
+
+        var radio = accessibilityController.accessibleElementById("radio");
+        
+        var menuItem1 = accessibilityController.accessibleElementById("menuitem1");
+        var menuItem2 = accessibilityController.accessibleElementById("menuitem2");
+
+        // Verify radio and menuitemradio have different traits.
+        shouldBeTrue("radio.traits != menuItem1.traits");
+        // Verify the value of the checked menu item is correct.
+        shouldBe("menuItem1.stringValue", "'AXValue: 1'");
+        shouldBe("menuItem2.stringValue", "'AXValue: 0'");
+        
+        var menuItem3 = accessibilityController.accessibleElementById("menuitem3");
+        var menuItem4 = accessibilityController.accessibleElementById("menuitem4");
+        
+        // Verify menuitemcheckbox and menuitemradio have same traits.
+        shouldBeTrue("menuItem1.traits == menuItem3.traits");
+        // Verify the value of the checked menu item is correct.
+        shouldBe("menuItem3.stringValue", "'AXValue: 1'");
+        shouldBe("menuItem4.stringValue", "'AXValue: 0'");
+        
+        // Verify menuitem and menuitemradio/menuitemcheckbox have different traits.
+        var menuItem5 = accessibilityController.accessibleElementById("menuitem5");
+        shouldBeTrue("menuItem5.traits != menuItem4.traits");
+    }
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 4061e20..d314cc9 100644 (file)
@@ -1,3 +1,18 @@
+2016-08-24  Nan Wang  <n_wang@apple.com>
+
+        AX: VoiceOver on iOS ignores aria-checked on menuitemradio and menuitemcheckbox
+        https://bugs.webkit.org/show_bug.cgi?id=161118
+
+        Reviewed by Chris Fleizach.
+
+        Added checkboxOrRadioValue and toggle trait to menuitemradio and menuitemcheckbox.
+
+        Test: accessibility/ios-simulator/menuitem-checked.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityTraits]):
+        (-[WebAccessibilityObjectWrapper accessibilityValue]):
+
 2016-08-24  Chris Dumez  <cdumez@apple.com>
 
         Assertion hit: ASSERT(!m_parserScheduler) in ~HTMLDocumentParser()
index b660e21..b28f9bf 100644 (file)
@@ -698,9 +698,11 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
             break;
         case MenuButtonRole:
         case MenuItemRole:
+            traits |= [self _axMenuItemTrait];
+            break;
         case MenuItemCheckboxRole:
         case MenuItemRadioRole:
-            traits |= [self _axMenuItemTrait];
+            traits |= ([self _axMenuItemTrait] | [self _axToggleTrait]);
             break;
         default:
             break;
@@ -1247,7 +1249,8 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     if (value)
         return value;
     
-    if (m_object->isCheckboxOrRadio()) {
+    AccessibilityRole role = m_object->roleValue();
+    if (m_object->isCheckboxOrRadio() || role == MenuItemCheckboxRole || role == MenuItemRadioRole) {
         switch (m_object->checkboxOrRadioValue()) {
         case ButtonStateOff:
             return [NSString stringWithFormat:@"%d", 0];