blob: 5d34018d0c0f50686e5cd5f0f1cd8bb02173071f [file] [edit]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/ui-helper.js"></script>
</head>
<body>
<p>This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.</p>
<input id="input" type="password"></input>
<div id="log"></div>
<script>
function log(msg) {
document.getElementById("log").innerHTML+= msg + "<br>";
}
function TestCase(message, testFunction) {
this.message = message;
this.testFunction = testFunction;
}
function makeTestCase(message, testFunction) {
return new TestCase(message, testFunction);
}
async function toggleCapsLockandLogCapsLockState() {
await UIHelper.toggleCapsLock();
await UIHelper.ensureStablePresentationUpdate();
if (window.internals.capsLockIsOn())
log("CapsLock is on.");
else
log("CapsLock is not on.");
}
const testCases = [
makeTestCase("1. Press Caps Lock key when view is active, make view inactive, make view active again, press Caps Lock key.", async () => {
await toggleCapsLockandLogCapsLockState();
testRunner.setWindowIsKey(false);
testRunner.setWindowIsKey(true);
await toggleCapsLockandLogCapsLockState();
}),
makeTestCase("2. Press Caps Lock key in inactive view, make view active, press Caps Lock key.", async () => {
testRunner.setWindowIsKey(false);
await toggleCapsLockandLogCapsLockState();
testRunner.setWindowIsKey(true);
await toggleCapsLockandLogCapsLockState();
}),
makeTestCase("3. Press Caps Lock key when view is active, press Caps Lock key when view is active.", async () => {
testRunner.setWindowIsKey(true);
await toggleCapsLockandLogCapsLockState();
await toggleCapsLockandLogCapsLockState();
}),
makeTestCase("4. Press Caps Lock key when view is inactive, press Caps Lock key when view inactive.", async () => {
testRunner.setWindowIsKey(false);
await toggleCapsLockandLogCapsLockState();
await toggleCapsLockandLogCapsLockState();
}),
];
async function runTest()
{
await UIHelper.activateElementAndWaitForInputSession(document.getElementById("input"));
for (const testCase of testCases) {
await UIHelper.ensureStablePresentationUpdate();
log(testCase.message);
await testCase.testFunction();
}
testRunner.notifyDone();
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
runTest();
}
</script>
</body>
</html>