summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-tap-hover-clear.html
blob: 4bf8a7ea326fd65e9ee9896b229c290f099f8679 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<script src="../../../js/resources/js-test-pre.js"></script>

<style type="text/css">
::-webkit-scrollbar {
    width: 0px;
    height: 0px;
}

div { 
    line-height: 100px;
}

#hoverme { 
    background-color: lightblue;
}

#clickme { 
    background-color: lightgreen;
}

#dontclickme {
    background-color: yellow;
    display: none; 
}

#hoverme:hover #dontclickme { 
    display: block;
}
</style>

<body style="margin:0">

<div id='hoverme'>Hover over me
  <div id='dontclickme'>Don't click me</div>
</div>
<div id='clickme'>Click me</div>

<p id="description"></p>
<p>See https://bugs.webkit.org/show_bug.cgi?id=103283 for details.</p>

<div id="console"></div>

<script>
description("Tests that hover effects from a gesture tap down can be cleared by a gesture tap or mousemove outside of the hovered element.");

var clickMe = document.getElementById('clickme');
var dontClickMe = document.getElementById('dontclickme');

function runTests()
{
    if (!window.eventSender) {
        debug('This test requires DRT.');
        return;
    }

    if (!eventSender.gestureShowPress || !eventSender.gestureTap || !eventSender.mouseMoveTo) {
        debug('GestureShowPress, GestureTap, or MouseMoveTo is not supported by this platform');
        return;
    }

    debug("The Don't Click Me div should not be visible.");
    shouldBe("dontClickMe.offsetTop", "0");

    debug("The Don't Click Me div should be visible after a GestureShowPress on the Hover Over Me div.");
    shouldBe(document.elementFromPoint(50, 50).id, "hoverme");
    eventSender.gestureShowPress(50, 50);
    shouldBe("dontClickMe.offsetTop", "100");

    debug("The Don't Click Me div should not be visible after a GestureTap on the Click Me div.");
    shouldBe(document.elementFromPoint(250, 250).id, "clickme");
    eventSender.gestureTap(250, 250);
    shouldBe("dontClickMe.offsetTop", "0");

    debug("The Don't Click Me div should be visible after a GestureShowPress on the Hover Over Me div.");
    shouldBe(document.elementFromPoint(50, 50).id, "hoverme");
    eventSender.gestureShowPress(50, 50);
    shouldBe("dontClickMe.offsetTop", "100");

    debug("The Don't Click Me div should not be visible after a mouse move to below the Click Me div.");
    eventSender.mouseMoveTo(350, 350);
    shouldBe("dontClickMe.offsetTop", "0");
}

runTests();
</script>
</body>
</html>