Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / gesture / gesture-tap-click-common-ancestor.html
blob41f5fdc4326f64d0731495c5302e1fb6c4f70782
1 <!DOCTYPE HTML>
2 <script src="../../../../resources/js-test.js"></script>
3 <style>
4 #target {
5 position: relative;
6 width: 100px;
7 height: 100px;
8 border: 1px solid black;
10 #target div {
11 position: absolute;
12 top: 0;
13 left: 0;
14 background-color: white;
15 width: 100px;
16 height: 100px;
18 #ancestor12 {
19 width: 0;
20 height: 0;
22 </style>
23 <div id=target>
24 <div id=ancestor12>
25 <div id=child1>1</div>
26 <div id=child2>2</div>
27 </div>
28 <div id=child3>3</div>
29 </div>
30 <div id=console></div>
31 <script>
33 description("Verifies that each mouse event that occurs when tapping on an element reflects the node under the point at the time of that event, and the click event goes to the common ancestor of the mousedown and mouseup events.");
35 var rect = target.getBoundingClientRect();
36 var point = {
37 x: rect.left + rect.width / 2,
38 y: rect.top + rect.height / 2
41 var event;
42 function expectEventOn(e, node) {
43 debug("Received " + e.type + " on " + (e.target.id || e.target.nodeName));
44 event = e;
45 shouldBeEqualToString('event.target.id', node.id);
46 node.style.visibility = 'hidden';
48 document.addEventListener('mousemove', function(e) {
49 expectEventOn(e, child3);
50 });
51 document.addEventListener('mousedown', function(e) {
52 expectEventOn(e, child2);
53 });
54 document.addEventListener('mouseup', function(e) {
55 expectEventOn(e, child1);
56 });
57 document.addEventListener('click', function(e) {
58 expectEventOn(e, ancestor12);
59 });
61 if (window.eventSender) {
62 debug("Sending GestureTapDown");
63 eventSender.gestureTapDown(point.x, point.y, 30, 30);
65 debug("Sending GestureShowPress");
66 eventSender.gestureShowPress(point.x, point.y, 30, 30);
68 debug("Sending GestureTap");
69 eventSender.gestureTap(point.x, point.y, 30, 30);
70 } else {
71 debug("This test requires eventSender");
73 </script>