OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <script src="../../../../resources/js-test.js"></script> | 2 <script src="../../../../resources/js-test.js"></script> |
3 <style> | 3 <style> |
4 html, body { | 4 html, body { |
5 margin: 0; | 5 margin: 0; |
6 } | 6 } |
7 body { | 7 body { |
8 height: 1000px; | 8 height: 1000px; |
9 } | 9 } |
10 #target { | 10 #target { |
11 width: 50px; | 11 width: 50px; |
12 height: 50px; | 12 height: 50px; |
| 13 margin: 5px 0px 0px 5px; |
13 } | 14 } |
14 </style> | 15 </style> |
15 <iframe frameborder=0 id="target" src="resources/event-delegator.html"></iframe> | 16 <iframe frameborder=0 id="target" src="resources/event-delegator.html"></iframe> |
16 <div id=console></div> | 17 <div id=console></div> |
17 <script> | 18 <script> |
18 var event; | 19 var event; |
19 window.scrollTo(0, 3); | 20 var windowScrollOffset = { |
20 var rect = target.getBoundingClientRect(); | 21 x: 0, |
21 var point = { | 22 y: 3 |
22 x: rect.left + rect.width / 2, | 23 }; |
23 y: rect.top + rect.height / 2 - 3 | 24 var frameScrollOffset = { |
| 25 x: 2, |
| 26 y: 7 |
| 27 }; |
| 28 window.scrollTo(windowScrollOffset.x, windowScrollOffset.y); |
| 29 var frameRect = target.getBoundingClientRect(); |
| 30 var pointInFrame = { |
| 31 x: frameRect.width / 2, |
| 32 y: frameRect.height / 2 |
| 33 }; |
| 34 var pointInWindow = { |
| 35 x: frameRect.left + pointInFrame.x, |
| 36 y: frameRect.top + pointInFrame.y |
24 }; | 37 }; |
25 | 38 |
26 var eventReceived = {}; | 39 var eventReceived = {}; |
27 | 40 |
28 function onEventInFrame(e) { | 41 function onEventInFrame(e) { |
29 debug("Received " + e.type + " in child frame"); | 42 debug("Received " + e.type + " in child frame"); |
30 event = e; | 43 event = e; |
31 eventReceived[e.type] = true; | 44 eventReceived[e.type] = true; |
32 shouldBe("event.screenX", "point.x"); | 45 shouldBe("event.screenX", "pointInWindow.x"); |
33 shouldBe("event.screenY", "point.y"); | 46 shouldBe("event.screenY", "pointInWindow.y"); |
34 shouldBe("event.clientX", "50 / 2"); | 47 shouldBe("event.clientX", "pointInFrame.x"); |
35 shouldBe("event.clientY", "50 / 2 + 7"); | 48 shouldBe("event.clientY", "pointInFrame.y"); |
| 49 shouldBe("event.pageX", "pointInFrame.x + frameScrollOffset.x"); |
| 50 shouldBe("event.pageY", "pointInFrame.y + frameScrollOffset.y"); |
36 } | 51 } |
37 | 52 |
38 description("Verifies that a tap occuring in a scrolled iframe has the correct c
o-ordinates"); | 53 description("Verifies that a tap occuring in a scrolled iframe has the correct c
o-ordinates"); |
39 | 54 |
40 if (window.eventSender) { | 55 if (window.eventSender) { |
41 jsTestIsAsync = true; | 56 jsTestIsAsync = true; |
42 target.onload = function() { | 57 target.onload = function() { |
43 target.contentWindow.scrollTo(0, 7); | 58 target.contentWindow.scrollTo(frameScrollOffset.x, frameScrollOffset.y); |
44 | 59 |
45 debug("Sending GestureTapDown to " + point.x + "," + point.y); | 60 debug("Sending GestureTapDown to " + pointInWindow.x + "," + pointInWind
ow.y); |
46 eventSender.gestureTapDown(point.x, point.y); | 61 eventSender.gestureTapDown(pointInWindow.x, pointInWindow.y); |
47 | 62 |
48 debug("Sending GestureShowPress"); | 63 debug("Sending GestureShowPress"); |
49 eventSender.gestureShowPress(point.x, point.y); | 64 eventSender.gestureShowPress(pointInWindow.x, pointInWindow.y); |
50 | 65 |
51 debug("Sending GestureTap"); | 66 debug("Sending GestureTap"); |
52 eventSender.gestureTap(point.x, point.y); | 67 eventSender.gestureTap(pointInWindow.x, pointInWindow.y); |
53 | 68 |
54 shouldBeTrue("eventReceived.mousemove"); | 69 shouldBeTrue("eventReceived.mousemove"); |
55 shouldBeTrue("eventReceived.mousedown"); | 70 shouldBeTrue("eventReceived.mousedown"); |
56 shouldBeTrue("eventReceived.mouseup"); | 71 shouldBeTrue("eventReceived.mouseup"); |
57 shouldBeTrue("eventReceived.click"); | 72 shouldBeTrue("eventReceived.click"); |
58 setTimeout(finishJSTest, 100); | 73 setTimeout(finishJSTest, 100); |
59 } | 74 } |
60 } else { | 75 } else { |
61 debug("This test requires eventSender"); | 76 debug("This test requires eventSender"); |
62 } | 77 } |
63 </script> | 78 </script> |
OLD | NEW |