Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / gesture / gesture-tap-near-iframe.html
blob4602570e6d5c4d4b28534f8553aacde3289c8e73
1 <!DOCTYPE HTML>
2 <script src="../../../../resources/js-test.js"></script>
3 <style>
5 #container {
6 position: absolute;
7 right: 0;
8 top: 0;
9 padding: 50px;
12 #frame {
13 width: 75px;
14 height: 75px;
15 border: 1px solid black;
18 </style>
20 <div id=container>
21 <iframe id=frame></iframe>
22 </div>
24 <script>
25 description("Verify that in the absence of any reason to adjust into an iframe, taps are handle in the frame matching the center point of the tap. bug 401504");
27 var sawClick = false;
29 function nodeName(node) {
30 var name = node.nodeName;
31 if (node.id)
32 name += '#' + node.id;
33 return name;
36 document.addEventListener('click', function(e) {
37 sawClick = true;
38 debug("Received click on " + nodeName(e.target));
39 });
41 function doTap(name, x, y, expectFrame) {
42 // Sanity check
43 var e = document.elementFromPoint(x, y);
44 var onFrame = e == frame;
45 if (onFrame != expectFrame)
46 testFailed("Point-based hit-test returned unexpected element: " + nodeName(e));
48 eventSender.gestureTapDown(x, y);
49 eventSender.gestureShowPress(x, y);
50 debug("Sending GestureTap " + name);
51 sawClick = false;
52 eventSender.gestureTap(x, y);
53 shouldBe('sawClick', onFrame ? 'false' : 'true');
54 debug("");
57 var rect = frame.getBoundingClientRect();
59 var midx = rect.left + rect.width / 2;
60 var midy = rect.top + rect.height / 2;
61 doTap("on top of iframe", midx, midy, true);
62 doTap("above iframe", midx, rect.top - 1, false);
63 doTap("to the left of iframe", rect.left - 1, midy, false);
64 doTap("to the right of iframe", rect.right + 1, midy, false);
65 doTap("below iframe", midx, rect.bottom + 1, false);
66 </script>