Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / multi-touch-inside-iframes.html
blobd7c9fe8f1371bd8309d380755b958f159edd2b9b
1 <html>
2 <script src="../../../resources/js-test.js"></script>
3 <style>
4 iframe {
5 width: 100px;
6 height: 100px;
7 margin: 0;
8 padding: 0;
9 border: 1px solid black;
12 #iframe1
14 position:absolute;
15 left:50px;
16 top:50px;
19 #iframe2
21 position:absolute;
22 left:200px;
23 top:50px;
26 #output
28 position:absolute;
29 top:150px;
32 </style>
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>
36 <div id="output">
37 <p id="description"></p>
38 <div id="console"></div>
39 </div>
40 <script type="text/javascript">
41 description('Test multi-touch is sent to the same iframe.');
43 var touchEventCount = 0;
44 var title = 0;
46 function onTouch(event, receiver)
48 ev = event;
49 touchreceiver = receiver;
50 switch (touchEventCount) {
51 case 0:
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');
63 break;
64 case 1:
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');
80 break;
81 case 2:
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');
92 break;
93 case 3:
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');
104 break;
105 case 4:
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();
115 touchEventCount++;
118 function runTest() {
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();
129 debug('');
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();
135 debug('');
137 debug('Moves the first touch outside iframe1.');
138 eventSender.updateTouchPoint(0, 201, 201);
139 eventSender.touchMove();
140 debug('');
142 debug('Release the first touch.');
143 eventSender.releaseTouchPoint(0);
144 eventSender.touchEnd();
145 debug('');
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();
151 debug('');
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();
159 debug('');
161 debug('Touch iframe1, nothing shoud happen.');
162 eventSender.addTouchPoint(101, 101);
163 eventSender.touchStart();
164 debug('');
166 debug('Release all touches.');
167 eventSender.releaseTouchPoint(0);
168 eventSender.releaseTouchPoint(1);
169 eventSender.touchEnd();
170 } else {
171 debug('This test requires DRT.');
175 if (window.testRunner) {
176 testRunner.waitUntilDone();
178 </script>
179 </body>
180 </html>