blob: e9264e14ec8d0baf33b9b17af88bd376be41c8a8 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Test for &lt;input autofocus&gt;</p>
<div id="console"></div>
<input id="input" type="text" value="foo" autofocus>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
// iOS places the caret at the end of the input field.
if (window.internals)
internals.settings.setEditingBehavior("mac");
function log(msg) {
document.getElementById("console").appendChild(document.createElement("div")).textContent = msg;
}
inputFocusCount = 0;
input.addEventListener("focus", (event) => {
++inputFocusCount;
});
requestAnimationFrame(() => {
log(`${inputFocusCount === 1 ? "PASS" : "FAIL"} inputFocusCount is 1`);
log(`${input.selectionStart === 0 ? "PASS" : "FAIL"} input.selectionStart is 0`);
log(`${input.selectionEnd === 0 ? "PASS" : "FAIL"} input.selectionEnd is 0`);
window.testRunner?.notifyDone();
});
</script>
</body>
</html>