blob: c8a0e4cf20fd2ba4495550bba9328379d887892b [file] [log] [blame]
<!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>
<div>
<iframe id="iframe1"></iframe>
<div id="target2"></div>
</div>
<script>
description("Test removing an iframe containing a locked element causes lock to be released.")
window.jsTestIsAsync = true;
targetIframe1 = document.getElementById("iframe1");
targetDiv2 = document.getElementById("target2");
todo = [
function () {
// Load a blank iframe.
targetIframe1.src = "about:blank";
targetIframe1.onload = function () { doNextStepWithUserGesture(); }
},
function () {
// Nest target element into iframe document.
targetIframe1.contentDocument.body.innerHTML ="<div><div></div></div>";
targetDiv1 = targetIframe1.contentDocument.body.firstChild.firstChild
expectNoEvents("Lock target in iframe. (main document handler)");
expectOnlyChangeEvent("Lock target in iframe. (iframe handler)", targetIframe1.contentDocument);
targetDiv1.requestPointerLock();
// doNextStep called by event handler.
},
function () {
shouldBe("targetIframe1.contentDocument.pointerLockElement", "targetDiv1");
shouldBe("targetDiv1.parentElement.parentElement", "targetIframe1.contentDocument.body");
expectOnlyChangeEvent("Remove iframe & immediately lock target2. (main document handler)");
expectNoEvents("Remove iframe & immediately lock target2. (iframe handler)", targetIframe1.contentDocument);
targetIframe1.parentElement.removeChild(targetIframe1);
targetDiv2.requestPointerLock();
shouldBe("document.pointerLockElement", "null");
// doNextStep called by event handler.
},
];
doNextStep();
</script>
<script src="../http/tests/resources/js-test-post.js"></script>
</body>
</html>