Title: [165656] trunk
Revision
165656
Author
[email protected]
Date
2014-03-14 15:02:00 -0700 (Fri, 14 Mar 2014)

Log Message

AX: AccessibilityObject::invalidStatus() is incorrect when aria-invalid="undefined" or whitespace
https://bugs.webkit.org/show_bug.cgi?id=130071

Patch by James Craig <[email protected]> on 2014-03-14
Reviewed by Chris Fleizach.

Accounted for whitespace values and the explicit string, "undefined".

Source/WebCore:

Test: accessibility/aria-invalid.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::invalidStatus):
* accessibility/AccessibilityObject.h:
* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(getAttributeSetForAccessibilityObject):

LayoutTests:

* accessibility/aria-invalid-expected.txt:
* accessibility/aria-invalid.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (165655 => 165656)


--- trunk/LayoutTests/ChangeLog	2014-03-14 21:58:35 UTC (rev 165655)
+++ trunk/LayoutTests/ChangeLog	2014-03-14 22:02:00 UTC (rev 165656)
@@ -1,3 +1,15 @@
+2014-03-14  James Craig  <[email protected]>
+
+        AX: AccessibilityObject::invalidStatus() is incorrect when aria-invalid="undefined" or whitespace
+        https://bugs.webkit.org/show_bug.cgi?id=130071
+
+        Reviewed by Chris Fleizach.
+
+        Accounted for whitespace values and the explicit string, "undefined".
+
+        * accessibility/aria-invalid-expected.txt:
+        * accessibility/aria-invalid.html:
+
 2014-03-14  Bear Travis  <[email protected]>
 
         [CSS Shapes] CSS parser accepts trailing position arguments

Modified: trunk/LayoutTests/accessibility/aria-invalid-expected.txt (165655 => 165656)


--- trunk/LayoutTests/accessibility/aria-invalid-expected.txt	2014-03-14 21:58:35 UTC (rev 165655)
+++ trunk/LayoutTests/accessibility/aria-invalid-expected.txt	2014-03-14 22:02:00 UTC (rev 165656)
@@ -1,17 +1,29 @@
-      
 This tests that aria-invalid causes the right attribute to be returned and it ensures a notification is sent when it changes.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS accessibilityController.focusedElement.stringAttributeValue('AXInvalid') is 'true'
-PASS accessibilityController.focusedElement.stringAttributeValue('AXInvalid') is 'grammar'
-PASS accessibilityController.focusedElement.stringAttributeValue('AXInvalid') is 'spelling'
-PASS accessibilityController.focusedElement.stringAttributeValue('AXInvalid') is 'true'
-PASS accessibilityController.focusedElement.stringAttributeValue('AXInvalid') is 'false'
-PASS accessibilityController.focusedElement.stringAttributeValue('AXInvalid') is 'false'
-PASS accessibilityController.focusedElement.stringAttributeValue('AXInvalid') is 'false'
+PASS: AXInvalid is false.
+PASS: AXInvalid is false.
+PASS: AXInvalid is false.
+PASS: AXInvalid is false.
+PASS: AXInvalid is false.
+PASS: AXInvalid is false.
+PASS: AXInvalid is false.
+PASS: AXInvalid is false.
+PASS: AXInvalid is grammar.
+PASS: AXInvalid is grammar.
+PASS: AXInvalid is spelling.
+PASS: AXInvalid is spelling.
+PASS: AXInvalid is true.
+PASS: AXInvalid is true.
+PASS: AXInvalid is true.
+PASS: AXInvalid is true.
+PASS: AXInvalid is true.
+PASS: AXInvalid is true.
+PASS: AXInvalid is true.
 PASS addedNotification is true
+PASS: AXInvalid is spelling.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/accessibility/aria-invalid.html (165655 => 165656)


--- trunk/LayoutTests/accessibility/aria-invalid.html	2014-03-14 21:58:35 UTC (rev 165655)
+++ trunk/LayoutTests/accessibility/aria-invalid.html	2014-03-14 22:02:00 UTC (rev 165656)
@@ -5,15 +5,36 @@
 </head>
 <body id="body">
 
+<div id="examples">
+    <!-- All of these eval to AXInvalid: 'false' -->
+    <input class="ex" data-expected="false" type="text">
+    <input class="ex" data-expected="false" type="text" aria-invalid>
+    <input class="ex" data-expected="false" type="text" aria-invalid="">
+    <input class="ex" data-expected="false" type="text" aria-invalid=" ">
+    <input class="ex" data-expected="false" type="text" aria-invalid="	"><!-- [sic] tab char -->
+    <input class="ex" data-expected="false" type="text" aria-invalid="
+    "><!-- [sic] newline char -->
+    <input class="ex" data-expected="false" type="text" aria-invalid="false">
+    <input class="ex" data-expected="false" type="text" aria-invalid="undefined">
 
-<input type="text" id="text1" aria-invalid="true">
-<input type="text" id="text2" aria-invalid="grammar">
-<input type="text" id="text3" aria-invalid="spelling">
-<input type="text" id="text4" aria-invalid="notallowed">
-<input type="text" id="text5" aria-invalid="false">
-<input type="text" id="text6" aria-invalid="">
-<input type="text" id="text7">
+    <!-- Known token values in ARIA 1.0. -->
+    <input class="ex" data-expected="grammar" type="text" aria-invalid="grammar">
+    <input class="ex" data-expected="grammar" type="text" aria-invalid="grammar	"><!-- [sic] tab char -->
+    <input class="ex" data-expected="spelling" type="text" aria-invalid="spelling">
+    <input class="ex" data-expected="spelling" type="text" aria-invalid="spelling
+    "><!-- [sic] newline char -->
 
+    <!-- All other string values are truthy, including a combination of otherwise valid tokens. -->
+    <input class="ex" data-expected="true" type="text" aria-invalid="true">
+    <input class="ex" data-expected="true" type="text" aria-invalid="notallowed">
+    <input class="ex" data-expected="true" type="text" aria-invalid="…">
+    <input class="ex" data-expected="true" type="text" aria-invalid="Ç">
+    <input class="ex" data-expected="true" type="text" aria-invalid="spelling grammar">
+    <input class="ex" data-expected="true" type="text" aria-invalid="spelling	grammar"><!-- [sic] tab char -->
+    <input class="ex" data-expected="true" type="text" aria-invalid="spelling
+    grammar"><!-- [sic] newline char -->
+</div>
+
 <p id="description"></p>
 <div id="console"></div>
 <div id="notifications"></div>
@@ -22,44 +43,47 @@
 
     description("This tests that aria-invalid causes the right attribute to be returned and it ensures a notification is sent when it changes.");
 
-    var notificationElement = 0;
+    function $(id){
+        return document.getElementById(id);
+    }
+
+    var axNotificationElement = null;
     function notificationCallback(notification) {
         if (notification == "AXInvalidStatusChanged") {
-            document.getElementById("notifications").innerHTML += "Notification received successfully.";
-            notificationElement.removeNotificationListener();
+            $("notifications").innerHTML += "Notification received successfully.";
+            axNotificationElement.removeNotificationListener();
+            $("examples").hidden = true;
             window.testRunner.notifyDone();
         }
     }
 
+    var result = $('console');
+    function verify(value, expectation, element) {
+      if (value === expectation)
+        result.innerText += "PASS: AXInvalid is " + value + ".\n";
+      else
+        result.innerText += "FAIL: AXInvalid is " + value + ". Expected: " + expectation + ". " + (element ? element.outerHTML : "") + "\n";
+    }
+
     if (window.accessibilityController) {
         window.testRunner.waitUntilDone();
 
-        document.getElementById("text1").focus();
-        shouldBe("accessibilityController.focusedElement.stringAttributeValue('AXInvalid')", "'true'");
-
-        document.getElementById("text2").focus();
-        shouldBe("accessibilityController.focusedElement.stringAttributeValue('AXInvalid')", "'grammar'");
-
-        document.getElementById("text3").focus();
-        shouldBe("accessibilityController.focusedElement.stringAttributeValue('AXInvalid')", "'spelling'");
-
-        document.getElementById("text4").focus();
-        shouldBe("accessibilityController.focusedElement.stringAttributeValue('AXInvalid')", "'true'");
-
-        document.getElementById("text5").focus();
-        shouldBe("accessibilityController.focusedElement.stringAttributeValue('AXInvalid')", "'false'");
-
-        document.getElementById("text6").focus();
-        shouldBe("accessibilityController.focusedElement.stringAttributeValue('AXInvalid')", "'false'");
-
-        document.getElementById("text7").focus();
-        shouldBe("accessibilityController.focusedElement.stringAttributeValue('AXInvalid')", "'false'");
-
-        notificationElement = accessibilityController.focusedElement;
-        var addedNotification = notificationElement.addNotificationListener(notificationCallback);
+        var examples = document.querySelectorAll(".ex");
+        for (var i = 0, c = examples.length; i < c; i++) {
+            var el = examples[i];
+            el.focus();
+            var expectation = el.getAttribute("data-expected");
+            var value = accessibilityController.focusedElement.stringAttributeValue('AXInvalid');
+            verify(value, expectation, el);
+        }
+        
+        var domNotificationElement = document.querySelector(".ex");
+        domNotificationElement.focus();
+        axNotificationElement = accessibilityController.focusedElement;
+        var addedNotification = axNotificationElement.addNotificationListener(notificationCallback);
         shouldBeTrue("addedNotification");
-
-        document.getElementById("text7").setAttribute("aria-invalid", "spelling");
+        domNotificationElement.setAttribute("aria-invalid", "spelling");
+        verify(axNotificationElement.stringAttributeValue('AXInvalid'), "spelling", domNotificationElement);
     }
 
 </script>

Modified: trunk/Source/WebCore/ChangeLog (165655 => 165656)


--- trunk/Source/WebCore/ChangeLog	2014-03-14 21:58:35 UTC (rev 165655)
+++ trunk/Source/WebCore/ChangeLog	2014-03-14 22:02:00 UTC (rev 165656)
@@ -1,3 +1,20 @@
+2014-03-14  James Craig  <[email protected]>
+
+        AX: AccessibilityObject::invalidStatus() is incorrect when aria-invalid="undefined" or whitespace
+        https://bugs.webkit.org/show_bug.cgi?id=130071
+
+        Reviewed by Chris Fleizach.
+
+        Accounted for whitespace values and the explicit string, "undefined".
+
+        Test: accessibility/aria-invalid.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::invalidStatus):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
+        (getAttributeSetForAccessibilityObject):
+
 2014-03-14  Bear Travis  <[email protected]>
 
         [CSS Shapes] CSS parser accepts trailing position arguments

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (165655 => 165656)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-03-14 21:58:35 UTC (rev 165655)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-03-14 22:02:00 UTC (rev 165656)
@@ -40,6 +40,7 @@
 #include "FrameLoader.h"
 #include "FrameSelection.h"
 #include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
 #include "LocalizedStrings.h"
 #include "MainFrame.h"
 #include "MathMLNames.h"
@@ -1528,23 +1529,28 @@
     return equalIgnoringCase(getAttribute(aria_multilineAttr), "true");
 }
 
-const AtomicString& AccessibilityObject::invalidStatus() const
+String AccessibilityObject::invalidStatus() const
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, invalidStatusFalse, ("false", AtomicString::ConstructFromLiteral));
-    DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, invalidStatusTrue, ("true", AtomicString::ConstructFromLiteral));
+    String grammarValue = ASCIILiteral("grammar");
+    String falseValue = ASCIILiteral("false");
+    String spellingValue = ASCIILiteral("spelling");
+    String trueValue = ASCIILiteral("true");
+    String undefinedValue = ASCIILiteral("undefined");
+
+    // aria-invalid can return false (default), grammar, spelling, or true.
+    String ariaInvalid = stripLeadingAndTrailingHTMLSpaces(getAttribute(aria_invalidAttr));
     
-    // aria-invalid can return false (default), grammer, spelling, or true.
-    const AtomicString& ariaInvalid = getAttribute(aria_invalidAttr);
-    
-    // If 'false', empty or not present, it should return false.
-    if (ariaInvalid.isEmpty() || equalIgnoringCase(ariaInvalid, invalidStatusFalse))
-        return invalidStatusFalse;
-    
-    // Only 'true', 'grammar' and 'spelling' are values recognised by the WAI-ARIA
-    // specification. Any other non empty string should be treated as 'true'.
-    if (equalIgnoringCase(ariaInvalid, "spelling") || equalIgnoringCase(ariaInvalid, "grammar"))
-        return ariaInvalid;
-    return invalidStatusTrue;
+    // If "false", "undefined" [sic, string value], empty, or missing, return "false".
+    if (ariaInvalid.isEmpty() || ariaInvalid == falseValue || ariaInvalid == undefinedValue)
+        return falseValue;
+    // Besides true/false/undefined, the only tokens defined by WAI-ARIA 1.0...
+    // ...for @aria-invalid are "grammar" and "spelling".
+    if (ariaInvalid == grammarValue)
+        return grammarValue;
+    if (ariaInvalid == spellingValue)
+        return spellingValue;
+    // Any other non empty string should be treated as "true".
+    return trueValue;
 }
  
 bool AccessibilityObject::hasTagName(const QualifiedName& tagName) const

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (165655 => 165656)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2014-03-14 21:58:35 UTC (rev 165655)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2014-03-14 22:02:00 UTC (rev 165656)
@@ -585,7 +585,7 @@
     virtual bool ariaHasPopup() const { return false; }
     virtual bool ariaPressedIsPresent() const;
     bool ariaIsMultiline() const;
-    virtual const AtomicString& invalidStatus() const;
+    String invalidStatus() const;
     bool supportsARIAExpanded() const;
     bool supportsChecked() const;
     AccessibilitySortDirection sortDirection() const;

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp (165655 => 165656)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2014-03-14 21:58:35 UTC (rev 165655)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2014-03-14 22:02:00 UTC (rev 165656)
@@ -204,7 +204,7 @@
     if (!language.isEmpty())
         result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE), language.utf8().data());
 
-    String invalidStatus = object->invalidStatus().string();
+    String invalidStatus = object->invalidStatus();
     if (invalidStatus != "false") {
         // Register the custom attribute for 'aria-invalid' if not done yet.
         if (atkTextAttributeInvalid == ATK_TEXT_ATTR_INVALID)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to