blob: 9c29ec07eb8411417e0ee166b9e5dec6f64dcfab [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/ui-helper.js"></script>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
</script>
</head>
<body>
<p>This tests that the caps lock indicator is visible after hiding the Strong Password AutoFill button. It can only be tested in the test tool.</p>
<input type="password" value="A quick brown fox jumped over the lazy dog.">
<script>
function done()
{
if (window.testRunner)
testRunner.notifyDone();
}
function handleCapsLockEnabled(event)
{
console.assert(event.key === "CapsLock");
// Move the caret to the beginning of the field to ensure consistent test results.
document.querySelector("input").setSelectionRange(0, 0);
// FIXME: For some reason it takes up to 100ms for the caps lock indicator to be painted (why?).
window.setTimeout(done, 100);
}
async function runTest()
{
if (!window.testRunner)
return;
let input = document.querySelector("input");
function handleFocus(event) {
console.assert(event.target === input);
input.addEventListener("keydown", handleCapsLockEnabled, { once: true });
UIHelper.toggleCapsLock();
}
input.addEventListener("focus", handleFocus, { once: true });
UIHelper.activateElement(input); // Puts caret in the center of the field; we will fix this up.
}
runTest();
</script>
</body>
</html>