1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/pointerlock/file_pointerLockPref.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 + <!-- 1.7 + https://bugzilla.mozilla.org/show_bug.cgi?id=633602 1.8 + --> 1.9 + <head> 1.10 + <title>Bug 633602</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> 1.12 + </script> 1.13 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"> 1.14 + </script> 1.15 + <script type="application/javascript" src="pointerlock_utils.js"></script> 1.16 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.17 + </head> 1.18 + <body> 1.19 + <a target="_blank" 1.20 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> 1.21 + Mozilla Bug 633602</a> 1.22 + <p id="display"></p> 1.23 + <div id="div"></div> 1.24 + <pre id="test"> 1.25 + <script type="application/javascript"> 1.26 + /* 1.27 + * Test for Bug 633602 1.28 + * Tests full-screen-api.pointer-lock pref 1.29 + */ 1.30 + 1.31 + SimpleTest.waitForExplicitFinish(); 1.32 + 1.33 + var div = document.getElementById("div") 1.34 + , prefEnabled = false 1.35 + , prefDisabled = false; 1.36 + 1.37 + function runTests () { 1.38 + ok(prefEnabled, "Element should be able to lock the pointer " + 1.39 + "if pointer-lock pref is set to TRUE"); 1.40 + ok(prefDisabled, "Element should NOT be able to lock the pointer " + 1.41 + "if pointer-lock pref is set to FALSE"); 1.42 + } 1.43 + 1.44 + document.addEventListener("mozpointerlockchange", function (e) { 1.45 + if (document.mozPointerLockElement === div) { 1.46 + prefEnabled = true; 1.47 + document.mozExitPointerLock(); 1.48 + } 1.49 + else { 1.50 + SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", 1.51 + false ); 1.52 + div.mozRequestPointerLock(); 1.53 + } 1.54 + }, false); 1.55 + 1.56 + document.addEventListener("mozpointerlockerror", function (e) { 1.57 + prefDisabled = true; 1.58 + document.mozCancelFullScreen(); 1.59 + }, false); 1.60 + 1.61 + document.addEventListener("mozfullscreenchange", function (e) { 1.62 + if (document.mozFullScreenElement === div) { 1.63 + SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", 1.64 + true ); 1.65 + div.mozRequestPointerLock(); 1.66 + } 1.67 + else { 1.68 + SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", 1.69 + true ); 1.70 + runTests(); 1.71 + SimpleTest.finish(); 1.72 + } 1.73 + }, false); 1.74 + 1.75 + function start() { 1.76 + div.mozRequestFullScreen(); 1.77 + } 1.78 + </script> 1.79 + </pre> 1.80 + </body> 1.81 +</html>