chromium/third_party/blink/web_tests/fast/forms/autofocus-opera-004.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>testing "autofocus" in XHTML combined with dynamic changes</title>
<style>
 input { background:red }
 input:focus { background:lime }
</style>
<script language="JavaScript" type="text/javascript">
    function log(message) {
        document.getElementById("console").innerHTML += "<li>"+message+"</li>";
    }

    function test() {
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.waitUntilDone();
        }
        var input = document.getElementsByTagName('input')[0];
        var p = document.getElementsByTagName('p')[0];
        var input = p.removeChild(input);
        input.setAttribute('autofocus','false');
        input.addEventListener('focus', check, false);
        p.appendChild(input);
        setTimeout(check, 1000);
    }
    
    function check() {
        if (document.activeElement == document.getElementsByTagName("input")[0])
            log("SUCCESS");
        else
            log("FAILURE");

        if (window.testRunner)
            testRunner.notifyDone();
    }

</script>
</head>
<body onload="test()">
<p>The form control should have a green background: <input/></p>
<hr/>
<ol id="console"></ol>
</body>
</html>