file_pointerLockPref.html (2416B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602 5 --> 6 <head> 7 <title>Bug 633602</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"> 9 </script> 10 <script src="/tests/SimpleTest/EventUtils.js"> 11 </script> 12 <script type="application/javascript" src="pointerlock_utils.js"></script> 13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 14 </head> 15 <body> 16 <a target="_blank" 17 href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> 18 Mozilla Bug 633602</a> 19 <p id="display"></p> 20 <div id="div"></div> 21 <pre id="test"> 22 <script type="application/javascript"> 23 /* 24 * Test for Bug 633602 25 * Tests full-screen-api.pointer-lock pref 26 */ 27 28 SimpleTest.waitForExplicitFinish(); 29 30 var div = document.getElementById("div") 31 , prefEnabled = false 32 , prefDisabled = false; 33 34 function runTests () { 35 ok(prefEnabled, "Element should be able to lock the pointer " + 36 "if pointer-lock pref is set to TRUE"); 37 ok(prefDisabled, "Element should NOT be able to lock the pointer " + 38 "if pointer-lock pref is set to FALSE"); 39 } 40 41 document.addEventListener("pointerlockchange", function (e) { 42 if (document.pointerLockElement === div) { 43 prefEnabled = true; 44 document.exitPointerLock(); 45 } 46 else { 47 SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", 48 false ); 49 div.requestPointerLock(); 50 } 51 }); 52 53 document.addEventListener("pointerlockerror", function (e) { 54 prefDisabled = true; 55 addFullscreenChangeContinuation("exit", function() { 56 SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", 57 true ); 58 runTests(); 59 SimpleTest.finish(); 60 }); 61 document.exitFullscreen(); 62 }); 63 64 function start() { 65 addFullscreenChangeContinuation("enter", function() { 66 SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", 67 true ); 68 div.requestPointerLock(); 69 }); 70 div.requestFullscreen(); 71 } 72 </script> 73 </pre> 74 </body> 75 </html>