blob: ccd27eab05866dbe3fa12aa4bb2e4ed6abf04bb5 (
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
90
91
92
93
94
95
96
97
98
99
100
101
102
|
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
</head>
<body id="body">
<div>
<div id="target1"></div>
<div id="target2"></div>
</div>
<script>
description("Test mouse events are routed to lock target.")
window.jsTestIsAsync = true;
targetdiv1 = document.getElementById("target1");
targetdiv2 = document.getElementById("target2");
// Expect change event only for all transitions below.
expectedTargetToBeLockedString = "";
document.onwebkitpointerlockchange = function ()
{
testPassed("document.onwebkitpointerlockchange event received.");
shouldBe("document.webkitPointerLockElement", expectedTargetToBeLockedString);
doNextStep();
};
document.onwebkitpointerlockerror =
function () { testFailed("document.onwebkitpointerlockerror event received."); finishJSTest(); };
function eventNotExpected(e) {
testFailed("Unexpected event " + e.type + " on " + e.currentTarget.id);
finishJSTest();
}
function eventExpected(e) {
testPassed("event type: " + e.type + ", target: " + e.target.id + ", received on: " + e.currentTarget.id);
}
todo = [
function () {
targetdiv1.webkitRequestPointerLock();
expectedTargetToBeLockedString = "targetdiv1";
// doNextStep() called by onwebkitpointerlockchange handler.
},
function () {
debug(" With a lock in place send a click.")
targetdiv1.onmousedown = eventExpected;
targetdiv2.onmousedown = eventNotExpected;
document.body.onmousedown = eventExpected;
if (window.eventSender) {
window.eventSender.leapForward(1000);
window.eventSender.mouseDown();
window.eventSender.mouseUp();
}
doNextStepWithUserGesture();
},
function () {
targetdiv2.webkitRequestPointerLock();
expectedTargetToBeLockedString = "targetdiv2";
// doNextStep() called by onwebkitpointerlockchange handler.
},
function () {
debug(" With a lock in place send a click.")
targetdiv1.onmousedown = eventNotExpected;
targetdiv2.onmousedown = eventExpected;
document.body.onmousedown = eventExpected;
if (window.eventSender) {
window.eventSender.leapForward(1000);
window.eventSender.mouseDown();
window.eventSender.mouseUp();
}
doNextStepWithUserGesture();
},
function () {
debug(" Ensure double clicks work as expected, sending 4 clicks.")
targetdiv1.onmousedown = undefined;
document.body.onmousedown = undefined;
targetdiv2.onmousedown = eventExpected;
targetdiv2.onmouseup = eventExpected;
targetdiv2.onclick = eventExpected;
targetdiv2.ondblclick = eventExpected;
debug(" Creating a click and dblclick.");
if (window.eventSender) {
window.eventSender.leapForward(1000);
window.eventSender.mouseDown();
window.eventSender.mouseUp();
window.eventSender.mouseDown();
window.eventSender.mouseUp();
}
debug(" Ensuring no false dblclicks if we continue.");
if (window.eventSender) {
window.eventSender.mouseDown();
window.eventSender.mouseUp();
window.eventSender.mouseDown();
window.eventSender.mouseUp();
}
doNextStepWithUserGesture();
},
];
doNextStepWithUserGesture();
</script>
</body>
</html>
|