blob: e2ef0dd9c4cfc3e48f824d1e13bbcfb589410375 [file] [log] [blame]
[email protected]4e3ee162012-07-13 20:37:501<!DOCTYPE HTML>
2<html>
3<head>
[email protected]efb086342013-11-05 00:56:214<script src="../resources/js-test.js"></script>
[email protected]c7c9cfba2012-07-20 19:17:585<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
[email protected]4e3ee162012-07-13 20:37:506</head>
7<body>
8<div>
9 <iframe id="iframe1"></iframe>
10 <div id="target2"></div>
11</div>
12<script>
13 description("Test removing a locked element from a document causes lock to be released.")
14 window.jsTestIsAsync = true;
15
16 targetIframe1 = document.getElementById("iframe1");
17 targetDiv2 = document.getElementById("target2");
18
19 todo = [
20 function () {
21 // Load a blank iframe.
22 targetIframe1.src = "about:blank";
23 targetIframe1.onload = function () { doNextStepWithUserGesture(); }
24 },
25 function () {
26 // Nest target element into iframe document.
27 targetIframe1.contentDocument.body.innerHTML ="<div><div></div></div>";
28 targetDiv1 = targetIframe1.contentDocument.body.firstChild.firstChild
29 expectNoEvents("Lock target in iframe. (main document handler).");
30 expectOnlyChangeEvent("Lock target in iframe. (iframe handler)", targetIframe1.contentDocument);
[email protected]133ede92014-05-09 17:42:2231 targetDiv1.requestPointerLock();
[email protected]4e3ee162012-07-13 20:37:5032 // doNextStep called by event handler.
33 },
34 function () {
[email protected]ea5cec422014-05-16 19:07:4535 shouldBe("targetIframe1.contentDocument.pointerLockElement", "targetDiv1");
[email protected]4e3ee162012-07-13 20:37:5036 shouldBe("targetDiv1.parentElement.parentElement", "targetIframe1.contentDocument.body");
37 expectOnlyErrorEvent("Remove targetDiv1's parent from iframe & immediately lock target2. (main document handler)");
38 expectOnlyChangeEvent("Remove targetDiv1's parent from iframe & immediately lock target2. (iframe handler)", targetIframe1.contentDocument);
39 targetDiv1.parentElement.parentElement.removeChild(targetDiv1.parentElement);
[email protected]133ede92014-05-09 17:42:2240 targetDiv2.requestPointerLock();
[email protected]ea5cec422014-05-16 19:07:4541 shouldBe("document.pointerLockElement", "null");
[email protected]4e3ee162012-07-13 20:37:5042 shouldBe("targetDiv1.parentElement.parentElement", "null");
43 // doNextStep called by event handler.
44 },
[email protected]005057e52012-07-16 20:48:4045 function () {
46 // Absorb an extra doNextStep() from previous event handlers.
47 },
[email protected]4e3ee162012-07-13 20:37:5048 ];
49 doNextStep();
50</script>
[email protected]4e3ee162012-07-13 20:37:5051</body>
52</html>