file_doubleLock.html (1919B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602 5 --> 6 <head> 7 <title>Bug 633602 - file_doubleLockCallBack.html</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <script type="application/javascript" src="pointerlock_utils.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 <style type="text/css"> 13 #test-element { background-color: #94E01B; width:100px; height:100px; } 14 </style> 15 </head> 16 <body> 17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> 18 Mozilla Bug 633602</a> 19 <div id="div"></div> 20 <pre id="test"> 21 <script type="text/javascript"> 22 /* 23 * Test for Bug 633602 24 * If element requests pointerlock on itself while in pointerlock state 25 * pointerlockchange event should be dispatched 26 */ 27 28 SimpleTest.waitForExplicitFinish(); 29 30 var div = document.getElementById("div") 31 , numberOfLocks = 0; 32 33 function runTests () { 34 is(numberOfLocks, 2, "Requesting pointer lock on a locked element " + 35 "should dispatch pointerlockchange event"); 36 } 37 38 document.addEventListener("pointerlockchange", function (e) { 39 if (document.pointerLockElement === div) { 40 if (numberOfLocks === 2) { 41 addFullscreenChangeContinuation("exit", function() { 42 runTests(); 43 SimpleTest.finish(); 44 }); 45 document.exitFullscreen(); 46 } 47 else { 48 numberOfLocks++; 49 div.requestPointerLock(); 50 } 51 } 52 }); 53 54 function start() { 55 console.log('started'); 56 addFullscreenChangeContinuation("enter", function() { 57 div.requestPointerLock(); 58 }); 59 div.requestFullscreen(); 60 } 61 </script> 62 </pre> 63 </body> 64 </html>