Title: [189044] trunk
Revision
189044
Author
[email protected]
Date
2015-08-27 12:21:29 -0700 (Thu, 27 Aug 2015)

Log Message

AX: Fix accessibility/select-element-at-index.html test
https://bugs.webkit.org/show_bug.cgi?id=148516

Patch by Nan Wang <[email protected]> on 2015-08-27
Reviewed by Chris Fleizach.

Tools:

Implemented setSelectedChildAtIndex and removeSelectionAtIndex for mac.

* DumpRenderTree/AccessibilityUIElement.cpp:
(setSelectedChildCallback):
(setSelectedChildAtIndexCallback):
(removeSelectionAtIndexCallback):
(elementAtPointCallback):
(sentenceAtOffsetCallback):
(stringForSelectionCallback):
(AccessibilityUIElement::getJSClass):
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::setSelectedChild):
(AccessibilityUIElement::setSelectedChildAtIndex):
(AccessibilityUIElement::removeSelectionAtIndex):
(AccessibilityUIElement::accessibilityValue):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::wordAtOffset):
(WTR::AccessibilityUIElement::lineAtOffset):
(WTR::AccessibilityUIElement::sentenceAtOffset):
(WTR::AccessibilityUIElement::isSelectable):
(WTR::AccessibilityUIElement::isMultiSelectable):
(WTR::AccessibilityUIElement::setSelectedChild):
(WTR::AccessibilityUIElement::setSelectedChildAtIndex):
(WTR::AccessibilityUIElement::removeSelectionAtIndex):
(WTR::AccessibilityUIElement::selectedChildrenCount):
(WTR::AccessibilityUIElement::selectedChildAtIndex):
(WTR::AccessibilityUIElement::isExpanded):
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::setSelectedChild):
(WTR::AccessibilityUIElement::setSelectedChildAtIndex):
(WTR::AccessibilityUIElement::removeSelectionAtIndex):
(WTR::AccessibilityUIElement::accessibilityValue):

LayoutTests:

* accessibility/select-element-at-index.html:
* platform/mac/TestExpectations:
* platform/mac/accessibility/select-element-at-index-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189043 => 189044)


--- trunk/LayoutTests/ChangeLog	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/LayoutTests/ChangeLog	2015-08-27 19:21:29 UTC (rev 189044)
@@ -1,3 +1,14 @@
+2015-08-27  Nan Wang  <[email protected]>
+
+        AX: Fix accessibility/select-element-at-index.html test
+        https://bugs.webkit.org/show_bug.cgi?id=148516
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/select-element-at-index.html:
+        * platform/mac/TestExpectations:
+        * platform/mac/accessibility/select-element-at-index-expected.txt: Added.
+
 2015-08-27  Brent Fulgham  <[email protected]>
 
         [Win] Skip new High DPI test (Windows doesn't quite support this)

Modified: trunk/LayoutTests/accessibility/select-element-at-index.html (189043 => 189044)


--- trunk/LayoutTests/accessibility/select-element-at-index.html	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/LayoutTests/accessibility/select-element-at-index.html	2015-08-27 19:21:29 UTC (rev 189044)
@@ -45,7 +45,14 @@
         selectElement.setSelectedChildAtIndex(3);
         shouldBe("selectElement.selectedChildrenCount", "3");
         shouldBeTrue("option4.isSelected");
-        shouldBeTrue("selectElement.selectedChildAtIndex(3).isEqual(option4)");
+        
+        // On mac, selectedChildAtIndex is using the index to retrieve the element
+        // from the selected children array. Here, the selected children array has
+        // size 3, so the index should be 2.
+        if (accessibilityController.platformName == "mac") 
+            shouldBeTrue("selectElement.selectedChildAtIndex(2).isEqual(option4)");
+        else
+            shouldBeTrue("selectElement.selectedChildAtIndex(3).isEqual(option4)");
 
         selectElement.removeSelectionAtIndex(3);
         shouldBeFalse("option4.isSelected");

Modified: trunk/LayoutTests/platform/mac/TestExpectations (189043 => 189044)


--- trunk/LayoutTests/platform/mac/TestExpectations	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2015-08-27 19:21:29 UTC (rev 189044)
@@ -44,9 +44,6 @@
 accessibility/menu-list-sends-change-notification.html
 accessibility/multiselect-list-reports-active-option.html
 
-# Missing implementation of some functions in mac.
-webkit.org/b/129039 accessibility/select-element-at-index.html [ Skip ]
-
 # Need to add functionality to DumpRenderTree to handle error pages
 fast/history/back-forward-reset-after-error-handling.html
 

Added: trunk/LayoutTests/platform/mac/accessibility/select-element-at-index-expected.txt (0 => 189044)


--- trunk/LayoutTests/platform/mac/accessibility/select-element-at-index-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/select-element-at-index-expected.txt	2015-08-27 19:21:29 UTC (rev 189044)
@@ -0,0 +1,27 @@
+
+Tests that checks whether setting selection at the given index works correctly
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS selectElement.selectedChildrenCount is 0
+PASS selectElement.selectedChildrenCount is 1
+PASS option1.isSelected is true
+PASS selectElement.selectedChildAtIndex(0).isEqual(option1) is true
+PASS selectElement.selectedChildrenCount is 2
+PASS option2.isSelected is true
+PASS selectElement.selectedChildAtIndex(1).isEqual(option2) is true
+PASS option3.isSelected is false
+PASS selectElement.selectedChildrenCount is 3
+PASS option4.isSelected is true
+PASS selectElement.selectedChildAtIndex(2).isEqual(option4) is true
+PASS option4.isSelected is false
+PASS selectElement.selectedChildrenCount is 2
+PASS option2.isSelected is false
+PASS selectElement.selectedChildrenCount is 1
+PASS option1.isSelected is false
+PASS selectElement.selectedChildrenCount is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/Tools/ChangeLog (189043 => 189044)


--- trunk/Tools/ChangeLog	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/Tools/ChangeLog	2015-08-27 19:21:29 UTC (rev 189044)
@@ -1,3 +1,43 @@
+2015-08-27  Nan Wang  <[email protected]>
+
+        AX: Fix accessibility/select-element-at-index.html test
+        https://bugs.webkit.org/show_bug.cgi?id=148516
+
+        Reviewed by Chris Fleizach.
+
+        Implemented setSelectedChildAtIndex and removeSelectionAtIndex for mac.
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (setSelectedChildCallback):
+        (setSelectedChildAtIndexCallback):
+        (removeSelectionAtIndexCallback):
+        (elementAtPointCallback):
+        (sentenceAtOffsetCallback):
+        (stringForSelectionCallback):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::setSelectedChild):
+        (AccessibilityUIElement::setSelectedChildAtIndex):
+        (AccessibilityUIElement::removeSelectionAtIndex):
+        (AccessibilityUIElement::accessibilityValue):
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+        (WTR::AccessibilityUIElement::wordAtOffset):
+        (WTR::AccessibilityUIElement::lineAtOffset):
+        (WTR::AccessibilityUIElement::sentenceAtOffset):
+        (WTR::AccessibilityUIElement::isSelectable):
+        (WTR::AccessibilityUIElement::isMultiSelectable):
+        (WTR::AccessibilityUIElement::setSelectedChild):
+        (WTR::AccessibilityUIElement::setSelectedChildAtIndex):
+        (WTR::AccessibilityUIElement::removeSelectionAtIndex):
+        (WTR::AccessibilityUIElement::selectedChildrenCount):
+        (WTR::AccessibilityUIElement::selectedChildAtIndex):
+        (WTR::AccessibilityUIElement::isExpanded):
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::setSelectedChild):
+        (WTR::AccessibilityUIElement::setSelectedChildAtIndex):
+        (WTR::AccessibilityUIElement::removeSelectionAtIndex):
+        (WTR::AccessibilityUIElement::accessibilityValue):
+
 2015-08-27  Alex Christensen  <[email protected]>
 
         Build fix after r188982

Modified: trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp (189043 => 189044)


--- trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp	2015-08-27 19:21:29 UTC (rev 189044)
@@ -482,6 +482,24 @@
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setSelectedChildAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount == 1) {
+        unsigned indexNumber = JSValueToNumber(context, arguments[0], exception);
+        toAXElement(thisObject)->setSelectedChildAtIndex(indexNumber);
+    }
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef removeSelectionAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount == 1) {
+        unsigned indexNumber = JSValueToNumber(context, arguments[0], exception);
+        toAXElement(thisObject)->removeSelectionAtIndex(indexNumber);
+    }
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef elementAtPointCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     int x = 0;
@@ -1294,28 +1312,6 @@
     return JSValueMakeString(context, sentenceAtOffset.get());
 }
 
-static JSValueRef setSelectedChildAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
-{
-    int indexNumber = -1;
-    if (argumentCount == 1);
-        indexNumber = JSValueToNumber(context, arguments[0], exception);
-
-    if (indexNumber >= 0)
-        toAXElement(thisObject)->setSelectedChildAtIndex(indexNumber);
-    return JSValueMakeUndefined(context);
-}
-
-static JSValueRef removeSelectionAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
-{
-    int indexNumber = -1;
-    if (argumentCount == 1)
-        indexNumber = JSValueToNumber(context, arguments[0], exception);
-
-    if (indexNumber >= 0)
-        toAXElement(thisObject)->removeSelectionAtIndex(indexNumber);
-    return JSValueMakeUndefined(context);
-}
-
 #elif PLATFORM(IOS)
 
 static JSValueRef stringForSelectionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -1380,6 +1376,8 @@
 JSStringRef AccessibilityUIElement::rangeForLine(int line) { return 0; }
 JSStringRef AccessibilityUIElement::rangeForPosition(int, int) { return 0; }
 void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement*) const { }
+void AccessibilityUIElement::setSelectedChildAtIndex(unsigned) const { }
+void AccessibilityUIElement::removeSelectionAtIndex(unsigned) const { }
 AccessibilityUIElement AccessibilityUIElement::horizontalScrollbar() const { return 0; }
 AccessibilityUIElement AccessibilityUIElement::verticalScrollbar() const { return 0; }
 AccessibilityUIElement AccessibilityUIElement::uiElementAttributeValue(JSStringRef) const { return 0; }
@@ -1696,6 +1694,8 @@
         { "previousTextMarker", previousTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "stringForTextMarkerRange", stringForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setSelectedChild", setSelectedChildCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setSelectedChildAtIndex", setSelectedChildAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "removeSelectionAtIndex", removeSelectionAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setValue", setValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setSelectedVisibleTextRange", setSelectedVisibleTextRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "selectedChildAtIndex", selectedChildAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -1705,8 +1705,6 @@
         { "wordAtOffset", wordAtOffsetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "lineAtOffset", lineAtOffsetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "sentenceAtOffset", sentenceAtOffsetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
-        { "setSelectedChildAtIndex", setSelectedChildAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
-        { "removeSelectionAtIndex", removeSelectionAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 #elif PLATFORM(IOS)
         { "linkedElement", linkedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "headerElementAtIndex", headerElementAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },

Modified: trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm (189043 => 189044)


--- trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2015-08-27 19:21:29 UTC (rev 189044)
@@ -76,6 +76,7 @@
 - (NSUInteger)accessibilityIndexOfChild:(id)child;
 - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute;
 - (void)_accessibilitySetTestValue:(id)value forAttribute:(NSString*)attributeName;
+- (void)_accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName;
 @end
 
 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
@@ -1404,6 +1405,33 @@
     END_AX_OBJC_EXCEPTIONS    
 }
 
+void AccessibilityUIElement::setSelectedChildAtIndex(unsigned index) const
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    AccessibilityUIElement element = const_cast<AccessibilityUIElement*>(this)->getChildAtIndex(index);
+    if (!element.platformUIElement())
+        return;
+    NSArray *selectedChildren = [m_element accessibilityAttributeValue:NSAccessibilitySelectedChildrenAttribute];
+    NSArray *array = [NSArray arrayWithObject:element.platformUIElement()];
+    if (selectedChildren)
+        array = [selectedChildren arrayByAddingObjectsFromArray:array];
+    [m_element _accessibilitySetValue:array forAttribute:NSAccessibilitySelectedChildrenAttribute];
+    END_AX_OBJC_EXCEPTIONS
+}
+
+void AccessibilityUIElement::removeSelectionAtIndex(unsigned index) const
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    AccessibilityUIElement element = const_cast<AccessibilityUIElement*>(this)->getChildAtIndex(index);
+    NSArray *selectedChildren = [m_element accessibilityAttributeValue:NSAccessibilitySelectedChildrenAttribute];
+    if (!element.platformUIElement() || !selectedChildren)
+        return;
+    NSMutableArray *array = [NSMutableArray arrayWithArray:selectedChildren];
+    [array removeObject:element.platformUIElement()];
+    [m_element _accessibilitySetValue:array forAttribute:NSAccessibilitySelectedChildrenAttribute];
+    END_AX_OBJC_EXCEPTIONS
+}
+
 JSStringRef AccessibilityUIElement::accessibilityValue() const
 {
     // FIXME: implement

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp (189043 => 189044)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp	2015-08-27 19:21:29 UTC (rev 189044)
@@ -78,8 +78,6 @@
 JSRetainPtr<JSStringRef> AccessibilityUIElement::wordAtOffset(int) { return 0; }
 JSRetainPtr<JSStringRef> AccessibilityUIElement::lineAtOffset(int) { return 0; }
 JSRetainPtr<JSStringRef> AccessibilityUIElement::sentenceAtOffset(int) { return 0; }
-void AccessibilityUIElement::setSelectedChildAtIndex(unsigned) const { }
-void AccessibilityUIElement::removeSelectionAtIndex(unsigned) const { }
 #endif
 
 #if (!PLATFORM(COCOA) && !PLATFORM(GTK) && !PLATFORM(EFL)) || !HAVE(ACCESSIBILITY)
@@ -147,6 +145,8 @@
 bool AccessibilityUIElement::isSelectable() const { return false; }
 bool AccessibilityUIElement::isMultiSelectable() const { return false; }
 void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement*) const { }
+void AccessibilityUIElement::setSelectedChildAtIndex(unsigned) const { }
+void AccessibilityUIElement::removeSelectionAtIndex(unsigned) const { }
 unsigned AccessibilityUIElement::selectedChildrenCount() const { return 0; }
 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedChildAtIndex(unsigned) const { return 0; }
 bool AccessibilityUIElement::isExpanded() const { return false; }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (189043 => 189044)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2015-08-27 19:21:29 UTC (rev 189044)
@@ -737,6 +737,14 @@
 {
 }
 
+void AccessibilityUIElement::setSelectedChildAtIndex(unsigned index) const
+{
+}
+
+void AccessibilityUIElement::removeSelectionAtIndex(unsigned index) const
+{
+}
+
 JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
 {
     // FIXME: implement

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (189043 => 189044)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2015-08-27 19:10:29 UTC (rev 189043)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2015-08-27 19:21:29 UTC (rev 189044)
@@ -80,6 +80,7 @@
 - (NSUInteger)accessibilityIndexOfChild:(id)child;
 - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute;
 - (void)_accessibilitySetTestValue:(id)value forAttribute:(NSString*)attributeName;
+- (void)_accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName;
 @end
 
 namespace WTR {
@@ -1442,6 +1443,33 @@
     END_AX_OBJC_EXCEPTIONS    
 }
 
+void AccessibilityUIElement::setSelectedChildAtIndex(unsigned index) const
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    RefPtr<AccessibilityUIElement> element = const_cast<AccessibilityUIElement*>(this)->childAtIndex(index);
+    if (!element)
+        return;
+    NSArray *selectedChildren = [m_element accessibilityAttributeValue:NSAccessibilitySelectedChildrenAttribute];
+    NSArray *array = [NSArray arrayWithObject:element->platformUIElement()];
+    if (selectedChildren)
+        array = [selectedChildren arrayByAddingObjectsFromArray:array];
+    [m_element _accessibilitySetValue:array forAttribute:NSAccessibilitySelectedChildrenAttribute];
+    END_AX_OBJC_EXCEPTIONS
+}
+
+void AccessibilityUIElement::removeSelectionAtIndex(unsigned index) const
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    RefPtr<AccessibilityUIElement> element = const_cast<AccessibilityUIElement*>(this)->childAtIndex(index);
+    NSArray *selectedChildren = [m_element accessibilityAttributeValue:NSAccessibilitySelectedChildrenAttribute];
+    if (!element || !selectedChildren)
+        return;
+    NSMutableArray *array = [NSMutableArray arrayWithArray:selectedChildren];
+    [array removeObject:element->platformUIElement()];
+    [m_element _accessibilitySetValue:array forAttribute:NSAccessibilitySelectedChildrenAttribute];
+    END_AX_OBJC_EXCEPTIONS
+}
+
 JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
 {
     // FIXME: implement
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to