Chromium Code Reviews| 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 |
|
Nirnimesh
2012/06/18 23:13:56
pyAuto -> PyAuto
dyu1
2012/06/27 22:48:45
Done.
| |
| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 case "1": lockMouse1(); break; | 170 case "1": lockMouse1(); break; |
| 161 case "2": lockMouse2(); break; | 171 case "2": lockMouse2(); break; |
| 162 case "d": delayedLockMouse1(); break; | 172 case "d": delayedLockMouse1(); break; |
| 163 case "u": unlockMouse(); break; | 173 case "u": unlockMouse(); break; |
| 164 case "b": enterFullscreenAndLockMouse1(); break; | 174 case "b": enterFullscreenAndLockMouse1(); break; |
| 165 case "B": lockMouse1AndEnterFullscreen(); break; | 175 case "B": lockMouse1AndEnterFullscreen(); break; |
| 166 default: moveHTMLCursorToCenter(); break; | 176 default: moveHTMLCursorToCenter(); break; |
| 167 } | 177 } |
| 168 }); | 178 }); |
| 169 } | 179 } |
| 180 | |
| 170 </script> | 181 </script> |
| 171 </head> | 182 </head> |
| 172 <body onload="init()" title="This tooltip should not be shown if the mouse is lo cked."> | 183 <body onload="init()" |
| 184 title="This tooltip should not be shown if the mouse is locked."> | |
| 173 <div id="container"> | 185 <div id="container"> |
| 174 <button id="enterFullscreen" onclick="enterFullscreen();">enterFullscreen() [f]</button><br> | 186 <button id="enterFullscreen" onclick="enterFullscreen();"> |
| 175 <button id="exitFullscreen" onclick="exitFullscreen();">exitFullscreen() [x] </button><br> | 187 enterFullscreen() [f] |
| 176 <button id="lockMouse1" onclick="lockMouse1();">lockMouse1() [1]</button><br > | 188 </button><br> |
| 177 <button id="lockMouse2" onclick="lockMouse2();">lockMouse2() [2]</button><br > | 189 <button id="exitFullscreen" onclick="exitFullscreen();"> |
| 178 <button id="delayedLockMouse1" onclick="delayedLockMouse1();">delayedLockMou se1() [d]</button><br> | 190 exitFullscreen() [x] |
| 179 <button id="spamLockMouse2" onclick="spamLockMouse2();">spamLockMouse2()</bu tton><br> | 191 </button><br> |
| 180 <button id="unlockMouse" onclick="unlockMouse();">unlockMouse() [u]</button> <br> | 192 <button id="lockMouse1" onclick="lockMouse1();"> |
| 181 <button id="enterFullscreenAndLockMouse1" onclick="enterFullscreenAndLockMou se1()">enterFullscreenAndLockMouse1() [b]</button><br> | 193 lockMouse1() [1] |
| 182 <button id="lockMouse1AndEnterFullscreen" onclick="lockMouse1AndEnterFullscr een()">lockMouse1AndEnterFullscreen() [B]</button><br> | 194 </button><br> |
| 195 <button id="lockMouse2" onclick="lockMouse2();"> | |
| 196 lockMouse2() [2] | |
| 197 </button><br> | |
| 198 <button id="delayedLockMouse1" onclick="delayedLockMouse1();"> | |
| 199 delayedLockMouse1() [d] | |
| 200 </button><br> | |
| 201 <button id="spamLockMouse2" onclick="spamLockMouse2();"> | |
| 202 spamLockMouse2() | |
| 203 </button><br> | |
| 204 <button id="unlockMouse" onclick="unlockMouse();"> | |
| 205 unlockMouse() [u] | |
| 206 </button><br> | |
| 207 <button id="enterFullscreenAndLockMouse1" | |
| 208 onclick="enterFullscreenAndLockMouse1()"> | |
| 209 enterFullscreenAndLockMouse1() [b] | |
| 210 </button><br> | |
| 211 <button id="lockMouse1AndEnterFullscreen" | |
| 212 onclick="lockMouse1AndEnterFullscreen()"> | |
| 213 lockMouse1AndEnterFullscreen() [B] | |
| 214 </button><br> | |
| 183 <div id="lockTarget1">lockTarget1</div> | 215 <div id="lockTarget1">lockTarget1</div> |
| 184 <div id="lockTarget2">lockTarget2</div> | 216 <div id="lockTarget2">lockTarget2</div> |
| 185 <form name="HTMLCursor" id="HTMLCursor">HTMLCursor</form> | 217 <form name="HTMLCursor" id="HTMLCursor">HTMLCursor</form> |
| 186 <form name="displaytext">...</form> | 218 <form name="displaytext">...</form> |
| 219 <p>The <a href="#anchor" name="anchor" id="anchor">anchor link</a> | |
| 220 navigates to an anchor on this page. The browser should not exit tab | |
| 221 fullscreen or mouse lock.</p> | |
| 187 </div> | 222 </div> |
| 188 This text is outside of the container that is made fullscreen. This text shoul d not be visible when fullscreen. | 223 <p>This text is outside of the container that is made fullscreen. This text |
| 224 should not be visible when fullscreen.</p> | |
| 189 </body> | 225 </body> |
| 190 </html> | 226 </html> |
| OLD | NEW |