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 width: 2000px; |
7 body { | 7 height: 2000px; |
8 height: 1000px; | |
9 } | |
10 #target { | |
11 width: 50px; | |
12 height: 50px; | |
13 } | 8 } |
14 </style> | 9 </style> |
15 <iframe frameborder=0 id="target" src="resources/event-delegator.html"></iframe> | |
16 <div id=console></div> | 10 <div id=console></div> |
17 <script> | 11 <script> |
18 var event; | 12 var event; |
19 window.scrollTo(0, 3); | 13 var scrollOffset = { |
20 var rect = target.getBoundingClientRect(); | 14 x: 12, |
| 15 y: 42 |
| 16 }; |
21 var point = { | 17 var point = { |
22 x: rect.left + rect.width / 2, | 18 x: 50, |
23 y: rect.top + rect.height / 2 - 3 | 19 y: 50 |
24 }; | 20 }; |
25 | 21 |
26 var eventReceived = {}; | 22 var eventReceived = {}; |
27 | 23 |
28 function onEventInFrame(e) { | 24 function onEvent(e) { |
29 debug("Received " + e.type + " in child frame"); | 25 debug("Received " + e.type + " in page"); |
30 event = e; | 26 event = e; |
31 eventReceived[e.type] = true; | 27 eventReceived[e.type] = true; |
32 shouldBe("event.screenX", "point.x"); | 28 shouldBe("event.screenX", "point.x"); |
33 shouldBe("event.screenY", "point.y"); | 29 shouldBe("event.screenY", "point.y"); |
34 shouldBe("event.clientX", "50 / 2"); | 30 shouldBe("event.clientX", "point.x"); |
35 shouldBe("event.clientY", "50 / 2 + 7"); | 31 shouldBe("event.clientY", "point.y"); |
| 32 shouldBe("event.pageX", "point.x + scrollOffset.x"); |
| 33 shouldBe("event.pageY", "point.y + scrollOffset.y"); |
36 } | 34 } |
37 | 35 |
38 description("Verifies that a tap occuring in a scrolled iframe has the correct c
o-ordinates"); | 36 var eventTypes = ['mousemove', 'mousedown', 'mouseup', 'click']; |
| 37 for (var i = 0; i < eventTypes.length; i++) |
| 38 document.addEventListener(eventTypes[i],onEvent); |
| 39 |
| 40 description("Verifies that a tap occuring in a scrolled page has the correct co-
ordinates"); |
39 | 41 |
40 if (window.eventSender) { | 42 if (window.eventSender) { |
41 jsTestIsAsync = true; | 43 jsTestIsAsync = true; |
42 target.onload = function() { | 44 window.onload = function() { |
43 target.contentWindow.scrollTo(0, 7); | 45 window.scrollTo(scrollOffset.x, scrollOffset.y); |
44 | 46 |
45 debug("Sending GestureTapDown to " + point.x + "," + point.y); | 47 debug("Sending GestureTapDown to " + point.x + "," + point.y); |
46 eventSender.gestureTapDown(point.x, point.y); | 48 eventSender.gestureTapDown(point.x, point.y); |
47 | 49 |
48 debug("Sending GestureShowPress"); | 50 debug("Sending GestureShowPress"); |
49 eventSender.gestureShowPress(point.x, point.y); | 51 eventSender.gestureShowPress(point.x, point.y); |
50 | 52 |
51 debug("Sending GestureTap"); | 53 debug("Sending GestureTap"); |
52 eventSender.gestureTap(point.x, point.y); | 54 eventSender.gestureTap(point.x, point.y); |
53 | 55 |
54 shouldBeTrue("eventReceived.mousemove"); | 56 shouldBeTrue("eventReceived.mousemove"); |
55 shouldBeTrue("eventReceived.mousedown"); | 57 shouldBeTrue("eventReceived.mousedown"); |
56 shouldBeTrue("eventReceived.mouseup"); | 58 shouldBeTrue("eventReceived.mouseup"); |
57 shouldBeTrue("eventReceived.click"); | 59 shouldBeTrue("eventReceived.click"); |
58 setTimeout(finishJSTest, 100); | 60 setTimeout(finishJSTest, 100); |
59 } | 61 } |
60 } else { | 62 } else { |
61 debug("This test requires eventSender"); | 63 debug("This test requires eventSender"); |
62 } | 64 } |
63 </script> | 65 </script> |
OLD | NEW |