forked from burg/timelapse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
click-count.html
61 lines (54 loc) · 1.76 KB
/
click-count.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
56
57
58
59
60
61
<html>
<head>
<script>
function log(string)
{
document.getElementById('output').innerHTML += string;
}
function mouseDown(evt)
{
log("<span style='color:green'>[Mouse Down]</span> Button: " + evt.button + " Click Count: " + evt.detail + "<br>");
}
function mouseUp(evt)
{
log("<span style='color:green'>[Mouse Up]</span> Button: " + evt.button + " Click Count: " + evt.detail + "<br>");
}
function mouseClick(evt)
{
log("<span style='color:green'>[Mouse Click]</span> Button: " + evt.button + " Click Count: " + evt.detail + "<br>");
}
function mouseDoubleClick(evt)
{
log("<span style='color:green'>[Mouse Double Click]</span> Button: " + evt.button + " Click Count: " + evt.detail + "<br>");
}
function test()
{
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
if (window.eventSender) {
var testEle = document.getElementById("testDiv");
eventSender.mouseMoveTo(testEle.offsetLeft+testEle.offsetWidth/2, testEle.offsetTop+testEle.offsetHeight/2);
testClick();
}
}
function testClick()
{
for (var clickCount = 1; clickCount <= 5; clickCount++) {
log("Clicking " + clickCount + " times<br>");
for (var click = 0; click < clickCount; click++) {
eventSender.mouseDown();
eventSender.mouseUp();
}
// Skip forward 1 second so that the clicks are counted as distinct.
eventSender.leapForward(1000);
}
testRunner.notifyDone();
}
</script>
</head>
<body onload="test()">
<div id="testDiv" style="-webkit-user-select: none; border:1px solid red" onmousedown="mouseDown(event)" onmouseup="mouseUp(event)" onclick="mouseClick(event)" ondblclick="mouseDoubleClick(event)">Click inside this div</div>
<p id="output">
</p>