3 <script src=
"../../../../resources/js-test.js"></script>
4 <link rel=
"stylesheet" href=
"../resources/touch-hover-active-tests.css">
5 <style type=
"text/css">
12 <div id=
"box" class=
"touch-interactive">Gestures go here
</div>
14 <p id=
"description"></p>
15 <p>See https://bugs.webkit.org/show_bug.cgi?id=
96060 for details
</p>
17 <div id=
"console"></div>
19 <script src=
"../resources/touch-hover-active-tests.js"></script>
21 var box
= document
.getElementById("box");
22 description("Tests that tap gesture events set and clear the active state of elements.");
26 if (!window
.eventSender
) {
27 debug('This test requires DRT.');
31 if (!eventSender
.gestureShowPress
) {
32 debug('GestureShowPress is not supported by this platform');
36 if (window
.testRunner
) {
37 window
.jsTestIsAsync
= true;
38 testRunner
.waitUntilDone();
41 debug("Verify active isn't initially set");
42 shouldBeDefault("getHoverActiveState(box)");
44 debug("Verify showPress, tap sets and clears active");
45 eventSender
.gestureTapDown(50, 50);
46 eventSender
.gestureShowPress(50, 50);
47 shouldBeHoveredAndActive("getHoverActiveState(box)");
48 eventSender
.gestureTap(50, 50);
49 // FIXME: Enable after implementing mocked timers (http://crbug.com/319529)
50 // shouldBeHoveredAndActive("getHoverActiveState(box)");
51 waitUntilActiveCleared();
54 function waitUntilActiveCleared()
56 if (getHoverActiveState(box
) == "hoveredAndActive") {
57 return setTimeout(waitUntilActiveCleared
, 10);
60 shouldBeOnlyHovered("getHoverActiveState(box)");
62 debug("Verify showPress, tapCancel on the element sets and clears active");
63 eventSender
.gestureTapDown(50, 50);
64 eventSender
.gestureShowPress(50, 50);
65 shouldBeHoveredAndActive("getHoverActiveState(box)");
66 eventSender
.gestureTapCancel(50, 50);
67 shouldBeOnlyHovered("getHoverActiveState(box)");
69 debug("Verify tap elsewhere still clears active");
70 eventSender
.gestureTapDown(50, 50);
71 eventSender
.gestureShowPress(50, 50);
72 shouldBeHoveredAndActive("getHoverActiveState(box)");
73 eventSender
.gestureTap(400, 250);
74 // FIXME: Remove after mocked timers added (http://crbug.com/319529)
75 waitUntilAnotherActiveCleared();
78 function waitUntilAnotherActiveCleared()
80 if (getHoverActiveState(box
) == "hoveredAndActive") {
81 return setTimeout(waitUntilAnotherActiveCleared
, 10);
84 shouldBeDefault("getHoverActiveState(box)");
86 debug("Verify tapCancel elsewhere still clears active");
87 eventSender
.gestureTapDown(50, 50);
88 eventSender
.gestureShowPress(50, 50);
89 shouldBeHoveredAndActive("getHoverActiveState(box)");
90 eventSender
.gestureTapCancel(400, 250);
91 shouldBeDefault("getHoverActiveState(box)");
93 debug("Verify that touchStart doesn't trigger active state");
94 eventSender
.addTouchPoint(50, 50);
95 eventSender
.touchStart();
96 shouldBeDefault("getHoverActiveState(box)");
97 eventSender
.releaseTouchPoint(0);
98 eventSender
.touchEnd();
100 debug("Verify that touchStart/touchEnd doesn't cancel active");
101 eventSender
.gestureTapDown(50, 50);
102 eventSender
.gestureShowPress(50, 50);
103 shouldBeHoveredAndActive("getHoverActiveState(box)");
104 eventSender
.addTouchPoint(50, 50);
105 eventSender
.touchStart();
106 shouldBeHoveredAndActive("getHoverActiveState(box)");
107 eventSender
.releaseTouchPoint(0);
108 eventSender
.touchEnd();
109 shouldBeHoveredAndActive("getHoverActiveState(box)");
110 eventSender
.gestureTapCancel(50, 50);
111 shouldBeOnlyHovered("getHoverActiveState(box)");
116 window
.onload
= runTests
;