Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/test/data/fullscreen_mouselock/fullscreen_mouselock.html

Issue 10832119: Change test .html page to new pointer lock API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/functional/fullscreen_mouselock.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 22
23 function exitFullscreen() { 23 function exitFullscreen() {
24 console.log("exitFullscreen()"); 24 console.log("exitFullscreen()");
25 document.webkitCancelFullScreen(); 25 document.webkitCancelFullScreen();
26 } 26 }
27 27
28 // Wait for notification from JS, then notify test of success or failure 28 // Wait for notification from JS, then notify test of success or failure
29 // callback that the click has registered and the mouse lock state has changed. 29 // callback that the click has registered and the mouse lock state has changed.
30 function lockMouse1(callback) { 30 function lockMouse1(callback) {
31 console.log("lockMouse1()"); 31 console.log("lockMouse1()");
32 navigator.webkitPointer.lock(document.getElementById("lockTarget1"), 32 var target = document.getElementById("lockTarget1");
33 function() { 33
34 function failure() {
35 console.log("lock failed");
36 if (callback) {
37 callback("failure");
38 }
39 };
40 function possibleSuccess() {
41 if (document.webkitPointerLockElement == target) {
34 console.log("lock success"); 42 console.log("lock success");
35 if (callback) { 43 if (callback)
36 callback("success"); 44 callback("success");
37 } 45 } else {
38 }, 46 failure();
39 function() {
40 console.log("lock failed");
41 if (callback) {
42 callback("failure");
43 }
44 } 47 }
45 ); 48 };
49 document.onwebkitpointerlockchange = possibleSuccess;
50 document.onwebkitpointerlockerror = failure;
51 target.webkitRequestPointerLock();
46 } 52 }
47 53
48 var lock_result1 = "";
49 // In the PyAuto test the fullscreen is initiated, accepted and enters into a 54 // In the PyAuto test the fullscreen is initiated, accepted and enters into a
50 // wait state reading the value of lock_result1. One of the two asynchronous 55 // wait state reading the value of lock_result. One of the two asynchronous
51 // functions in the JS will be executed. The PyAuto code waits for lock_result 56 // functions in the JS will be executed. The PyAuto code waits for lock_result
52 // to return "success" or "failure". Sample PyAuto code: 57 // to return "success" or "failure". Sample PyAuto code:
53 // lock_result = self._driver.execute_script('lockMouse1AndSetLockResult()') 58 // lock_result = self._driver.execute_script('lockMouse1AndSetLockResult()')
59 function lockMouseAndSetLockResult(targetId) {
60 var target = document.getElementById(targetId);
61 lock_result = "";
62
63 function failure() {
64 console.log("lock failed");
65 lock_result = "failure"
66 };
67 function possibleSuccess() {
68 if (document.webkitPointerLockElement == target) {
69 console.log("lock success");
70 lock_result = "success"
71 } else {
72 failure();
73 }
74 };
75 document.onwebkitpointerlockchange = possibleSuccess;
76 document.onwebkitpointerlockerror = failure;
77 target.webkitRequestPointerLock();
78 }
79
54 function lockMouse1AndSetLockResult() { 80 function lockMouse1AndSetLockResult() {
55 console.log("lockMouse1AndSetLockResult()"); 81 console.log("lockMouse1AndSetLockResult()");
56 lock_result1 = ""; 82 lockMouseAndSetLockResult("lockTarget1");
57 navigator.webkitPointer.lock(document.getElementById("lockTarget1"),
58 function() {
59 console.log("lock success");
60 lock_result = "success"
61 },
62 function() {
63 console.log("lock failed");
64 lock_result = "failure"
65 }
66 );
67 } 83 }
68 84
69 // When mouse lock is initiated and accepted, PyAuto test will wait for the 85 // 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. 86 // lock_result to return "success" or "failure" to initiate the next action.
71 function lockMouse2() { 87 function lockMouse2() {
72 console.log("lockMouse2()"); 88 console.log("lockMouse2()");
73 navigator.webkitPointer.lock(document.getElementById("lockTarget2"), 89 lockMouseAndSetLockResult("lockTarget2");
74 function() {
75 console.log("lock success");
76 lock_result = "success"
77 },
78 function() {
79 console.log("lock failed")
80 lock_result = "failure"
81 }
82 );
83 } 90 }
84 91
85 function delayedLockMouse1() { 92 function delayedLockMouse1() {
86 console.log("delayedLockMouse1()"); 93 console.log("delayedLockMouse1()");
87 window.setTimeout(lockMouse1, 1010); 94 window.setTimeout(lockMouse1, 1010);
88 // Delay must be over 1 second or the click that initiated the delayed action 95 // Delay must be over 1 second or the click that initiated the delayed action
89 // may still be considered active and treat this as a user gesture. 96 // may still be considered active and treat this as a user gesture.
90 // We want to test a lock not associated with a user gesture. 97 // We want to test a lock not associated with a user gesture.
91 } 98 }
92 99
93 function spamLockMouse2() { 100 function spamLockMouse2() {
94 console.log("spamLockMouse2()") 101 console.log("spamLockMouse2()")
95 window.setInterval(lockMouse2, 111); 102 window.setInterval(lockMouse2, 111);
96 } 103 }
97 104
98 function unlockMouse() { 105 function unlockMouse() {
99 console.log("unlockMouse()"); 106 console.log("unlockMouse()");
100 navigator.webkitPointer.unlock(); 107 document.webkitExitPointerLock();
101 } 108 }
102 109
103 function enterFullscreenAndLockMouse1() { 110 function enterFullscreenAndLockMouse1() {
104 console.log("enterFullscreenAndLockMouse1()"); 111 console.log("enterFullscreenAndLockMouse1()");
105 enterFullscreen(); 112 enterFullscreen();
106 lockMouse1(); 113 lockMouse1();
107 } 114 }
108 115
109 function lockMouse1AndEnterFullscreen() { 116 function lockMouse1AndEnterFullscreen() {
110 console.log("lockMouse1AndEnterFullscreen()"); 117 console.log("lockMouse1AndEnterFullscreen()");
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 onclick="clickElement(this.id);"> 232 onclick="clickElement(this.id);">
226 anchor link 233 anchor link
227 </a> 234 </a>
228 navigates to an anchor on this page. The browser should not exit tab 235 navigates to an anchor on this page. The browser should not exit tab
229 fullscreen or mouse lock.</p> 236 fullscreen or mouse lock.</p>
230 </div> 237 </div>
231 <p>This text is outside of the container that is made fullscreen. This text 238 <p>This text is outside of the container that is made fullscreen. This text
232 should not be visible when fullscreen.</p> 239 should not be visible when fullscreen.</p>
233 </body> 240 </body>
234 </html> 241 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/fullscreen_mouselock.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698