d58a8551288c18537200c82665ae07e8bdb3ce93
[WebKit-https.git] / LayoutTests / fast / events / touch / gesture / gesture-dblclick.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body onload="runTest();">
7 <div id="gesture">
8
9 <p id="description"></p>
10 <div id="console"></div>
11
12 <script>
13 var expectedEvents = [
14   {type: 'mousemove', x: 10, y: 12, detail: 0 },
15   {type: 'mousedown', x: 10, y: 12, detail: 1 },
16   {type: 'mouseup', x: 10, y: 12, detail: 1 },
17   {type: 'click', x: 10, y: 12, detail: 1 },
18   {type: 'mousemove', x: 11, y: 12, detail: 0 },
19   {type: 'mousedown', x: 11, y: 12, detail: 2 },
20   {type: 'mouseup', x: 11, y: 12, detail: 2 },
21   {type: 'click', x: 11, y: 12, detail: 2 },
22   {type: 'dblclick', x: 11, y: 12, detail: 2 },
23   ];
24
25 var mouseEventsReceived = 0;
26
27 function gestureEventCallback(event)
28 {
29     if (window.eventSender) {
30         shouldBeEqualToString('event.type', expectedEvents[mouseEventsReceived].type);
31         shouldEvaluateTo('event.clientX', expectedEvents[mouseEventsReceived].x);
32         shouldEvaluateTo('event.clientY', expectedEvents[mouseEventsReceived].y);
33         shouldEvaluateTo('event.detail', expectedEvents[mouseEventsReceived].detail);
34         mouseEventsReceived++;
35     } else {
36         debug(event.type);
37         debug(event.clientX);
38         debug(event.clientY);
39         debug(event.detail);
40     }
41 }
42
43 // Because we may not have a gesture recognizer, we send a key press
44 // event to end the test without temporal flakiness.
45 function quitKeyToEndTest(event) {
46     endTest();
47 }
48
49 function endTest()
50 {
51     if (mouseEventsReceived < expectedEvents.length) {
52         debug('Gesture manager not implemented on this platform.');
53     }
54     // Bail.
55     isSuccessfullyParsed();
56     testRunner.notifyDone();
57 }
58
59 function runTest() {
60     var div = document.getElementById('gesture');
61     div.addEventListener("mousedown", gestureEventCallback, false);
62     div.addEventListener("click", gestureEventCallback, false);
63     div.addEventListener("dblclick", gestureEventCallback, false);
64     div.addEventListener("mouseup", gestureEventCallback, false);
65     div.addEventListener("mousemove", gestureEventCallback, false);
66     document.addEventListener("keydown", quitKeyToEndTest, false);
67
68     if (window.testRunner) {
69         testRunner.dumpAsText();
70         testRunner.waitUntilDone();
71     }
72
73     if (window.eventSender) {
74         description("This tests gesture callbacks for a double tap sequence of gestures.");
75         eventSender.gestureTap(10, 12);
76         eventSender.leapForward(10);
77         eventSender.gestureTap(11, 12, 2);
78         eventSender.leapForward(50);
79         eventSender.keyDown(' ');
80     } else {
81         debug("This test requires DumpRenderTree.")
82     }
83 }
84 </script>
85 </body>
86 </html>