Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: timelapse
Fetching contributors…

Cannot retrieve contributors at this time

104 lines (99 sloc) 3.991 kB
<!DOCTYPE HTML>
<html>
<head>
<script src="../http/tests/resources/js-test-pre.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>
<script src="../http/tests/resources/js-test-post.js"></script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.