|
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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> |
|
9 </script> |
|
10 <script type="application/javascript" 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("mozpointerlockchange", function (e) { |
|
42 if (document.mozPointerLockElement === div) { |
|
43 prefEnabled = true; |
|
44 document.mozExitPointerLock(); |
|
45 } |
|
46 else { |
|
47 SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", |
|
48 false ); |
|
49 div.mozRequestPointerLock(); |
|
50 } |
|
51 }, false); |
|
52 |
|
53 document.addEventListener("mozpointerlockerror", function (e) { |
|
54 prefDisabled = true; |
|
55 document.mozCancelFullScreen(); |
|
56 }, false); |
|
57 |
|
58 document.addEventListener("mozfullscreenchange", function (e) { |
|
59 if (document.mozFullScreenElement === div) { |
|
60 SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", |
|
61 true ); |
|
62 div.mozRequestPointerLock(); |
|
63 } |
|
64 else { |
|
65 SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", |
|
66 true ); |
|
67 runTests(); |
|
68 SimpleTest.finish(); |
|
69 } |
|
70 }, false); |
|
71 |
|
72 function start() { |
|
73 div.mozRequestFullScreen(); |
|
74 } |
|
75 </script> |
|
76 </pre> |
|
77 </body> |
|
78 </html> |