AX: event.target should sometimes be a descendant element on AXPress-triggered mouse clicks
https://bugs.webkit.org/show_bug.cgi?id=135689
Reviewed by Mario Sanchez Prada.
Source/WebCore:
When trying to find the right sub-node to target, we need to go back up the parent chain to find
an Element, in case we land on a Text node for example.
Test: accessibility/press-target-uses-text-descendant-node.html
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::press):
LayoutTests:
* accessibility/press-target-uses-text-descendant-node-expected.txt: Added.
* accessibility/press-target-uses-text-descendant-node.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/accessibility/press-target-uses-text-descendant-node.html b/LayoutTests/accessibility/press-target-uses-text-descendant-node.html
new file mode 100644
index 0000000..a39abfa
--- /dev/null
+++ b/LayoutTests/accessibility/press-target-uses-text-descendant-node.html
@@ -0,0 +1,56 @@
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+<script type="text/javascript">
+ function handleClick(e) {
+ if (e.target.classList.contains("target")) {
+ debug("Clicked on element: " + e.target.nodeName);
+ }
+ return false;
+ }
+</script>
+<style type="text/css">
+ a:link, button {
+ padding: 10px;
+ margin: 10px;
+ background-color: red;
+ display: inline-block;
+ }
+ .target {
+ background-color: yellow;
+ }
+</style>
+</head>
+<body>
+
+<a href="#" onclick="return handleClick(event);" id="link">
+ <span class="target">click only works on span inside link, not red link edges</span>
+</a>
+
+<button onclick="return handleClick(event);" id="button">
+ <img src="resources/cake.png" alt="click only works on image inside button, not red button edges" class="target" onload="startTest();">
+</button>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+ description("Make sure that when performing a press, we target the deepest descendant, but also one that is an Element at the least.");
+
+ function startTest() {
+ accessibilityController.accessibleElementById("link").press();
+ debug("\nNow pressing on button\n");
+ accessibilityController.accessibleElementById("button").press();
+ finishJSTest();
+ }
+
+ if (window.accessibilityController) {
+ window.jsTestIsAsync = true;
+ }
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>