-
Notifications
You must be signed in to change notification settings - Fork 54
/
mouse-dblclick-event.html
55 lines (54 loc) · 1.93 KB
/
mouse-dblclick-event.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Double Click</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style type="text/css">
.textarea
{
background: red;
width: 100px;
height: 100px;
color: white;
text-align: center;
font-family: monospace;
}
</style>
<script type="text/javascript">
// Send two continuous clicks.
function run() {
var testDoubleClick = async_test('Tests that the double click event is correctly generated by sending pointerDown, pointerUp, pointerDown and pointerUp for the mouse type.');
var elem = document.getElementById("click_area");
var actions_promise;
elem.addEventListener('dblclick', function(e) {
testDoubleClick.step(function () {
assert_equals(e.target.id, "click_area");
assert_equals(e.detail, 2);
});
// Make sure the test finishes after all the input actions are completed.
actions_promise.then( () => {
testDoubleClick.done();
});
});
actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: elem})
.pointerDown()
.pointerUp()
.pointerDown()
.pointerUp()
.send();
}
</script>
</head>
<body onload="run()">
<h1>Double Click</h1>
<p>Double-click on the text area and check if the "dblclick" event is received.</p>
<div id="click_area" class="textarea"></div>
</body>
</html>