|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602 |
|
5 --> |
|
6 <head> |
|
7 <title>Bug 633602 - file_targetOutOfFocus.html</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> |
|
9 </script> |
|
10 <script type="text/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 |
|
19 </a> |
|
20 <p id="display"></p> |
|
21 <div id="content"> |
|
22 </div> |
|
23 <div id="div"></div> |
|
24 <input id="input" type="text" /> |
|
25 <pre id="test"> |
|
26 <script type="application/javascript"> |
|
27 /* |
|
28 * Test for Bug 633602 |
|
29 * Element doesn't need to have focus to request |
|
30 * pointer lock |
|
31 */ |
|
32 |
|
33 SimpleTest.waitForExplicitFinish(); |
|
34 |
|
35 var div = document.getElementById("div") |
|
36 , input = document.getElementById("input") |
|
37 , divPointerLock = false; |
|
38 |
|
39 function runTests () { |
|
40 ok(divPointerLock, "Pointer should be locked even if " + |
|
41 "the element being locked is not focused"); |
|
42 } |
|
43 |
|
44 input.addEventListener("focus", function() { |
|
45 div.mozRequestPointerLock(); |
|
46 }, false); |
|
47 |
|
48 document.addEventListener("mozpointerlockchange", function (e) { |
|
49 if (document.mozPointerLockElement === div) { |
|
50 divPointerLock = true; |
|
51 document.mozCancelFullScreen(); |
|
52 } |
|
53 }, false); |
|
54 |
|
55 document.addEventListener("mozfullscreenchange", function() { |
|
56 if (document.mozFullScreenElement === div) { |
|
57 input.focus(); |
|
58 } else { |
|
59 runTests(); |
|
60 SimpleTest.finish(); |
|
61 } |
|
62 }, false); |
|
63 |
|
64 function start() { |
|
65 div.mozRequestFullScreen(); |
|
66 } |
|
67 </script> |
|
68 </pre> |
|
69 </body> |
|
70 </html> |