Source/WebKit/chromium: Wire gesture tap events, add support for gesture events in...
[WebKit-https.git] / LayoutTests / fast / events / touch / gesture / gesture-click.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../../js/resources/js-test-style.css">
5 <script src="../../../js/resources/js-test-pre.js"></script>
6 <script src="../../../js/resources/js-test-post-function.js"></script>
7 </head>
8 <body onload="runTest();">
9 <div id="gesture">
10
11 <p id="description"></p>
12 <div id="console"></div>
13
14 <script>
15 var expectedMouseEvents = 4;
16 var mouseEventsReceived = 0;
17 var eventTypes = [ 'mousemove', 'mousedown', 'mouseup', 'click' ];
18
19 function gestureEventCallback(event)
20 {
21     if (window.eventSender) {
22         shouldBeEqualToString('event.type', eventTypes[mouseEventsReceived]);
23         shouldBe('event.clientX', '10');
24         shouldBe('event.clientY', '12');
25         mouseEventsReceived++;
26     } else {
27         debug(event.type);
28         debug(event.clientX);
29         debug(event.clientY);
30     }
31 }
32
33 // Because we may not have a gesture recognizer, we send a key press
34 // event to end the test without temporal flakiness.
35 function quitKeyToEndTest(event) {
36     endTest();
37 }
38
39 function endTest()
40 {
41     if (mouseEventsReceived < expectedMouseEvents) {
42         debug('Gesture manager not implemented on this platform.');
43     }
44     // Bail.
45     successfullyParsed = true;
46     isSuccessfullyParsed();
47     layoutTestController.notifyDone();
48 }
49
50 function runTest() {
51     var div = document.getElementById('gesture');
52     div.addEventListener("mousedown", gestureEventCallback, false);
53     div.addEventListener("click", gestureEventCallback, false);
54     div.addEventListener("mouseup", gestureEventCallback, false);
55     div.addEventListener("mousemove", gestureEventCallback, false);
56     document.addEventListener("keydown", quitKeyToEndTest, false);
57
58     if (window.layoutTestController) {
59         layoutTestController.dumpAsText();
60         layoutTestController.waitUntilDone();
61     }
62
63     if (window.eventSender) {
64         description("This tests basic gesture callbacks.");
65         // A 'tap' gesture event should generate a sequence of mouse events.
66         eventSender.gestureTap(10, 12);
67         eventSender.leapForward(10);
68         eventSender.keyDown(' ');
69     } else {
70         debug("This test requires DumpRenderTree.  Tap on the blue rect to log.")
71     }
72 }
73 </script>
74 </body>
75 </html>