Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / page-scaled-touch-gesture-click.html
blobe44c4d131772c37783455fd89df13d96092296d4
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <style type="text/css">
6 ::-webkit-scrollbar {
7 width: 0px;
8 height: 0px;
10 #touchtarget {
11 width: 100px;
12 height: 100px;
13 background: blue;
15 </style>
16 </head>
17 <body style="width: 2000px; height: 2000px" onload="runTest();">
18 <div id="touchtarget">
20 <p id="description"></p>
21 <div id="console"></div>
23 <script>
24 var clickEventsReceived = 0;
25 var expectedMouseEvents = 4;
26 var mouseEventsReceived = 0;
27 var eventTypes = [ 'mousemove', 'mousedown', 'mouseup', 'click' ];
29 function gestureEventCallback(event)
31 if (window.eventSender) {
32 shouldBeEqualToString('event.type', eventTypes[mouseEventsReceived]);
33 shouldBe('event.clientX', '20');
34 shouldBe('event.clientY', '24');
35 shouldBe("event.shiftKey", "false");
36 shouldBe("event.altKey", "false");
37 shouldBe("event.ctrlKey", "false");
38 shouldBe("event.metaKey", "false");
39 mouseEventsReceived++;
40 } else {
41 debug(event.type);
42 debug(event.clientX);
43 debug(event.clientY);
47 // Because we may not have a gesture recognizer, we send a key press
48 // event to end the test without temporal flakiness.
49 function quitKeyToEndTest(event) {
50 endTest();
53 // Log that we still got the touch events.
54 function touchEventCallback(event) {
55 touchEventsReceived++;
56 debug('have received: ' + touchEventsReceived + ' touch events');
57 return true;
60 function endTest()
62 if (mouseEventsReceived < expectedMouseEvents) {
63 debug('Gesture manager not implemented on this platform.');
65 // Bail.
66 isSuccessfullyParsed();
67 testRunner.notifyDone();
70 function runTest() {
71 if (window.internals) {
72 internals.setPageScaleFactorLimits(0.5, 0.5);
73 internals.setPageScaleFactor(0.5);
76 var div = document.getElementById('touchtarget');
77 div.addEventListener("mousedown", gestureEventCallback, false);
78 div.addEventListener("click", gestureEventCallback, false);
79 div.addEventListener("mouseup", gestureEventCallback, false);
80 div.addEventListener("mousemove", gestureEventCallback, false);
81 document.addEventListener("keydown", quitKeyToEndTest, false);
83 if (window.testRunner)
84 testRunner.waitUntilDone();
86 if (window.eventSender && window.internals) {
87 description("This tests basic single touch gesture generation.");
88 if (eventSender.clearTouchPoints) {
89 eventSender.gestureTap(10, 12);
90 eventSender.leapForward(10);
91 eventSender.keyDown(' ');
92 } else {
93 endTest();
95 } else {
96 debug("This test requires DumpRenderTree. Tap on the blue rect to log.")
99 </script>
100 </body>
101 </html>