AX: HTML datalist accessibility is not exposed by WebKit
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jul 2019 06:33:57 +0000 (06:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jul 2019 06:33:57 +0000 (06:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196998
<rdar://problem/49962521>

Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-07-09
Reviewed by Chris Fleizach.

Source/WebCore:

Input fields with datalist are exposed as having a listbox popup.

Test: accessibility/datalist.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::popupValue const):
(WebCore::AccessibilityObject::hasDatalist const):
* accessibility/AccessibilityObject.h:

LayoutTests:

* accessibility/datalist-expected.txt: Added.
* accessibility/datalist.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/datalist-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/datalist.html [new file with mode: 0644]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h

index bfee67e..6b0d6d8 100644 (file)
@@ -1,3 +1,14 @@
+2019-07-09  Andres Gonzalez  <andresg_22@apple.com>
+
+        AX: HTML datalist accessibility is not exposed by WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=196998
+        <rdar://problem/49962521>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/datalist-expected.txt: Added.
+        * accessibility/datalist.html: Added.
+
 2019-07-09  Saam Barati  <sbarati@apple.com>
 
         [WHLSL] Import another round of JS spec tests
diff --git a/LayoutTests/accessibility/datalist-expected.txt b/LayoutTests/accessibility/datalist-expected.txt
new file mode 100644 (file)
index 0000000..8a06330
--- /dev/null
@@ -0,0 +1,13 @@
+Websites 
+
+This tests that an input field with a datalist is conveyed as listbox popup.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS axInput.popupValue is 'listbox'
+PASS axInput.popupValue is 'listbox'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/datalist.html b/LayoutTests/accessibility/datalist.html
new file mode 100644 (file)
index 0000000..d29e25f
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+
+<div>
+    <label>
+        Websites <input id="input1" type="text" list="datalist1" />
+    </label>
+    <datalist id="datalist1">
+        <option value="https://www.apple.com/" label="Apple">Apple</option>
+        <option value="https://www.wikipedia.com/" label="Wikipedia">Wikipedia</option>
+    </datalist>
+</div>
+
+<div>
+    <input id="input2" type="search" placeholder="Fruits" list="fruits" />
+    <datalist id="fruits">
+        <select>
+            <option>Apple</option>
+            <option>Apricot</option>
+            <option>Banana</option>
+            <option>Cantaloupe</option>
+            <option>Durian</option>
+            <option>Grape</option>
+            <option>Guava</option>
+            <option>Orange</option>
+            <option>Mango</option>
+            <option>Pear</option>
+            <option>Watermelon</option>
+            <option></option>
+            <option disabled>Foo</option>
+        </select>
+    </datalist>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that an input field with a datalist is conveyed as listbox popup.");
+
+    if (window.accessibilityController) {
+        document.getElementById("input1").focus();
+        var axInput = accessibilityController.focusedElement;
+        shouldBe("axInput.popupValue", "'listbox'");
+
+        document.getElementById("input2").focus();
+        axInput = accessibilityController.focusedElement;
+        shouldBe("axInput.popupValue", "'listbox'");
+    }
+</script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index 918893a..ceaa3f5 100644 (file)
@@ -178,6 +178,7 @@ fast/history/page-cache-notification-non-suspendable.html
 fast/history/page-cache-notification-suspendable.html
 
 # Datalist is not yet enabled.
+accessibility/datalist.html [ Skip ]
 webkit.org/b/98934 fast/forms/datalist [ Skip ]
 
 # ENABLE_INPUT_TYPE_* are not enabled.
index 3f92c2d..3bae024 100644 (file)
@@ -56,6 +56,7 @@ http/tests/ssl/media-stream
 inspector/page/overrideSetting-MockCaptureDevicesEnabled.html [ Skip ]
 
 # Datalist is unsupported in WK1
+accessibility/datalist.html [ WontFix ]
 fast/forms/datalist [ WontFix ]
 imported/w3c/web-platform-tests/html/semantics/forms/the-datalist-element [ WontFix ]
 
index 525a242..f32b4a8 100644 (file)
@@ -550,6 +550,7 @@ pointer-lock/ [ Skip ]
 http/tests/pointer-lock/ [ Skip ]
 
 # Datalist is unsupported on Windows
+accessibility/datalist.html [ WontFix ]
 fast/forms/datalist [ WontFix ]
 imported/w3c/web-platform-tests/html/semantics/forms/the-datalist-element [ WontFix ]
 
index 4673698..3964d45 100644 (file)
@@ -1,3 +1,20 @@
+2019-07-09  Andres Gonzalez  <andresg_22@apple.com>
+
+        AX: HTML datalist accessibility is not exposed by WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=196998
+        <rdar://problem/49962521>
+
+        Reviewed by Chris Fleizach.
+
+        Input fields with datalist are exposed as having a listbox popup.
+
+        Test: accessibility/datalist.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::popupValue const):
+        (WebCore::AccessibilityObject::hasDatalist const):
+        * accessibility/AccessibilityObject.h:
+
 2019-07-09  Justin Fan  <justin_fan@apple.com>
 
         Replace old, broken WebGPU IDL spec link with the new one in IDL comments.
index bbea694..7d592b8 100644 (file)
@@ -48,6 +48,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameSelection.h"
+#include "HTMLDataListElement.h"
 #include "HTMLDetailsElement.h"
 #include "HTMLFormControlElement.h"
 #include "HTMLInputElement.h"
@@ -2767,7 +2768,7 @@ String AccessibilityObject::popupValue() const
     auto hasPopup = getAttribute(aria_haspopupAttr).convertToASCIILowercase();
     if (hasPopup.isNull() || hasPopup.isEmpty()) {
         // In ARIA 1.1, the implicit value for combobox became "listbox."
-        if (isComboBox())
+        if (isComboBox() || hasDatalist())
             return "listbox";
         return "false";
     }
@@ -2785,6 +2786,24 @@ String AccessibilityObject::popupValue() const
     return "false";
 }
 
+bool AccessibilityObject::hasDatalist() const
+{
+#if ENABLE(DATALIST_ELEMENT)
+    auto datalistId = getAttribute(listAttr);
+    if (datalistId.isNull() || datalistId.isEmpty())
+        return false;
+
+    auto element = this->element();
+    if (!element)
+        return false;
+
+    auto datalist = element->treeScope().getElementById(datalistId);
+    return is<HTMLDataListElement>(datalist);
+#else
+    return false;
+#endif
+}
+
 bool AccessibilityObject::supportsSetSize() const
 {
     return hasAttribute(aria_setsizeAttr);
index 7b763c7..4995a4a 100644 (file)
@@ -553,6 +553,7 @@ public:
 
     virtual bool hasPopup() const { return false; }
     String popupValue() const;
+    bool hasDatalist() const;
     bool supportsHasPopup() const;
     bool pressedIsPresent() const;
     bool ariaIsMultiline() const;