| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js">
</script> | 5 <script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js">
</script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <div> | 8 <div> |
| 9 <div id="target1"></div> | 9 <div id="target1"></div> |
| 10 <div id="target2"></div> | 10 <div id="target2"></div> |
| 11 </div> | 11 </div> |
| 12 <script> | 12 <script> |
| 13 description("Test calling lock when already in a locked state.") | 13 description("Test calling lock when already in a locked state.") |
| 14 window.jsTestIsAsync = true; | 14 window.jsTestIsAsync = true; |
| 15 | 15 |
| 16 targetdiv1 = document.getElementById("target1"); | 16 targetdiv1 = document.getElementById("target1"); |
| 17 targetdiv2 = document.getElementById("target2"); | 17 targetdiv2 = document.getElementById("target2"); |
| 18 | 18 |
| 19 // Expect change event only for all transitions below. | 19 // Expect change event only for all transitions below. |
| 20 expectedTargetToBeLockedString = ""; | 20 expectedTargetToBeLockedString = ""; |
| 21 document.onpointerlockchange = function () | 21 document.onpointerlockchange = function () |
| 22 { | 22 { |
| 23 testPassed("document.onpointerlockchange event received."); | 23 testPassed("document.onpointerlockchange event received."); |
| 24 shouldBe("document.pointerLockElement", expectedTargetToBeLockedStri
ng); | 24 shouldBe("document.pointerLockElement", expectedTargetToBeLockedStri
ng); |
| 25 doNextStepWithUserGesture(); | 25 doNextStepWithUserGesture(); |
| 26 }; | 26 }; |
| 27 document.onpointerlockerror = | 27 document.onpointerlockerror = |
| 28 function () { testFailed("document.onpointerlockerror event received.");
finishJSTest(); }; | 28 function () { testFailed("document.onpointerlockerror event received.");
finishJSTest(); }; |
| 29 | 29 |
| 30 var expectTarget1Unlock = false; | |
| 31 targetdiv1.addEventListener("webkitpointerlocklost", | |
| 32 function () { shouldBe("expectTarget1Unlock", "true"); }); | |
| 33 | |
| 34 var expectTarget2Unlock = false; | |
| 35 targetdiv2.addEventListener("webkitpointerlocklost", | |
| 36 function () { shouldBe("expectTarget2Unlock", "true"); }); | |
| 37 | |
| 38 todo = [ | 30 todo = [ |
| 39 function () { | 31 function () { |
| 40 shouldBe("document.pointerLockElement", "null"); | 32 shouldBe("document.pointerLockElement", "null"); |
| 41 debug(" Locking targetdiv1.") | 33 debug(" Locking targetdiv1.") |
| 42 targetdiv1.requestPointerLock(); | 34 targetdiv1.requestPointerLock(); |
| 43 expectedTargetToBeLockedString = "targetdiv1"; | 35 expectedTargetToBeLockedString = "targetdiv1"; |
| 44 // doNextStep() called by onpointerlockchange handler. | 36 // doNextStep() called by onpointerlockchange handler. |
| 45 }, | 37 }, |
| 46 function () { | 38 function () { |
| 47 debug(" Locking targetdiv1, again.") | 39 debug(" Locking targetdiv1, again.") |
| 48 targetdiv1.requestPointerLock(); | 40 targetdiv1.requestPointerLock(); |
| 49 expectedTargetToBeLockedString = "targetdiv1"; | 41 expectedTargetToBeLockedString = "targetdiv1"; |
| 50 // doNextStep() called by onpointerlockchange handler. | 42 // doNextStep() called by onpointerlockchange handler. |
| 51 }, | 43 }, |
| 52 function () { | 44 function () { |
| 53 debug(" Locking targetdiv2.") | 45 debug(" Locking targetdiv2.") |
| 54 expectTarget1Unlock = true; | |
| 55 targetdiv2.requestPointerLock(); | 46 targetdiv2.requestPointerLock(); |
| 56 expectedTargetToBeLockedString = "targetdiv2"; | 47 expectedTargetToBeLockedString = "targetdiv2"; |
| 57 // doNextStep() called by onpointerlockchange handler. | 48 // doNextStep() called by onpointerlockchange handler. |
| 58 }, | 49 }, |
| 59 ]; | 50 ]; |
| 60 doNextStepWithUserGesture(); | 51 doNextStepWithUserGesture(); |
| 61 </script> | 52 </script> |
| 62 </body> | 53 </body> |
| 63 </html> | 54 </html> |
| OLD | NEW |