Accessibility objects contained in links should honor the aria-haspopup attribute...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jun 2019 18:59:18 +0000 (18:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jun 2019 18:59:18 +0000 (18:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199107
<rdar://problem/43663611>

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

Source/WebCore:

Tests: accessibility/ios-simulator/button-with-aria-haspopup-role.html
       accessibility/ios-simulator/element-haspopup.html

If an accessibility object is contained within an <a>, we should check
the aria-haspopup attribute on the ancestor <a> element. This was done
before in the iOS WebKit accessibility bunddle override.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::hasPopup const):

Tools:

iOS implementation for AccessibilityUIElement::hasPopup.
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::hasPopup const):

LayoutTests:

* accessibility/element-haspopup-expected.txt:
* accessibility/element-haspopup.html: Added cases for a <p> element contained within <a>.
* accessibility/ios-simulator/button-with-aria-haspopup-role-expected.txt: Added.
* accessibility/ios-simulator/button-with-aria-haspopup-role.html: Added. Existed for MacOS and now also for iOS.
* accessibility/ios-simulator/element-haspopup-expected.txt: Copied from LayoutTests/accessibility/element-haspopup-expected.txt.
* accessibility/ios-simulator/element-haspopup.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/element-haspopup-expected.txt
LayoutTests/accessibility/element-haspopup.html
LayoutTests/accessibility/ios-simulator/button-with-aria-haspopup-role-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/button-with-aria-haspopup-role.html [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/element-haspopup-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/element-haspopup.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm

index f7d9b7b..c64ce1f 100644 (file)
@@ -1,3 +1,18 @@
+2019-06-22  Andres Gonzalez  <andresg_22@apple.com>
+
+        Accessibility objects contained in links should honor the aria-haspopup attribute in the ancestor link.
+        https://bugs.webkit.org/show_bug.cgi?id=199107
+        <rdar://problem/43663611>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/element-haspopup-expected.txt:
+        * accessibility/element-haspopup.html: Added cases for a <p> element contained within <a>.
+        * accessibility/ios-simulator/button-with-aria-haspopup-role-expected.txt: Added.
+        * accessibility/ios-simulator/button-with-aria-haspopup-role.html: Added. Existed for MacOS and now also for iOS.
+        * accessibility/ios-simulator/element-haspopup-expected.txt: Copied from LayoutTests/accessibility/element-haspopup-expected.txt.
+        * accessibility/ios-simulator/element-haspopup.html: Added.
+
 2019-06-21  Sihui Liu  <sihui_liu@apple.com>
 
         openDatabase should return an empty object when WebSQL is disabled
index c7b511c..0ccc44f 100644 (file)
@@ -1,4 +1,10 @@
 Link 1 Link 2
+Paragraph 1.
+
+Paragraph 2.
+
+Paragraph 3.
+
 This tests that an element will report that it has a popup correctly.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,6 +12,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS accessibilityController.focusedElement.hasPopup is true
 PASS accessibilityController.focusedElement.hasPopup is false
+PASS p1.hasPopup is true
+PASS p2.hasPopup is false
+PASS p3.hasPopup is false
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 50c48ca..2cf0c31 100644 (file)
@@ -8,20 +8,39 @@
 <a href="#" aria-haspopup="true" tabindex="0" id="link1">Link 1</a>
 <a href="#" aria-haspopup="false" tabindex="0" id="link2">Link 2</a>
 
+<a href="#" aria-haspopup="true" tabindex="0" id="link3">
+    <p id="paragraph1">Paragraph 1.</p>
+</a>
+
+<a href="#" aria-haspopup="false" tabindex="0" id="link4">
+    <p id="paragraph2">Paragraph 2.</p>
+</a>
+
+<a href="#" tabindex="0" id="link5">
+    <p id="paragraph3">Paragraph 3.</p>
+</a>
+
 <p id="description"></p>
 <div id="console"></div>
 
 <script>
-
     description("This tests that an element will report that it has a popup correctly.");
 
     if (window.accessibilityController) {
-
         document.getElementById("link1").focus();
         shouldBe("accessibilityController.focusedElement.hasPopup", "true");
 
         document.getElementById("link2").focus();
         shouldBe("accessibilityController.focusedElement.hasPopup", "false");
+
+        var p1 = accessibilityController.accessibleElementById("paragraph1");
+        shouldBe("p1.hasPopup", "true");
+
+        var p2 = accessibilityController.accessibleElementById("paragraph2");
+        shouldBe("p2.hasPopup", "false");
+
+        var p3 = accessibilityController.accessibleElementById("paragraph3");
+        shouldBe("p3.hasPopup", "false");
     }
 
 </script>
diff --git a/LayoutTests/accessibility/ios-simulator/button-with-aria-haspopup-role-expected.txt b/LayoutTests/accessibility/ios-simulator/button-with-aria-haspopup-role-expected.txt
new file mode 100644 (file)
index 0000000..409c859
--- /dev/null
@@ -0,0 +1,19 @@
+This tests the platform attributes exposed for buttons with aria-haspopup
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS element.hasAttribute('aria-haspopup') is true
+test1 has trait haspopup = true with aria-haspopup attribute = dialog
+test2 has trait haspopup = true with aria-haspopup attribute = grid
+test3 has trait haspopup = true with aria-haspopup attribute = listbox
+test4 has trait haspopup = true with aria-haspopup attribute = menu
+test5 has trait haspopup = true with aria-haspopup attribute = tree
+test6 has trait haspopup = false with aria-haspopup attribute = null
+test7 has trait haspopup = false with aria-haspopup attribute = false
+test8 has trait haspopup = false with aria-haspopup attribute = foo
+test9 has trait haspopup = false with aria-haspopup attribute = 
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/button-with-aria-haspopup-role.html b/LayoutTests/accessibility/ios-simulator/button-with-aria-haspopup-role.html
new file mode 100644 (file)
index 0000000..3da94b3
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<div id="content">
+  <div id="test0" role="button" aria-haspopup="true">X</div>
+  <div id="test1" role="button" aria-haspopup="dialog">X</div>
+  <div id="test2" role="button" aria-haspopup="grid">X</div>
+  <div id="test3" role="button" aria-haspopup="listbox">X</div>
+  <div id="test4" role="button" aria-haspopup="menu">X</div>
+  <div id="test5" role="button" aria-haspopup="tree">X</div>
+  <div id="test6" role="button">X</div>
+  <div id="test7" role="button" aria-haspopup="false">X</div>
+  <div id="test8" role="button" aria-haspopup="foo">X</div>
+  <div id="test9" role="button" aria-haspopup="">X</div>
+</div>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the platform attributes exposed for buttons with aria-haspopup");
+    if (window.accessibilityController) {
+        // Get the document and accessibility elements for test0 to be used as reference.
+        var element = document.getElementById("test0");
+        shouldBe("element.hasAttribute('aria-haspopup')", "true");
+        var axElement = accessibilityController.accessibleElementById("test0");
+        var haspopupTraits = axElement.traits;
+
+        for (var i = 1; i <= 9; i++) {
+            var element = document.getElementById("test" + i);
+            var popup = element.getAttribute("aria-haspopup");
+            var axElement = accessibilityController.accessibleElementById("test" + i);
+            var sameTraits = axElement.traits == haspopupTraits;
+            debug("test" + i + " has trait haspopup = " + sameTraits + " with aria-haspopup attribute = " + popup);
+        }
+
+        document.getElementById("content").style.visibility = "hidden";
+    }
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/accessibility/ios-simulator/element-haspopup-expected.txt b/LayoutTests/accessibility/ios-simulator/element-haspopup-expected.txt
new file mode 100644 (file)
index 0000000..0ccc44f
--- /dev/null
@@ -0,0 +1,21 @@
+Link 1 Link 2
+Paragraph 1.
+
+Paragraph 2.
+
+Paragraph 3.
+
+This tests that an element will report that it has a popup correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS accessibilityController.focusedElement.hasPopup is true
+PASS accessibilityController.focusedElement.hasPopup is false
+PASS p1.hasPopup is true
+PASS p2.hasPopup is false
+PASS p3.hasPopup is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/element-haspopup.html b/LayoutTests/accessibility/ios-simulator/element-haspopup.html
new file mode 100644 (file)
index 0000000..2c008b9
--- /dev/null
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<a href="#" aria-haspopup="true" tabindex="0" id="link1">Link 1</a>
+<a href="#" aria-haspopup="false" tabindex="0" id="link2">Link 2</a>
+
+<a href="#" aria-haspopup="true" tabindex="0" id="link3">
+    <p id="paragraph1">Paragraph 1.</p>
+</a>
+
+<a href="#" aria-haspopup="false" tabindex="0" id="link4">
+    <p id="paragraph2">Paragraph 2.</p>
+</a>
+
+<a href="#" tabindex="0" id="link5">
+    <p id="paragraph3">Paragraph 3.</p>
+</a>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that an element will report that it has a popup correctly.");
+
+    if (window.accessibilityController) {
+        document.getElementById("link1").focus();
+        shouldBe("accessibilityController.focusedElement.hasPopup", "true");
+
+        document.getElementById("link2").focus();
+        shouldBe("accessibilityController.focusedElement.hasPopup", "false");
+
+        var p1 = accessibilityController.accessibleElementById("paragraph1");
+        shouldBe("p1.hasPopup", "true");
+
+        var p2 = accessibilityController.accessibleElementById("paragraph2");
+        shouldBe("p2.hasPopup", "false");
+
+        var p3 = accessibilityController.accessibleElementById("paragraph3");
+        shouldBe("p3.hasPopup", "false");
+    }
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 13a931d..315e0a3 100644 (file)
@@ -1,3 +1,20 @@
+2019-06-22  Andres Gonzalez  <andresg_22@apple.com>
+
+        Accessibility objects contained in links should honor the aria-haspopup attribute in the ancestor link.
+        https://bugs.webkit.org/show_bug.cgi?id=199107
+        <rdar://problem/43663611>
+
+        Reviewed by Chris Fleizach.
+
+        Tests: accessibility/ios-simulator/button-with-aria-haspopup-role.html
+               accessibility/ios-simulator/element-haspopup.html
+
+        If an accessibility object is contained within an <a>, we should check
+        the aria-haspopup attribute on the ancestor <a> element. This was done
+        before in the iOS WebKit accessibility bunddle override.
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::hasPopup const):
+
 2019-06-22  Robin Morisset  <rmorisset@apple.com> and Yusuke Suzuki  <ysuzuki@apple.com>
 
         All prototypes should call didBecomePrototype()
index edbdb81..85f6e2f 100644 (file)
@@ -1029,10 +1029,14 @@ bool AccessibilityRenderObject::hasTextAlternative() const
     // override the "label" element association.
     return ariaAccessibilityDescription().length();
 }
-    
+
 bool AccessibilityRenderObject::hasPopup() const
 {
-    return !equalLettersIgnoringASCIICase(hasPopupValue(), "false");
+    // Return true if this has the aria-haspopup attribute, or if it has an ancestor of type link with the aria-haspopup attribute.
+    return AccessibilityObject::matchedParent(*this, true, [this] (const AccessibilityObject& object) {
+        return (this == &object) ? !equalLettersIgnoringASCIICase(object.hasPopupValue(), "false")
+            : object.isLink() && !equalLettersIgnoringASCIICase(object.hasPopupValue(), "false");
+    });
 }
 
 bool AccessibilityRenderObject::supportsARIADropping() const 
index ef1250a..7f03a28 100644 (file)
@@ -1,3 +1,15 @@
+2019-06-22  Andres Gonzalez  <andresg_22@apple.com>
+
+        Accessibility objects contained in links should honor the aria-haspopup attribute in the ancestor link.
+        https://bugs.webkit.org/show_bug.cgi?id=199107
+        <rdar://problem/43663611>
+
+        Reviewed by Chris Fleizach.
+
+        iOS implementation for AccessibilityUIElement::hasPopup.
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::hasPopup const):
+
 2019-06-22  Konstantin Tokarev  <annulen@yandex.ru>
 
         Unreviewed, add myself to CMake watchlist
index c60640e..f34deed 100644 (file)
@@ -86,6 +86,7 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 - (CGRect)accessibilityVisibleContentRect;
 - (NSString *)accessibilityTextualContext;
 - (NSString *)accessibilityRoleDescription;
+- (BOOL)accessibilityHasPopup;
 - (NSString *)accessibilityColorStringValue;
 
 // TextMarker related
@@ -1054,7 +1055,7 @@ bool AccessibilityUIElement::isMultiLine() const
 
 bool AccessibilityUIElement::hasPopup() const
 {
-    return false;
+    return [m_element accessibilityHasPopup];
 }
 
 void AccessibilityUIElement::takeFocus()