AX: when no other label on provided on form elements, WebKit should fall back to...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Sep 2013 22:55:52 +0000 (22:55 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Sep 2013 22:55:52 +0000 (22:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112842

Patch by Samuel White <samuel_white@apple.com> on 2013-09-04
Reviewed by Chris Fleizach.

Source/WebCore:

Don't let input elements include empty labels in their accessibility title.

Test: platform/mac/accessibility/input-title.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::titleElementText):

LayoutTests:

Added test to ensure that input elements are computing their
accessibility title as expected.

* platform/mac/accessibility/input-title-expected.txt: Added.
* platform/mac/accessibility/input-title.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/input-title-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/input-title.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp

index ca883b11d250a384a7a70ec55c6a491db5d5173c..16099bb97fc6b0908266d210d87fe60b73cd05c4 100644 (file)
@@ -1,3 +1,16 @@
+2013-09-04  Samuel White  <samuel_white@apple.com>
+
+        AX: when no other label on provided on form elements, WebKit should fall back to using @title
+        https://bugs.webkit.org/show_bug.cgi?id=112842
+
+        Reviewed by Chris Fleizach.
+
+        Added test to ensure that input elements are computing their
+        accessibility title as expected.
+
+        * platform/mac/accessibility/input-title-expected.txt: Added.
+        * platform/mac/accessibility/input-title.html: Added.
+
 2013-09-04  Tim Horton  <timothy_horton@apple.com>
 
         [mac] PDFDocumentImage should use PDFKit to draw
diff --git a/LayoutTests/platform/mac/accessibility/input-title-expected.txt b/LayoutTests/platform/mac/accessibility/input-title-expected.txt
new file mode 100644 (file)
index 0000000..14d1a97
--- /dev/null
@@ -0,0 +1,12 @@
+This tests that the input title is exposed correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS green.description is 'AXDescription: green'
+PASS red.description is 'AXDescription: red'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/input-title.html b/LayoutTests/platform/mac/accessibility/input-title.html
new file mode 100644 (file)
index 0000000..379bc3f
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+<title>Input Title</title>
+</head>
+<body>
+
+<input id="green" name="color" title="green" type="radio">
+<input id="red" name="color" title="red" type="radio">
+<label for="red"></label>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that the input title is exposed correctly.");
+    
+    if (window.accessibilityController) {
+        var green = accessibilityController.accessibleElementById("green");
+        shouldBe("green.description", "'AXDescription: green'");
+        
+        var red = accessibilityController.accessibleElementById("red");
+        shouldBe("red.description", "'AXDescription: red'");
+    }
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 8f0b97f40e36ca0ea5f6a9ec32bf3d4cc5f69a42..af8b98e0958791847c9d500e3ae1f4913e4417e5 100644 (file)
@@ -1,3 +1,17 @@
+2013-09-04  Samuel White  <samuel_white@apple.com>
+
+        AX: when no other label on provided on form elements, WebKit should fall back to using @title
+        https://bugs.webkit.org/show_bug.cgi?id=112842
+
+        Reviewed by Chris Fleizach.
+
+        Don't let input elements include empty labels in their accessibility title.
+
+        Test: platform/mac/accessibility/input-title.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::titleElementText):
+
 2013-09-04  Andreas Kling  <akling@apple.com>
 
         Make ImageQualityController per-RenderView.
index 2ae889a05555727dc4a41c0b9adcc0e4d4b291ae..dc49e4dc43dfb91ab28313c913f377c75f74e0ea 100644 (file)
@@ -1171,7 +1171,9 @@ void AccessibilityNodeObject::titleElementText(Vector<AccessibilityText>& textOr
         HTMLLabelElement* label = labelForElement(toElement(node));
         if (label) {
             AccessibilityObject* labelObject = axObjectCache()->getOrCreate(label);
-            textOrder.append(AccessibilityText(label->innerText(), LabelByElementText, labelObject));
+            String innerText = label->innerText();
+            if (!innerText.isEmpty())
+                textOrder.append(AccessibilityText(innerText, LabelByElementText, labelObject));
             return;
         }
     }