chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/xmlhttprequest-responseXML-exception.html

<html>
<head></head>
<body>

<p>Test bug 12914 :  Trying to access XMLHttpRequest.responseText or responseXML when they are not available should raise an exception </p>
<p>Should see "PASS" four times:</p>
<div id="ans"></div>

<script type="text/javascript">
function log(message) {
    document.getElementById("ans").appendChild(document.createTextNode(message));
    document.getElementById("ans").appendChild(document.createElement("br"));
}

function test(num)
{
    var xhr;

    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    } else {
        try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (ex) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

    xhr.onreadystatechange = function () {
        if (this.readyState == num) {
            ++finishedTests;
            try {
                // Force evaluation for Opera
                var response = this.responseXML;
                log("PASS");
            } catch (e) {
                log("FAILED");
            }
        }
        
        if (finishedTests == 4 && window.testRunner)
            testRunner.notifyDone();
    }

    xhr.open("GET", "resources/1251.html", true);
    if (num != 1)
        xhr.send(null);
}

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

var finishedTests = 0;

for (i = 1; i < 5; i++) {
    test(i);
}

</script>
</body>
</html>