OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Fullscreen and Mouse Lock Scripts</title> | 4 <title>Fullscreen and Mouse Lock Scripts</title> |
5 <style type="text/css"> | 5 <style type="text/css"> |
6 #HTMLCursor { | 6 #HTMLCursor { |
7 border: solid black 1px; | 7 border: solid black 1px; |
8 background: yellow; | 8 background: yellow; |
9 display: inline; | 9 display: inline; |
10 position: absolute; | 10 position: absolute; |
(...skipping 28 matching lines...) Expand all Loading... |
39 function() { | 39 function() { |
40 console.log("lock failed"); | 40 console.log("lock failed"); |
41 if (callback) { | 41 if (callback) { |
42 callback("failure"); | 42 callback("failure"); |
43 } | 43 } |
44 } | 44 } |
45 ); | 45 ); |
46 } | 46 } |
47 | 47 |
48 var lock_result1 = ""; | 48 var lock_result1 = ""; |
49 // In the pyAuto test the fullscreen is initiated, accepted and enters into a wa
it state | 49 // In the PyAuto test the fullscreen is initiated, accepted and enters into a |
50 // reading the value of lock_result1. One of the two asynchronous functions in t
he JS will | 50 // wait state reading the value of lock_result1. One of the two asynchronous |
51 // be executed. The pyAuto code waits for lock_result to return "success" or "fa
ilure". | 51 // functions in the JS will be executed. The PyAuto code waits for lock_result |
52 // Sample pyAuto code: lock_result = self._driver.execute_script('lockMouse1AndS
etLockResult()') | 52 // to return "success" or "failure". Sample PyAuto code: |
| 53 // lock_result = self._driver.execute_script('lockMouse1AndSetLockResult()') |
53 function lockMouse1AndSetLockResult() { | 54 function lockMouse1AndSetLockResult() { |
54 console.log("lockMouse1AndSetLockResult()"); | 55 console.log("lockMouse1AndSetLockResult()"); |
55 lock_result1 = ""; | 56 lock_result1 = ""; |
56 navigator.webkitPointer.lock(document.getElementById("lockTarget1"), | 57 navigator.webkitPointer.lock(document.getElementById("lockTarget1"), |
57 function() { | 58 function() { |
58 console.log("lock success"); | 59 console.log("lock success"); |
59 lock_result = "success" | 60 lock_result = "success" |
60 }, | 61 }, |
61 function() { | 62 function() { |
62 console.log("lock failed"); | 63 console.log("lock failed"); |
63 lock_result = "failure" | 64 lock_result = "failure" |
64 } | 65 } |
65 ); | 66 ); |
66 } | 67 } |
67 | 68 |
| 69 // When mouse lock is initiated and accepted, PyAuto test will wait for the |
| 70 // lock_result to return "success" or "failure" to initiate the next action. |
68 function lockMouse2() { | 71 function lockMouse2() { |
69 console.log("lockMouse2()"); | 72 console.log("lockMouse2()"); |
70 navigator.webkitPointer.lock(document.getElementById("lockTarget2"), | 73 navigator.webkitPointer.lock(document.getElementById("lockTarget2"), |
71 function(){console.log("lock success")}, | 74 function() { |
72 function(){console.log("lock failed")}); | 75 console.log("lock success"); |
| 76 lock_result = "success" |
| 77 }, |
| 78 function() { |
| 79 console.log("lock failed") |
| 80 lock_result = "failure" |
| 81 } |
| 82 ); |
73 } | 83 } |
74 | 84 |
75 function delayedLockMouse1() { | 85 function delayedLockMouse1() { |
76 console.log("delayedLockMouse1()"); | 86 console.log("delayedLockMouse1()"); |
77 window.setTimeout(lockMouse1, 1010); | 87 window.setTimeout(lockMouse1, 1010); |
78 // Delay must be over 1 second or the click that initiated the delayed action | 88 // Delay must be over 1 second or the click that initiated the delayed action |
79 // may still be considered active and treat this as a user gesture. | 89 // may still be considered active and treat this as a user gesture. |
80 // We want to test a lock not associated with a user gesture. | 90 // We want to test a lock not associated with a user gesture. |
81 } | 91 } |
82 | 92 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 (e.mozMovementX !== undefined ? e.mozMovementX : | 133 (e.mozMovementX !== undefined ? e.mozMovementX : |
124 (e.oMovementX !== undefined ? e.oMovementX : | 134 (e.oMovementX !== undefined ? e.oMovementX : |
125 e.msMovementY)))); | 135 e.msMovementY)))); |
126 e.movementY = (e.movementY !== undefined ? e.movementY : | 136 e.movementY = (e.movementY !== undefined ? e.movementY : |
127 (e.webkitMovementY !== undefined ? e.webkitMovementY : | 137 (e.webkitMovementY !== undefined ? e.webkitMovementY : |
128 (e.mozMovementY !== undefined ? e.mozMovementY : | 138 (e.mozMovementY !== undefined ? e.mozMovementY : |
129 (e.oMovementY !== undefined ? e.oMovementY : | 139 (e.oMovementY !== undefined ? e.oMovementY : |
130 e.msMovementY)))); | 140 e.msMovementY)))); |
131 } | 141 } |
132 | 142 |
| 143 var clicked_elem_ID = "" |
| 144 function clickElement(id) { |
| 145 clicked_elem_ID = id; |
| 146 } |
| 147 |
133 function init() { | 148 function init() { |
134 moveHTMLCursorToCenter(); | 149 moveHTMLCursorToCenter(); |
135 | 150 |
136 document.addEventListener("mousemove", | 151 document.addEventListener("mousemove", |
137 polyFillMouseEventMovementFromVenderPrefix); | 152 polyFillMouseEventMovementFromVenderPrefix); |
138 document.addEventListener("mousemove", function (e) { | 153 document.addEventListener("mousemove", function (e) { |
139 if (e.movementX !== undefined) { | 154 if (e.movementX !== undefined) { |
140 moveHTMLCursorBy(e.movementX, e.movementY); | 155 moveHTMLCursorBy(e.movementX, e.movementY); |
141 displaytext.innerHTML = | 156 displaytext.innerHTML = |
142 "Document mousemove listener:<br>" + | 157 "Document mousemove listener:<br>" + |
(...skipping 17 matching lines...) Expand all Loading... |
160 case "1": lockMouse1(); break; | 175 case "1": lockMouse1(); break; |
161 case "2": lockMouse2(); break; | 176 case "2": lockMouse2(); break; |
162 case "d": delayedLockMouse1(); break; | 177 case "d": delayedLockMouse1(); break; |
163 case "u": unlockMouse(); break; | 178 case "u": unlockMouse(); break; |
164 case "b": enterFullscreenAndLockMouse1(); break; | 179 case "b": enterFullscreenAndLockMouse1(); break; |
165 case "B": lockMouse1AndEnterFullscreen(); break; | 180 case "B": lockMouse1AndEnterFullscreen(); break; |
166 default: moveHTMLCursorToCenter(); break; | 181 default: moveHTMLCursorToCenter(); break; |
167 } | 182 } |
168 }); | 183 }); |
169 } | 184 } |
| 185 |
170 </script> | 186 </script> |
171 </head> | 187 </head> |
172 <body onload="init()" title="This tooltip should not be shown if the mouse is lo
cked."> | 188 <body onload="init()" |
| 189 title="This tooltip should not be shown if the mouse is locked."> |
173 <div id="container"> | 190 <div id="container"> |
174 <button id="enterFullscreen" onclick="enterFullscreen();">enterFullscreen()
[f]</button><br> | 191 <button id="enterFullscreen" onclick="enterFullscreen();"> |
175 <button id="exitFullscreen" onclick="exitFullscreen();">exitFullscreen() [x]
</button><br> | 192 enterFullscreen() [f] |
176 <button id="lockMouse1" onclick="lockMouse1();">lockMouse1() [1]</button><br
> | 193 </button><br> |
177 <button id="lockMouse2" onclick="lockMouse2();">lockMouse2() [2]</button><br
> | 194 <button id="exitFullscreen" onclick="exitFullscreen();"> |
178 <button id="delayedLockMouse1" onclick="delayedLockMouse1();">delayedLockMou
se1() [d]</button><br> | 195 exitFullscreen() [x] |
179 <button id="spamLockMouse2" onclick="spamLockMouse2();">spamLockMouse2()</bu
tton><br> | 196 </button><br> |
180 <button id="unlockMouse" onclick="unlockMouse();">unlockMouse() [u]</button>
<br> | 197 <button id="lockMouse1" onclick="lockMouse1();"> |
181 <button id="enterFullscreenAndLockMouse1" onclick="enterFullscreenAndLockMou
se1()">enterFullscreenAndLockMouse1() [b]</button><br> | 198 lockMouse1() [1] |
182 <button id="lockMouse1AndEnterFullscreen" onclick="lockMouse1AndEnterFullscr
een()">lockMouse1AndEnterFullscreen() [B]</button><br> | 199 </button><br> |
| 200 <button id="lockMouse2" onclick="lockMouse2();"> |
| 201 lockMouse2() [2] |
| 202 </button><br> |
| 203 <button id="delayedLockMouse1" onclick="delayedLockMouse1();"> |
| 204 delayedLockMouse1() [d] |
| 205 </button><br> |
| 206 <button id="spamLockMouse2" onclick="spamLockMouse2();"> |
| 207 spamLockMouse2() |
| 208 </button><br> |
| 209 <button id="unlockMouse" onclick="unlockMouse();"> |
| 210 unlockMouse() [u] |
| 211 </button><br> |
| 212 <button id="enterFullscreenAndLockMouse1" |
| 213 onclick="enterFullscreenAndLockMouse1()"> |
| 214 enterFullscreenAndLockMouse1() [b] |
| 215 </button><br> |
| 216 <button id="lockMouse1AndEnterFullscreen" |
| 217 onclick="lockMouse1AndEnterFullscreen()"> |
| 218 lockMouse1AndEnterFullscreen() [B] |
| 219 </button><br> |
183 <div id="lockTarget1">lockTarget1</div> | 220 <div id="lockTarget1">lockTarget1</div> |
184 <div id="lockTarget2">lockTarget2</div> | 221 <div id="lockTarget2">lockTarget2</div> |
185 <form name="HTMLCursor" id="HTMLCursor">HTMLCursor</form> | 222 <form name="HTMLCursor" id="HTMLCursor">HTMLCursor</form> |
186 <form name="displaytext">...</form> | 223 <form name="displaytext">...</form> |
| 224 <p>The <a href="#anchor" name="anchor" id="anchor" |
| 225 onclick="clickElement(this.id);"> |
| 226 anchor link |
| 227 </a> |
| 228 navigates to an anchor on this page. The browser should not exit tab |
| 229 fullscreen or mouse lock.</p> |
187 </div> | 230 </div> |
188 This text is outside of the container that is made fullscreen. This text shoul
d not be visible when fullscreen. | 231 <p>This text is outside of the container that is made fullscreen. This text |
| 232 should not be visible when fullscreen.</p> |
189 </body> | 233 </body> |
190 </html> | 234 </html> |
OLD | NEW |