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

<p> Test bug 16989 : Add send() flag checks in XmlHttpRequest </p>
<p> You should see PASS two 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"));
}

if (window.testRunner)
    testRunner.dumpAsText();

var xhr;

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

// First test : test open method send() flag check
xhr.open("GET", "resources/endlessxml.py", true);
xhr.send(null);
try {
    if (xhr.readyState == 1)
        xhr.send(null);
    log("FAILED");
} catch (e) {
    // Call abort to prevent triggering some readystate events
    xhr.abort();
    log("PASS");
}

// Second test : test setResponseHeader method send() flag check
xhr.open("GET", "resources/endlessxml.py", true);
xhr.setRequestHeader("Test1", "Test1");
xhr.send(null);
try {
    // makes sure readyState is opened (bug in Opera)
    if (xhr.readyState == 1)
        xhr.setRequestHeader("Test", "Test");
    log("FAILED");
} catch (e) {
    // Call abort to prevent triggering some readystate events
    xhr.abort();
    log("PASS");
}

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

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