Commit 3684f627 authored by scheib@chromium.org's avatar scheib@chromium.org

Refactor common Pointer Lock test code to a harness.

https://bugs.webkit.org/show_bug.cgi?id=90813

Reviewed by Adrienne Walker.

* pointer-lock/bug90391-move-then-window-open-crash-expected.txt:
* pointer-lock/bug90391-move-then-window-open-crash.html:
* pointer-lock/lock-already-locked-expected.txt:
* pointer-lock/lock-already-locked.html:
* pointer-lock/lock-fail-responses-expected.txt:
* pointer-lock/lock-fail-responses.html:
* pointer-lock/mouse-event-delivery-expected.txt:
* pointer-lock/mouse-event-delivery.html:
* pointer-lock/pointer-lock-api-expected.txt:
* pointer-lock/pointer-lock-api.html:
* pointer-lock/pointerlockchange-pointerlockerror-events-expected.txt:
* pointer-lock/pointerlockchange-pointerlockerror-events.html:
* pointer-lock/pointerlocklost-event-expected.txt:
* pointer-lock/pointerlocklost-event.html:
* pointer-lock/resources/pointer-lock-test-harness.js: Added.
(doNextStep.else):
(doNextStepWithUserGesture):
(eventExpected.targetHanderNode.eventHandlerName):
(eventExpected):
(expectOnlyChangeEvent):
(expectOnlyErrorEvent):
(expectNoEvents):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c8e4c8da
2012-07-09 Vincent Scheib <scheib@chromium.org>
Refactor common Pointer Lock test code to a harness.
https://bugs.webkit.org/show_bug.cgi?id=90813
Reviewed by Adrienne Walker.
* pointer-lock/bug90391-move-then-window-open-crash-expected.txt:
* pointer-lock/bug90391-move-then-window-open-crash.html:
* pointer-lock/lock-already-locked-expected.txt:
* pointer-lock/lock-already-locked.html:
* pointer-lock/lock-fail-responses-expected.txt:
* pointer-lock/lock-fail-responses.html:
* pointer-lock/mouse-event-delivery-expected.txt:
* pointer-lock/mouse-event-delivery.html:
* pointer-lock/pointer-lock-api-expected.txt:
* pointer-lock/pointer-lock-api.html:
* pointer-lock/pointerlockchange-pointerlockerror-events-expected.txt:
* pointer-lock/pointerlockchange-pointerlockerror-events.html:
* pointer-lock/pointerlocklost-event-expected.txt:
* pointer-lock/pointerlocklost-event.html:
* pointer-lock/resources/pointer-lock-test-harness.js: Added.
(doNextStep.else):
(doNextStepWithUserGesture):
(eventExpected.targetHanderNode.eventHandlerName):
(eventExpected):
(expectOnlyChangeEvent):
(expectOnlyErrorEvent):
(expectNoEvents):
2012-07-09 Dean Jackson <dino@apple.com>
Tiled drawing means some elements can disappear behind the page
......@@ -11,5 +11,4 @@ PASS Didn't crash
PASS successfullyParsed is true
TEST COMPLETE
doNextStep for manual testing
......@@ -2,10 +2,10 @@
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/pointer-lock-test-harness.js"></script>
</head>
<body>
<div>
<button onclick="doNextStep('manual');">doNextStep for manual testing</button>
<div id="target1"></div>
</div>
<script>
......@@ -14,16 +14,6 @@
targetdiv1 = document.getElementById("target1");
currentStep = 0;
function doNextStep(manual)
{
if (!window.layoutTestController && !manual)
return;
if (currentStep < todo.length)
setTimeout(function () { todo[currentStep++](); }, 0);
else if (currentStep++ == todo.length)
setTimeout(function () { finishJSTest(); }, 0);
}
todo = [
function () {
debug(" Locking targetdiv1.")
......@@ -31,7 +21,7 @@
document.onwebkitpointerlockchange = function () {
document.onwebkitpointerlockchange = null;
testPassed("document.onwebkitpointerlockchange event received.");
doNextStep('manual');
doNextStep();
};
},
function () {
......@@ -40,7 +30,7 @@
targetdiv1.onmousemove = function () {
if (++mouseMoveEvents == 2) {
targetdiv1.onmousemove = null;
doNextStep('manual');
doNextStep();
}
}
if (window.eventSender) {
......@@ -54,10 +44,10 @@
window.open();
testPassed("Didn't crash");
document.webkitExitPointerLock();
doNextStep('manual');
doNextStep();
},
];
doNextStep();
doNextStepWithUserGesture();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
......
......@@ -31,5 +31,4 @@ PASS document.webkitPointerLockElement is targetdiv2
PASS successfullyParsed is true
TEST COMPLETE
doNextStep for manual testing
......@@ -2,10 +2,10 @@
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/pointer-lock-test-harness.js"></script>
</head>
<body>
<div>
<button onclick="doNextStep('manual');">doNextStep for manual testing</button>
<div id="target1"></div>
<div id="target2"></div>
</div>
......@@ -22,7 +22,7 @@
{
testPassed("document.onwebkitpointerlockchange event received.");
shouldBe("document.webkitPointerLockElement", expectedTargetToBeLockedString);
doNextStep();
doNextStepWithUserGesture();
};
document.onwebkitpointerlockerror =
function () { testFailed("document.onwebkitpointerlockerror event received."); finishJSTest(); };
......@@ -35,16 +35,6 @@
targetdiv2.addEventListener("webkitpointerlocklost",
function () { shouldBe("expectTarget2Unlock", "true"); });
currentStep = 0;
function doNextStep(manual)
{
if (!window.layoutTestController && !manual)
return;
if (currentStep < todo.length)
setTimeout(function () { todo[currentStep++](); }, 0);
else if (currentStep++ == todo.length)
setTimeout(function () { finishJSTest(); }, 0);
}
todo = [
function () {
shouldBe("document.webkitPointerLockElement", "null");
......@@ -110,7 +100,7 @@
expectedTargetToBeLockedString = "targetdiv2";
},
];
doNextStep();
doNextStepWithUserGesture();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
......
......@@ -2,6 +2,7 @@
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/pointer-lock-test-harness.js"></script>
</head>
<body>
<script>
......@@ -9,10 +10,6 @@
window.jsTestIsAsync = true;
shouldBeDefined("window.testRunner");
currentStep = 0;
function doNextStep() {
todo[currentStep++]();
}
todo = [
function () {
testRunner.setPointerLockWillFailSynchronously();
......@@ -23,7 +20,7 @@
},
function () {
testPassed("Lock failed (after we called testRunner.setPointerLockWillFailSynchronously)");
doNextStep();
doNextStepWithUserGesture();
});
},
function () {
......@@ -38,9 +35,8 @@
doNextStep();
});
},
finishJSTest
];
doNextStep();
doNextStepWithUserGesture();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
......
......@@ -32,5 +32,4 @@ PASS event type: click, target: target2, received on: target2
PASS successfullyParsed is true
TEST COMPLETE
doNextStep for manual testing
......@@ -2,10 +2,10 @@
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/pointer-lock-test-harness.js"></script>
</head>
<body id="body">
<div>
<button onclick="doNextStep('manual');">doNextStep for manual testing</button>
<div id="target1"></div>
<div id="target2"></div>
</div>
......@@ -22,7 +22,7 @@
{
testPassed("document.onwebkitpointerlockchange event received.");
shouldBe("document.webkitPointerLockElement", expectedTargetToBeLockedString);
doNextStep('manual');
doNextStep();
};
document.onwebkitpointerlockerror =
function () { testFailed("document.onwebkitpointerlockerror event received."); finishJSTest(); };
......@@ -35,16 +35,6 @@
testPassed("event type: " + e.type + ", target: " + e.target.id + ", received on: " + e.currentTarget.id);
}
currentStep = 0;
function doNextStep(manual)
{
if (!window.layoutTestController && !manual)
return;
if (currentStep < todo.length)
setTimeout(function () { todo[currentStep++](); }, 0);
else if (currentStep++ == todo.length)
setTimeout(function () { finishJSTest(); }, 0);
}
todo = [
function () {
targetdiv1.webkitRequestPointerLock();
......@@ -61,7 +51,7 @@
window.eventSender.mouseDown();
window.eventSender.mouseUp();
}
doNextStep();
doNextStepWithUserGesture();
},
function () {
targetdiv2.webkitRequestPointerLock();
......@@ -78,7 +68,7 @@
window.eventSender.mouseDown();
window.eventSender.mouseUp();
}
doNextStep();
doNextStepWithUserGesture();
},
function () {
debug(" Ensure double clicks work as expected, sending 4 clicks.")
......@@ -103,10 +93,10 @@
window.eventSender.mouseDown();
window.eventSender.mouseUp();
}
doNextStep();
doNextStepWithUserGesture();
},
];
doNextStep();
doNextStepWithUserGesture();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
......
......@@ -17,4 +17,4 @@ PASS element.webkitRequestPointerLock is defined.
PASS successfullyParsed is true
TEST COMPLETE
doNextStep for manual testing
......@@ -2,23 +2,13 @@
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/pointer-lock-test-harness.js"></script>
</head>
<body>
<button onclick="doNextStep('manual');">doNextStep for manual testing</button>
<script>
description("Basic API existence test for Pointer Lock.")
window.jsTestIsAsync = true;
currentStep = 0;
function doNextStep(manual)
{
if (!window.testRunner && !manual)
return;
if (currentStep < todo.length)
setTimeout(function () { todo[currentStep++](); }, 0);
else if (currentStep++ == todo.length)
setTimeout(function () { finishJSTest(); }, 0);
}
todo = [
function () {
shouldBeDefined("navigator.webkitPointer");
......@@ -43,7 +33,7 @@
doNextStep();
},
];
doNextStep();
doNextStepWithUserGesture();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
......
......@@ -36,5 +36,4 @@ PASS onwebkitpointerlockerror received after: Lock with asynchronous failure.
PASS successfullyParsed is true
TEST COMPLETE
doNextStep for manual testing
......@@ -2,10 +2,10 @@
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/pointer-lock-test-harness.js"></script>
</head>
<body>
<div>
<button onclick="doNextStep('manual');">doNextStep for manual testing</button>
<div id="target1"></div>
<div id="target2"></div>
<iframe id="iframe1"></iframe>
......@@ -20,59 +20,11 @@
targetIframe1 = document.getElementById("iframe1");
targetIframe2 = document.getElementById("iframe2");
function eventExpected(eventHandlerName, message, expectedCalls, targetHanderNode)
{
targetHanderNode[eventHandlerName] = function ()
{
switch (expectedCalls--) {
case 0:
testFailed(eventHandlerName + " received after: " + message);
finishJSTest();
break;
case 1:
doNextStep();
default:
testPassed(eventHandlerName + " received after: " + message);
};
};
};
function expectOnlyChangeEvent(message, targetDocument) {
debug(" " + message);
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, 1, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 0, targetDocument);
};
function expectOnlyErrorEvent(message, targetDocument) {
debug(" " + message);
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, 0, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 1, targetDocument);
};
function expectNoEvents(message, targetDocument) {
debug(" " + message);
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, 0, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 0, targetDocument);
};
currentStep = 0;
function doNextStep(manual)
{
if (!window.testRunner && !manual)
return;
if (currentStep < todo.length)
setTimeout(function () { todo[currentStep++](); }, 0);
else if (currentStep++ == todo.length)
setTimeout(function () { finishJSTest(); }, 0);
}
todo = [
function () {
expectNoEvents("Unlock.");
document.webkitExitPointerLock();
doNextStep();
doNextStepWithUserGesture();
},
function () {
expectOnlyChangeEvent("Lock targetDiv1.");
......
......@@ -2,6 +2,7 @@
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/pointer-lock-test-harness.js"></script>
</head>
<body>
<div>
......@@ -48,10 +49,6 @@
}
}
currentStep = 0;
function doNextStep() {
setTimeout(function () { todo[currentStep++](); }, 0);
}
todo = [
function () {
navigator.webkitPointer.lock(targetdiv,
......@@ -74,7 +71,7 @@
// locklostHandler will catch unlocks and call doNextStep to bring us here.
shouldBe("document.webkitPointerLockElement", "null");
shouldBe("navigator.webkitPointer.isLocked", "false");
doNextStep();
doNextStepWithUserGesture();
},
function () {
navigator.webkitPointer.lock(targetdiv,
......@@ -100,9 +97,8 @@
shouldBe("document.webkitPointerLockElement", "null");
doNextStep();
},
finishJSTest
];
doNextStep();
doNextStepWithUserGesture();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
......
// Automatically add doNextStepButton to document for manual tests.
if (!window.testRunner) {
setTimeout(function () {
doNextStepButton = document.body.insertBefore(document.createElement("button"), document.body.firstChild);
doNextStepButton.onclick = doNextStep;
doNextStepButton.innerText = "doNextStep button for manual testing. Use keyboard to select button and press (TAB, then SPACE).";
}, 0);
}
function doNextStep()
{
if (typeof(currentStep) == "undefined")
currentStep = 0;
if (currentStep < todo.length)
setTimeout(function () { todo[currentStep++](); }, 0);
else if (currentStep++ == todo.length)
setTimeout(function () { finishJSTest(); }, 0);
}
function doNextStepWithUserGesture()
{
if (!window.testRunner)
return; // Wait for human to press doNextStep button.
doNextStep();
}
function eventExpected(eventHandlerName, message, expectedCalls, targetHanderNode)
{
targetHanderNode[eventHandlerName] = function () {
switch (expectedCalls--) {
case 0:
testFailed(eventHandlerName + " received after: " + message);
finishJSTest();
break;
case 1:
doNextStep();
default:
testPassed(eventHandlerName + " received after: " + message);
};
};
};
function expectOnlyChangeEvent(message, targetDocument) {
debug(" " + message);
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, 1, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 0, targetDocument);
};
function expectOnlyErrorEvent(message, targetDocument) {
debug(" " + message);
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, 0, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 1, targetDocument);
};
function expectNoEvents(message, targetDocument) {
debug(" " + message);
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, 0, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 0, targetDocument);
};
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