4 <script src=
"../resources/js-test.js"></script>
5 <script src=
"../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
9 <iframe id=
"iframe1"></iframe>
10 <div id=
"target2"></div>
13 description("Test removing a locked element from a document causes lock to be released.")
14 window
.jsTestIsAsync
= true;
16 targetIframe1
= document
.getElementById("iframe1");
17 targetDiv2
= document
.getElementById("target2");
21 // Load a blank iframe.
22 targetIframe1
.src
= "about:blank";
23 targetIframe1
.onload = function () { doNextStepWithUserGesture(); }
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
);
31 targetDiv1
.requestPointerLock();
32 // doNextStep called by event handler.
35 shouldBe("targetIframe1.contentDocument.pointerLockElement", "targetDiv1");
36 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
);
40 targetDiv2
.requestPointerLock();
41 shouldBe("document.pointerLockElement", "null");
42 shouldBe("targetDiv1.parentElement.parentElement", "null");
43 // doNextStep called by event handler.
46 // Absorb an extra doNextStep() from previous event handlers.