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 } | 13 } |
14 </style> | 14 </style> |
15 <iframe frameborder=0 id="target" src="resources/event-delegator.html"></iframe> | 15 <iframe frameborder=0 id="target" src="resources/event-delegator.html"></iframe> |
16 <div id=console></div> | 16 <div id=console></div> |
17 <script> | 17 <script> |
18 var event; | 18 var event; |
19 window.scrollTo(0, 3); | 19 var scrollOffset = 3; |
Rick Byers
2014/10/10 00:39:35
nit: call this windowScrollOffset (to avoid confus
| |
20 window.scrollTo(0, scrollOffset); | |
20 var rect = target.getBoundingClientRect(); | 21 var rect = target.getBoundingClientRect(); |
21 var point = { | 22 var point = { |
22 x: rect.left + rect.width / 2, | 23 x: rect.left + rect.width / 2, |
23 y: rect.top + rect.height / 2 - 3 | 24 y: rect.top + rect.height / 2 |
24 }; | 25 }; |
25 | 26 |
26 var eventReceived = {}; | 27 var eventReceived = {}; |
27 | 28 |
28 function onEventInFrame(e) { | 29 function onEventInFrame(e) { |
29 debug("Received " + e.type + " in child frame"); | 30 debug("Received " + e.type + " in child frame"); |
30 event = e; | 31 event = e; |
31 eventReceived[e.type] = true; | 32 eventReceived[e.type] = true; |
32 shouldBe("event.screenX", "point.x"); | 33 shouldBe("event.screenX", "point.x"); |
33 shouldBe("event.screenY", "point.y"); | 34 shouldBe("event.screenY", "point.y"); |
34 shouldBe("event.clientX", "50 / 2"); | 35 shouldBe("event.clientX", "point.x"); |
Rick Byers
2014/10/10 00:39:35
using "point" here seems wrong because point is in
Zeeshan Qureshi
2014/10/10 00:47:23
That looks more readable, will update.
| |
35 shouldBe("event.clientY", "50 / 2 + 7"); | 36 shouldBe("event.clientY", "point.y + scrollOffset"); |
Rick Byers
2014/10/10 00:39:35
Ok so it looks like the real problem here is that
| |
36 } | 37 } |
37 | 38 |
38 description("Verifies that a tap occuring in a scrolled iframe has the correct c o-ordinates"); | 39 description("Verifies that a tap occuring in a scrolled iframe has the correct c o-ordinates"); |
39 | 40 |
40 if (window.eventSender) { | 41 if (window.eventSender) { |
41 jsTestIsAsync = true; | 42 jsTestIsAsync = true; |
42 target.onload = function() { | 43 target.onload = function() { |
43 target.contentWindow.scrollTo(0, 7); | 44 target.contentWindow.scrollTo(0, 7); |
44 | 45 |
45 debug("Sending GestureTapDown to " + point.x + "," + point.y); | 46 debug("Sending GestureTapDown to " + point.x + "," + point.y); |
46 eventSender.gestureTapDown(point.x, point.y); | 47 eventSender.gestureTapDown(point.x, point.y); |
47 | 48 |
48 debug("Sending GestureShowPress"); | 49 debug("Sending GestureShowPress"); |
49 eventSender.gestureShowPress(point.x, point.y); | 50 eventSender.gestureShowPress(point.x, point.y); |
50 | 51 |
51 debug("Sending GestureTap"); | 52 debug("Sending GestureTap"); |
52 eventSender.gestureTap(point.x, point.y); | 53 eventSender.gestureTap(point.x, point.y); |
53 | 54 |
54 shouldBeTrue("eventReceived.mousemove"); | 55 shouldBeTrue("eventReceived.mousemove"); |
55 shouldBeTrue("eventReceived.mousedown"); | 56 shouldBeTrue("eventReceived.mousedown"); |
56 shouldBeTrue("eventReceived.mouseup"); | 57 shouldBeTrue("eventReceived.mouseup"); |
57 shouldBeTrue("eventReceived.click"); | 58 shouldBeTrue("eventReceived.click"); |
58 setTimeout(finishJSTest, 100); | 59 setTimeout(finishJSTest, 100); |
59 } | 60 } |
60 } else { | 61 } else { |
61 debug("This test requires eventSender"); | 62 debug("This test requires eventSender"); |
62 } | 63 } |
63 </script> | 64 </script> |
OLD | NEW |