4 <script src=
"../resources/js-test.js"></script>
5 <script src=
"../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
9 <div id=
"target1"></div>
10 <div id=
"target2"></div>
13 description("Test calling lock when already in a locked state.")
14 window
.jsTestIsAsync
= true;
16 targetdiv1
= document
.getElementById("target1");
17 targetdiv2
= document
.getElementById("target2");
19 // Expect change event only for all transitions below.
20 expectedTargetToBeLockedString
= "";
21 document
.onpointerlockchange = function ()
23 testPassed("document.onpointerlockchange event received.");
24 shouldBe("document.pointerLockElement", expectedTargetToBeLockedString
);
25 doNextStepWithUserGesture();
27 document
.onpointerlockerror
=
28 function () { testFailed("document.onpointerlockerror event received."); finishJSTest(); };
32 shouldBe("document.pointerLockElement", "null");
33 debug(" Locking targetdiv1.")
34 targetdiv1
.requestPointerLock();
35 expectedTargetToBeLockedString
= "targetdiv1";
36 // doNextStep() called by onpointerlockchange handler.
39 debug(" Locking targetdiv1, again.")
40 targetdiv1
.requestPointerLock();
41 expectedTargetToBeLockedString
= "targetdiv1";
42 // doNextStep() called by onpointerlockchange handler.
45 debug(" Locking targetdiv2.")
46 targetdiv2
.requestPointerLock();
47 expectedTargetToBeLockedString
= "targetdiv2";
48 // doNextStep() called by onpointerlockchange handler.
51 doNextStepWithUserGesture();