blob: 7fbe76e0e22d01c35e9ac90f6db6bb5a1fbb6838 [file] [log] [blame]
cfleizach@apple.com46e76de2014-12-18 22:59:22 +00001<html>
2<head>
3<script src="../resources/js-test-pre.js"></script>
4<script type="text/javascript">
5 function handleClick(e) {
6 if (e.target.classList.contains("target")) {
7 debug("Clicked on element: " + e.target.nodeName);
8 }
9 return false;
10 }
11</script>
12<style type="text/css">
13 a:link, button {
14 padding: 10px;
15 margin: 10px;
16 background-color: red;
17 display: inline-block;
18 }
19 .target {
20 background-color: yellow;
21 }
22</style>
23</head>
24<body>
25
26<a href="#" onclick="return handleClick(event);" id="link">
27 <span class="target">click only works on span inside link, not red link edges</span>
28</a>
29
30<button onclick="return handleClick(event);" id="button">
31 <img src="resources/cake.png" alt="click only works on image inside button, not red button edges" class="target" onload="startTest();">
32</button>
33
34<p id="description"></p>
35<div id="console"></div>
36
37<script>
38
39 description("Make sure that when performing a press, we target the deepest descendant, but also one that is an Element at the least.");
40
n_wang@apple.com088469c2017-08-11 01:41:56 +000041 document.getElementById("link").addEventListener("click", pressedLink);
42 document.getElementById("button").addEventListener("click", pressedButton);
cfleizach@apple.com46e76de2014-12-18 22:59:22 +000043 function startTest() {
44 accessibilityController.accessibleElementById("link").press();
cfleizach@apple.com46e76de2014-12-18 22:59:22 +000045 }
46
47 if (window.accessibilityController) {
48 window.jsTestIsAsync = true;
49 }
n_wang@apple.com088469c2017-08-11 01:41:56 +000050
51 function pressedLink() {
52 debug("\nNow pressing on button\n");
53 accessibilityController.accessibleElementById("button").press();
54 }
55
56 function pressedButton() {
57 finishJSTest();
58 }
cfleizach@apple.com46e76de2014-12-18 22:59:22 +000059
60</script>
61
62<script src="../resources/js-test-post.js"></script>
63</body>
64</html>