Title: [179820] trunk
Revision
179820
Author
[email protected]
Date
2015-02-08 23:09:50 -0800 (Sun, 08 Feb 2015)

Log Message

AX: VoiceOver appears unresponsive when _javascript_ alerts are triggered via focus or blur events
https://bugs.webkit.org/show_bug.cgi?id=140485

Reviewed by Anders Carlsson.

Source/WebCore:

If setting an accessibility attribute results in a modal alert being displayed, it can cause VoiceOver
to hang. A simple solution is perform the actual work after a short delay, which will ensure the call
returns without hanging.

Test: platform/mac/accessibility/setting-attributes-is-asynchronous.html

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilitySetValue:forAttribute:]):
(-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):

Tools:

Implement takeFocus() as a way to set focus through accessibility wrappers.

* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::takeFocus):
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::takeFocus):

LayoutTests:

Modify tests that relied on setting behavior and immediately checking results. Those
tests now need to retrieve results after a short timeout.

* accessibility/textarea-selected-text-range-expected.txt:
* accessibility/textarea-selected-text-range.html:
* platform/mac/accessibility/select-element-selection-with-optgroups.html:
* platform/mac/accessibility/setting-attributes-is-asynchronous-expected.txt: Added.
* platform/mac/accessibility/setting-attributes-is-asynchronous.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (179819 => 179820)


--- trunk/LayoutTests/ChangeLog	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/LayoutTests/ChangeLog	2015-02-09 07:09:50 UTC (rev 179820)
@@ -1,3 +1,19 @@
+2015-02-08  Chris Fleizach  <[email protected]>
+
+        AX: VoiceOver appears unresponsive when _javascript_ alerts are triggered via focus or blur events
+        https://bugs.webkit.org/show_bug.cgi?id=140485
+
+        Reviewed by Anders Carlsson.
+
+        Modify tests that relied on setting behavior and immediately checking results. Those
+        tests now need to retrieve results after a short timeout.
+
+        * accessibility/textarea-selected-text-range-expected.txt:
+        * accessibility/textarea-selected-text-range.html:
+        * platform/mac/accessibility/select-element-selection-with-optgroups.html:
+        * platform/mac/accessibility/setting-attributes-is-asynchronous-expected.txt: Added.
+        * platform/mac/accessibility/setting-attributes-is-asynchronous.html: Added.
+
 2015-02-08  Benjamin Poulain  <[email protected]>
 
         Add parsing support for CSS Selector L4's case-insensitive attribute

Modified: trunk/LayoutTests/accessibility/textarea-selected-text-range-expected.txt (179819 => 179820)


--- trunk/LayoutTests/accessibility/textarea-selected-text-range-expected.txt	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/LayoutTests/accessibility/textarea-selected-text-range-expected.txt	2015-02-09 07:09:50 UTC (rev 179820)
@@ -1,7 +1,7 @@
-(4,0) = {4, 0}
+PASS textArea.selectedTextRange is '{4, 0}'
+PASS textArea.selectedTextRange is '{8, 2}'
+PASS textArea.selectedTextRange is '{25, 0}'
+PASS successfullyParsed is true
 
-(8,2) = {8, 2}
+TEST COMPLETE
 
-(100,0) = {25, 0}
-
-

Modified: trunk/LayoutTests/accessibility/textarea-selected-text-range.html (179819 => 179820)


--- trunk/LayoutTests/accessibility/textarea-selected-text-range.html	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/LayoutTests/accessibility/textarea-selected-text-range.html	2015-02-09 07:09:50 UTC (rev 179820)
@@ -1,8 +1,5 @@
 <html>
-<script>
-    if (window.testRunner)
-        testRunner.dumpAsText();
-</script>
+<script src=""
 <body>
     
     <div id="result"></div>
@@ -15,23 +12,31 @@
 
     <script>
         if (window.accessibilityController) {
-            var result = document.getElementById("result");
-
+            window.jsTestIsAsync = true;
             var area1 = document.getElementById("area1");
             area1.focus();
 
             var textArea = accessibilityController.focusedElement;
 
             textArea.setSelectedTextRange(4,0);
-            result.innerText += "(4,0) = " + textArea.selectedTextRange + "\n\n";
 
-            textArea.setSelectedTextRange(8,2);
-            result.innerText += "(8,2) = " + textArea.selectedTextRange + "\n\n";
+            // After setting a property through accessibility, the value won't be updated immediately, so we
+            // must check after a timeout to re-verify the value.
+            setTimeout(function() {
+                shouldBe("textArea.selectedTextRange", "'{4, 0}'");
+                textArea.setSelectedTextRange(8,2);
+                setTimeout(function() {
+                    shouldBe("textArea.selectedTextRange", "'{8, 2}'");
+                    textArea.setSelectedTextRange(100,0);
+                    setTimeout(function() {
+                        shouldBe("textArea.selectedTextRange", "'{25, 0}'");
+                        finishJSTest();
+                    }, 1);
+                }, 1);
+            }, 1);
 
-            textArea.setSelectedTextRange(100,0);
-            result.innerText += "(100,0) = " + textArea.selectedTextRange + "\n\n";
-
         }
     </script>
+<script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/platform/mac/accessibility/select-element-selection-with-optgroups.html (179819 => 179820)


--- trunk/LayoutTests/platform/mac/accessibility/select-element-selection-with-optgroups.html	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/LayoutTests/platform/mac/accessibility/select-element-selection-with-optgroups.html	2015-02-09 07:09:50 UTC (rev 179820)
@@ -26,6 +26,7 @@
     description("This tests that setting selection within a list box works correctly if there are optgroups");
 
     if (window.accessibilityController) {
+          window.jsTestIsAsync = true;
 
           document.getElementById("suite").focus();
           var selectElement = accessibilityController.focusedElement;
@@ -36,17 +37,26 @@
           var option2 = selectElement.childAtIndex(2);
           var option3 = selectElement.childAtIndex(4);
 
+          // Selection operations happen after a delay so they don't hang. Check the result on a timeout.
           selectElement.setSelectedChild(option1);
-          shouldBe("selectElement.selectedChildrenCount", "1");
-          shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option1)");
+          setTimeout(function() {
+              shouldBe("selectElement.selectedChildrenCount", "1");
+              shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option1)");
 
-          selectElement.setSelectedChild(option2);
-          shouldBe("selectElement.selectedChildrenCount", "1");
-          shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option2)");
+              selectElement.setSelectedChild(option2);
+              setTimeout(function() {
+                  shouldBe("selectElement.selectedChildrenCount", "1");
+                  shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option2)");
 
-          selectElement.setSelectedChild(option3);
-          shouldBe("selectElement.selectedChildrenCount", "1");
-          shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option3)");
+                  selectElement.setSelectedChild(option3);
+                  setTimeout(function() {
+                      shouldBe("selectElement.selectedChildrenCount", "1");
+                      shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option3)");
+                      finishJSTest();
+                  }, 1);
+              }, 1);
+           }, 1);
+        
     }
 
 </script>

Added: trunk/LayoutTests/platform/mac/accessibility/setting-attributes-is-asynchronous-expected.txt (0 => 179820)


--- trunk/LayoutTests/platform/mac/accessibility/setting-attributes-is-asynchronous-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/setting-attributes-is-asynchronous-expected.txt	2015-02-09 07:09:50 UTC (rev 179820)
@@ -0,0 +1,11 @@
+
+This tests makes sure that setting accessibility attributes happens asychronously, so that a caller won't hang if the result is an alert.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+This line should be printed first
+This line should be printed second.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/accessibility/setting-attributes-is-asynchronous.html (0 => 179820)


--- trunk/LayoutTests/platform/mac/accessibility/setting-attributes-is-asynchronous.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/setting-attributes-is-asynchronous.html	2015-02-09 07:09:50 UTC (rev 179820)
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<script src=""
+
+<input type="text" id="textfield" _onfocus_="debug('This line should be printed second.');  finishJSTest(); ">
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+
+description("This tests makes sure that setting accessibility attributes happens asychronously, so that a caller won't hang if the result is an alert.")
+
+if (window.testRunner && window.accessibilityController) {
+    
+   window.jsTestIsAsync = true;
+   var textfield = accessibilityController.accessibleElementById("textfield");
+   textfield.takeFocus();
+   debug("This line should be printed first");
+}
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (179819 => 179820)


--- trunk/Source/WebCore/ChangeLog	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/Source/WebCore/ChangeLog	2015-02-09 07:09:50 UTC (rev 179820)
@@ -1,3 +1,20 @@
+2015-02-08  Chris Fleizach  <[email protected]>
+
+        AX: VoiceOver appears unresponsive when _javascript_ alerts are triggered via focus or blur events
+        https://bugs.webkit.org/show_bug.cgi?id=140485
+
+        Reviewed by Anders Carlsson.
+
+        If setting an accessibility attribute results in a modal alert being displayed, it can cause VoiceOver
+        to hang. A simple solution is perform the actual work after a short delay, which will ensure the call
+        returns without hanging.
+
+        Test: platform/mac/accessibility/setting-attributes-is-asynchronous.html
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilitySetValue:forAttribute:]):
+        (-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):
+
 2015-02-08  Benjamin Poulain  <[email protected]>
 
         Add parsing support for CSS Selector L4's case-insensitive attribute

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (179819 => 179820)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2015-02-09 07:09:50 UTC (rev 179820)
@@ -3246,6 +3246,15 @@
 
 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName
 {
+    // In case anything we do by changing values causes an alert or other modal
+    // behaviors, we need to return now, so that VoiceOver doesn't hang indefinitely.
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [self _accessibilitySetValue:value forAttribute:attributeName];
+    });
+}
+
+- (void)_accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName
+{
     if (![self updateObjectBackingStore])
         return;
     

Modified: trunk/Tools/ChangeLog (179819 => 179820)


--- trunk/Tools/ChangeLog	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/Tools/ChangeLog	2015-02-09 07:09:50 UTC (rev 179820)
@@ -1,3 +1,17 @@
+2015-02-08  Chris Fleizach  <[email protected]>
+
+        AX: VoiceOver appears unresponsive when _javascript_ alerts are triggered via focus or blur events
+        https://bugs.webkit.org/show_bug.cgi?id=140485
+
+        Reviewed by Anders Carlsson.
+
+        Implement takeFocus() as a way to set focus through accessibility wrappers.
+
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::takeFocus):
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::takeFocus):
+
 2015-02-08  Darin Adler  <[email protected]>
 
         Remove the SVG instance tree

Modified: trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm (179819 => 179820)


--- trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2015-02-09 07:09:50 UTC (rev 179820)
@@ -1517,7 +1517,9 @@
 
 void AccessibilityUIElement::takeFocus()
 {
-    // FIXME: implement
+    BEGIN_AX_OBJC_EXCEPTIONS
+    [m_element accessibilitySetValue:@YES forAttribute:NSAccessibilityFocusedAttribute];
+    END_AX_OBJC_EXCEPTIONS
 }
 
 void AccessibilityUIElement::takeSelection()

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (179819 => 179820)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl	2015-02-09 07:09:50 UTC (rev 179820)
@@ -168,6 +168,7 @@
     readonly attribute AccessibilityUIElement verticalScrollbar;
 
     void scrollToMakeVisible();
+    void takeFocus();
 
     // Text markers.
     AccessibilityTextMarkerRange lineTextMarkerRangeForTextMarker(AccessibilityTextMarker textMarker);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (179819 => 179820)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2015-02-09 03:44:57 UTC (rev 179819)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2015-02-09 07:09:50 UTC (rev 179820)
@@ -1532,7 +1532,9 @@
 
 void AccessibilityUIElement::takeFocus()
 {
-    // FIXME: implement
+    BEGIN_AX_OBJC_EXCEPTIONS
+    [m_element accessibilitySetValue:@YES forAttribute:NSAccessibilityFocusedAttribute];
+    END_AX_OBJC_EXCEPTIONS
 }
 
 void AccessibilityUIElement::takeSelection()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to