chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html

<html>
<body>
<p>This tests the readyState of a XMLHttpRequset which is sent with a "HEAD" method to a not exist resource.</p>
<pre id="result">FAIL</pre>
<script type="text/javascript">

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

    var res = "";
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState) {
            res = res + xmlhttp.readyState;
            if(res == "124" && xmlhttp.status == 404) {
                document.getElementById('result').innerText = "PASS";

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

    xmlhttp.open("HEAD","notExist.html",true);
    xmlhttp.send();
</script>
</body>
</html>