2 <script src=
"../../../resources/js-test.js"></script>
9 border:
1px solid black;
33 <body onload=
"runTest()">
34 <iframe id=
"iframe1" src=
"./resources/multi-touch-inside-iframes2.html"></iframe>
35 <iframe id=
"iframe2" src=
"./resources/multi-touch-inside-iframes2.html"></iframe>
37 <p id=
"description"></p>
38 <div id=
"console"></div>
40 <script type=
"text/javascript">
41 description('Test multi-touch is sent to the same iframe.');
43 var touchEventCount
= 0;
46 function onTouch(event
, receiver
)
49 touchreceiver
= receiver
;
50 switch (touchEventCount
) {
52 shouldBeEqualToString('ev.type', 'touchstart');
53 shouldBeEqualToString('touchreceiver', 'iframe1');
54 shouldBe("ev.changedTouches.length", "1");
55 shouldBe("ev.touches.length", "1");
56 shouldBe("ev.targetTouches.length", "1");
57 shouldBe("ev.touches[0].pageX", "50");
58 shouldBe("ev.touches[0].pageY", "50");
59 shouldBe('ev.touches[0].identifier', '0');
60 shouldBeEqualToString('ev.touches[0].target.ownerDocument.title', 'iframe1');
61 shouldBeEqualToString('ev.changedTouches[0].target.ownerDocument.title', 'iframe1');
62 shouldBeEqualToString('ev.targetTouches[0].target.ownerDocument.title', 'iframe1');
65 shouldBeEqualToString('ev.type', 'touchmove');
66 shouldBeEqualToString('touchreceiver', 'iframe1');
67 shouldBe("ev.changedTouches.length", "1");
68 shouldBe("ev.touches.length", "2");
69 shouldBe("ev.targetTouches.length", "1");
70 shouldBe("ev.touches[0].pageX", "150");
71 shouldBe("ev.touches[0].pageY", "150");
72 shouldBe('ev.touches[0].identifier', '0');
73 shouldBe('ev.touches[1].identifier', '1');
74 shouldBe('ev.changedTouches[0].identifier', '0');
75 shouldBeEqualToString('ev.touches[0].target.ownerDocument.title', 'iframe1');
76 shouldBeEqualToString('ev.changedTouches[0].target.ownerDocument.title', 'iframe1');
77 shouldBeEqualToString('ev.targetTouches[0].target.ownerDocument.title', 'iframe1');
78 shouldBeEqualToString('ev.touches[1].target.nodeName', '#document');
79 shouldBeEqualToString('ev.touches[1].target.title', 'iframe1');
82 shouldBeEqualToString('ev.type', 'touchend');
83 shouldBeEqualToString('touchreceiver', 'iframe1');
84 shouldBe("ev.changedTouches.length", "1");
85 shouldBe("ev.touches.length", "1");
86 shouldBe("ev.targetTouches.length", "0");
87 shouldBeEqualToString('ev.changedTouches[0].target.ownerDocument.title', 'iframe1');
88 shouldBe('ev.changedTouches[0].identifier', '0');
89 shouldBeEqualToString('ev.touches[0].target.nodeName', '#document');
90 shouldBeEqualToString('ev.touches[0].target.title', 'iframe1');
91 shouldBe('ev.touches[0].identifier', '1');
94 shouldBeEqualToString('ev.type', 'touchstart');
95 shouldBeEqualToString('touchreceiver', 'iframe2');
96 shouldBe("ev.changedTouches.length", "1");
97 shouldBe("ev.touches.length", "1");
98 shouldBe("ev.targetTouches.length", "1");
99 shouldBe("ev.touches[0].pageX", "50");
100 shouldBe("ev.touches[0].pageY", "50");
101 shouldBeEqualToString('ev.touches[0].target.ownerDocument.title', 'iframe2');
102 shouldBeEqualToString('ev.changedTouches[0].target.ownerDocument.title', 'iframe2');
103 shouldBeEqualToString('ev.targetTouches[0].target.ownerDocument.title', 'iframe2');
106 shouldBeEqualToString('ev.type', 'touchend');
107 shouldBeEqualToString('touchreceiver', 'iframe2');
108 shouldBe("ev.changedTouches.length", "1");
109 shouldBe("ev.touches.length", "0");
110 shouldBe("ev.targetTouches.length", "0");
111 shouldBeEqualToString('ev.changedTouches[0].target.ownerDocument.title', 'iframe2');
112 isSuccessfullyParsed();
113 testRunner
.notifyDone();
119 document
.getElementById("iframe1").contentWindow
.document
.title
= "iframe1";
120 document
.getElementById("iframe2").contentWindow
.document
.title
= "iframe2";
121 if (window
.eventSender
) {
122 eventSender
.clearTouchPoints();
123 // Touch the center of iframe1. 50px is offset to iframe1 in main frame,
124 // 1px for the iframe border, 50px to get to centre.
125 debug('First touch is on iframe1.');
126 shouldBeEqualToString('document.elementFromPoint(101, 101).id', 'iframe1');
127 eventSender
.addTouchPoint(101, 101);
128 eventSender
.touchStart();
131 debug('Second touch is on iframe2, nothing should happen.');
132 shouldBeEqualToString('document.elementFromPoint(251, 101).id', 'iframe2');
133 eventSender
.addTouchPoint(251, 101);
134 eventSender
.touchStart();
137 debug('Moves the first touch outside iframe1.');
138 eventSender
.updateTouchPoint(0, 201, 201);
139 eventSender
.touchMove();
142 debug('Release the first touch.');
143 eventSender
.releaseTouchPoint(0);
144 eventSender
.touchEnd();
147 debug('Third touch is on iframe2, nothing should happen.');
148 shouldBeEqualToString('document.elementFromPoint(261, 101).id', 'iframe2');
149 eventSender
.addTouchPoint(261, 101);
150 eventSender
.touchStart();
153 debug('Release all touches on iframe2, and touch iframe2 again.');
154 eventSender
.releaseTouchPoint(0);
155 eventSender
.releaseTouchPoint(1);
156 eventSender
.touchEnd();
157 eventSender
.addTouchPoint(251, 101);
158 eventSender
.touchStart();
161 debug('Touch iframe1, nothing shoud happen.');
162 eventSender
.addTouchPoint(101, 101);
163 eventSender
.touchStart();
166 debug('Release all touches.');
167 eventSender
.releaseTouchPoint(0);
168 eventSender
.releaseTouchPoint(1);
169 eventSender
.touchEnd();
171 debug('This test requires DRT.');
175 if (window
.testRunner
) {
176 testRunner
.waitUntilDone();