2012-01-27 19:06:41 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
2012-07-20 19:17:58 +00:00
|
|
|
<script src="../http/tests/resources/js-test-pre.js"></script>
|
|
|
|
<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
|
2012-01-27 19:06:41 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div>
|
|
|
|
<div id="target1"></div>
|
|
|
|
<div id="target2"></div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
description("Test calling lock when already in a locked state.")
|
|
|
|
window.jsTestIsAsync = true;
|
|
|
|
|
|
|
|
targetdiv1 = document.getElementById("target1");
|
|
|
|
targetdiv2 = document.getElementById("target2");
|
|
|
|
|
2012-06-07 22:40:19 +00:00
|
|
|
// Expect change event only for all transitions below.
|
2012-06-12 03:02:16 +00:00
|
|
|
expectedTargetToBeLockedString = "";
|
2014-07-08 22:36:24 +00:00
|
|
|
document.onpointerlockchange = function ()
|
2012-06-12 03:02:16 +00:00
|
|
|
{
|
2014-07-08 22:36:24 +00:00
|
|
|
testPassed("document.onpointerlockchange event received.");
|
|
|
|
shouldBe("document.pointerLockElement", expectedTargetToBeLockedString);
|
2012-07-09 21:19:26 +00:00
|
|
|
doNextStepWithUserGesture();
|
2012-06-12 03:02:16 +00:00
|
|
|
};
|
2014-07-08 22:36:24 +00:00
|
|
|
document.onpointerlockerror =
|
|
|
|
function () { testFailed("document.onpointerlockerror event received."); finishJSTest(); };
|
2012-06-07 22:40:19 +00:00
|
|
|
|
2012-01-27 19:06:41 +00:00
|
|
|
var expectTarget1Unlock = false;
|
2014-07-08 22:36:24 +00:00
|
|
|
targetdiv1.addEventListener("pointerlocklost",
|
2012-01-27 19:06:41 +00:00
|
|
|
function () { shouldBe("expectTarget1Unlock", "true"); });
|
|
|
|
|
2012-06-15 19:53:27 +00:00
|
|
|
var expectTarget2Unlock = false;
|
2014-07-08 22:36:24 +00:00
|
|
|
targetdiv2.addEventListener("pointerlocklost",
|
2012-06-15 19:53:27 +00:00
|
|
|
function () { shouldBe("expectTarget2Unlock", "true"); });
|
2012-01-27 19:06:41 +00:00
|
|
|
|
|
|
|
todo = [
|
|
|
|
function () {
|
2014-07-08 22:36:24 +00:00
|
|
|
shouldBe("document.pointerLockElement", "null");
|
2012-06-15 19:53:27 +00:00
|
|
|
debug(" Locking targetdiv1.")
|
2014-07-08 22:36:24 +00:00
|
|
|
targetdiv1.requestPointerLock();
|
2012-06-15 19:53:27 +00:00
|
|
|
expectedTargetToBeLockedString = "targetdiv1";
|
2014-07-08 22:36:24 +00:00
|
|
|
// doNextStep() called by onpointerlockchange handler.
|
2012-06-15 19:53:27 +00:00
|
|
|
},
|
|
|
|
function () {
|
|
|
|
debug(" Locking targetdiv1, again.")
|
2014-07-08 22:36:24 +00:00
|
|
|
targetdiv1.requestPointerLock();
|
2012-06-15 19:53:27 +00:00
|
|
|
expectedTargetToBeLockedString = "targetdiv1";
|
2014-07-08 22:36:24 +00:00
|
|
|
// doNextStep() called by onpointerlockchange handler.
|
2012-06-15 19:53:27 +00:00
|
|
|
},
|
|
|
|
function () {
|
|
|
|
debug(" Locking targetdiv2.")
|
|
|
|
expectTarget1Unlock = true;
|
2014-07-08 22:36:24 +00:00
|
|
|
targetdiv2.requestPointerLock();
|
2012-06-15 19:53:27 +00:00
|
|
|
expectedTargetToBeLockedString = "targetdiv2";
|
2014-07-08 22:36:24 +00:00
|
|
|
// doNextStep() called by onpointerlockchange handler.
|
2012-06-15 19:53:27 +00:00
|
|
|
},
|
2012-01-27 19:06:41 +00:00
|
|
|
];
|
2012-07-09 21:19:26 +00:00
|
|
|
doNextStepWithUserGesture();
|
2012-01-27 19:06:41 +00:00
|
|
|
</script>
|
2012-07-20 19:17:58 +00:00
|
|
|
<script src="../http/tests/resources/js-test-post.js"></script>
|
2012-01-27 19:06:41 +00:00
|
|
|
</body>
|
|
|
|
</html>
|