blob: e02f5139bc5b400d46b3fbd8c60aeb15b43c0f5d [file] [log] [blame]
<!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 type="password"></input>
<div id="log"></div>
<script>
function log(msg) {
document.getElementById("log").innerHTML+= msg + "<br>";
}
function keyDown(e) {
if (e.key == "q")
return;
if (window.internals) {
log(messages[messageCount++]);
if (window.internals.capsLockIsOn())
log("CapsLock is on.");
else
log("CapsLock is not on.");
}
}
function keyUp(e) {
if (e.key == "q")
testRunner.notifyDone();
if (window.internals) {
if (window.internals.capsLockIsOn())
log("CapsLock is on.");
else
log("CapsLock is not on.");
}
}
var messages = ["1. Press Caps Lock key when view is active, make view inactive, make view active again, press Caps Lock key.",
"2. Press Caps Lock key in inactive view, make view active, press Caps Lock key.",
"3. Press Caps Lock key when view is active, press Caps Lock key when view is active.",
"4. Press Caps Lock key when view is inactive, press Caps Lock key when view inactive."];
var messageCount = 0;
var input = document.getElementsByTagName("input")[0];
input.addEventListener('keydown', keyDown, false);
input.addEventListener('keyup', keyUp, false);
input.focus();
async function runTest()
{
await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(false);
testRunner.setWindowIsKey(true);
await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(false);
await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(true);
await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(true);
await UIHelper.toggleCapsLock();
await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(false);
await UIHelper.toggleCapsLock();
await UIHelper.toggleCapsLock();
eventSender.keyDown("q", []);
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
runTest();
}
</script>
</body>
</html>