a256caf0c9399bb3e3cf0e11f6e835357c4ed6f6
[WebKit-https.git] / LayoutTests / fast / events / touch / emulated-touch-iframe.html
1 <html>
2 <script src="../../js/resources/js-test-pre.js"></script>
3 <body>
4 <iframe style="position:absolute; top:100px; left:100px;" src="./resources/emulated-touch-iframe2.html"></iframe>
5 <p>Test touchend events are emulated in iframes correctly.</p>
6 <div id="console"></div>
7 <script type="text/javascript">
8
9 var touchstartCount = 0;
10 var touchmoveCount = 0;
11 var EXPECTED_TOUCHSTART_COUNT = 1;
12 var EXPECTED_TOUCHMOVE_COUNT = 1;
13 var shouldBail;
14
15 function testComplete()
16 {
17     if (shouldBail)
18         return;
19
20     if (touchstartCount > EXPECTED_TOUCHSTART_COUNT) {
21         debug("touchstart fired for the top frame, too, but should only fire for the iframe!");
22         shouldBail = true;
23     }
24
25     if (!touchmoveCount)
26         debug("touchmove not fired for the iframe!");
27     else if (touchmoveCount > EXPECTED_TOUCHMOVE_COUNT)
28         debug("touchmove fired too many times!");
29
30     debug("touchend (test will time out if broken)");
31     window.internals.settings.setTouchEventEmulationEnabled(false);
32     window.testRunner.notifyDone();
33 }
34
35 function handleTouchmove()
36 {
37     ++touchmoveCount;
38 }
39
40 function handleTouchstart()
41 {
42     ++touchstartCount;
43 }
44
45 function runTest() {
46     if (window.eventSender && window.internals && window.internals.settings) {
47         window.eventSender.dragMode = false;
48         window.internals.settings.setTouchEventEmulationEnabled(true);
49
50         eventSender.mouseMoveTo(110, 110);
51         eventSender.mouseDown(0);
52         eventSender.mouseMoveTo(120, 130);
53         eventSender.mouseUp(0);
54     } else
55        debug('This test requires DRT.');
56 }
57
58 if (window.testRunner)
59     window.testRunner.waitUntilDone();
60
61 </script>
62 </body>
63 </html>