<!DOCTYPE html>
<html>
<div id="div">
    <form id="form">
        <input id="input" onfocus="focused()" type="tel"></input>
    </form>
</div>

<script>
function focused() {
    if (input.autofocus) {
        input.type = "checkbox";
        document.body.innerHTML = "FAIL - focus event handler called for autofocus";
        if (window.testRunner)
            testRunner.notifyDone();
        return;
    }

    document.body.appendChild(input);
    input.autofocus = true;
    requestAnimationFrame(() => {
        document.body.textContent = document.activeElement == document.body ? "PASS" : "FAIL";
        if (window.testRunner)
            testRunner.notifyDone();
    });
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

input.focus();
</script>
</html>