Commit 781a2840 authored by scheib@chromium.org's avatar scheib@chromium.org

Change test .html page to new pointer lock API.


BUG=72754


Review URL: https://chromiumcodereview.appspot.com/10832119

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149726 0039d316-1c4b-4281-b951-d872f2087c98
parent 6b5435a6
...@@ -29,57 +29,64 @@ function exitFullscreen() { ...@@ -29,57 +29,64 @@ function exitFullscreen() {
// callback that the click has registered and the mouse lock state has changed. // callback that the click has registered and the mouse lock state has changed.
function lockMouse1(callback) { function lockMouse1(callback) {
console.log("lockMouse1()"); console.log("lockMouse1()");
navigator.webkitPointer.lock(document.getElementById("lockTarget1"), var target = document.getElementById("lockTarget1");
function() {
function failure() {
console.log("lock failed");
if (callback) {
callback("failure");
}
};
function possibleSuccess() {
if (document.webkitPointerLockElement == target) {
console.log("lock success"); console.log("lock success");
if (callback) { if (callback)
callback("success"); callback("success");
} } else {
}, failure();
function() {
console.log("lock failed");
if (callback) {
callback("failure");
}
} }
); };
document.onwebkitpointerlockchange = possibleSuccess;
document.onwebkitpointerlockerror = failure;
target.webkitRequestPointerLock();
} }
var lock_result1 = "";
// In the PyAuto test the fullscreen is initiated, accepted and enters into a // In the PyAuto test the fullscreen is initiated, accepted and enters into a
// wait state reading the value of lock_result1. One of the two asynchronous // wait state reading the value of lock_result. One of the two asynchronous
// functions in the JS will be executed. The PyAuto code waits for lock_result // functions in the JS will be executed. The PyAuto code waits for lock_result
// to return "success" or "failure". Sample PyAuto code: // to return "success" or "failure". Sample PyAuto code:
// lock_result = self._driver.execute_script('lockMouse1AndSetLockResult()') // lock_result = self._driver.execute_script('lockMouse1AndSetLockResult()')
function lockMouse1AndSetLockResult() { function lockMouseAndSetLockResult(targetId) {
console.log("lockMouse1AndSetLockResult()"); var target = document.getElementById(targetId);
lock_result1 = ""; lock_result = "";
navigator.webkitPointer.lock(document.getElementById("lockTarget1"),
function() { function failure() {
console.log("lock failed");
lock_result = "failure"
};
function possibleSuccess() {
if (document.webkitPointerLockElement == target) {
console.log("lock success"); console.log("lock success");
lock_result = "success" lock_result = "success"
}, } else {
function() { failure();
console.log("lock failed");
lock_result = "failure"
} }
); };
document.onwebkitpointerlockchange = possibleSuccess;
document.onwebkitpointerlockerror = failure;
target.webkitRequestPointerLock();
}
function lockMouse1AndSetLockResult() {
console.log("lockMouse1AndSetLockResult()");
lockMouseAndSetLockResult("lockTarget1");
} }
// When mouse lock is initiated and accepted, PyAuto test will wait for the // When mouse lock is initiated and accepted, PyAuto test will wait for the
// lock_result to return "success" or "failure" to initiate the next action. // lock_result to return "success" or "failure" to initiate the next action.
function lockMouse2() { function lockMouse2() {
console.log("lockMouse2()"); console.log("lockMouse2()");
navigator.webkitPointer.lock(document.getElementById("lockTarget2"), lockMouseAndSetLockResult("lockTarget2");
function() {
console.log("lock success");
lock_result = "success"
},
function() {
console.log("lock failed")
lock_result = "failure"
}
);
} }
function delayedLockMouse1() { function delayedLockMouse1() {
...@@ -97,7 +104,7 @@ function spamLockMouse2() { ...@@ -97,7 +104,7 @@ function spamLockMouse2() {
function unlockMouse() { function unlockMouse() {
console.log("unlockMouse()"); console.log("unlockMouse()");
navigator.webkitPointer.unlock(); document.webkitExitPointerLock();
} }
function enterFullscreenAndLockMouse1() { function enterFullscreenAndLockMouse1() {
......
...@@ -339,6 +339,7 @@ class FullscreenMouselockTest(pyauto.PyUITest): ...@@ -339,6 +339,7 @@ class FullscreenMouselockTest(pyauto.PyUITest):
self.assertTrue( self.assertTrue(
self.WaitUntil(lambda: self.IsMouseLockPermissionRequested())) self.WaitUntil(lambda: self.IsMouseLockPermissionRequested()))
self.AcceptCurrentFullscreenOrMouseLockRequest() self.AcceptCurrentFullscreenOrMouseLockRequest()
self.assertTrue(self.WaitUntil(self.IsMouseLocked))
# Waits until lock_result gets 'success' or 'failure'. # Waits until lock_result gets 'success' or 'failure'.
lock_result = self._driver.execute_script('return lock_result') lock_result = self._driver.execute_script('return lock_result')
self.assertEqual( self.assertEqual(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment