blob: 982b9491d69612d295ea10f4cbd5e1596bd9dd36 [file] [log] [blame]
<p> Test for: <ul><li><a href="https://bugs.webkit.org/show_bug.cgi?id=40996">bug 40996<a>: Progress event should not be fired during synchronous XMLHttpRequest;</li>
<li><a href="https://bugs.webkit.org/show_bug.cgi?id=17502">bug 17502<a>: Assertion failure when trying to restart a sync XMLHttpRequest as an async one from onreadystatechange.</li></ul>
<pre id=log></pre>
<script type="text/javascript">
if (window.testRunner)
testRunner.dumpAsText();
function log(message)
{
document.getElementById("log").innerHTML += message + "\n";
}
function test(url)
{
try {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, false);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.addEventListener("loadstart", function () { log("loadstart"); }, true);
xhr.addEventListener("readystatechange", function () { log("readystatechange " + xhr.readyState); }, true);
xhr.addEventListener("progress", function () { log("progress"); }, true);
xhr.addEventListener("load", function () { log("load"); }, true);
xhr.addEventListener("error", function () { log("error"); }, true);
xhr.addEventListener("loadend", function () { log("loadend"); }, true);
xhr.upload.addEventListener("loadstart", function () { log("upload.loadstart"); }, true);
xhr.upload.addEventListener("readystatechange", function () { log("upload.readystatechange"); }, true); // No such event on upload object, but let's add a listener anyway.
xhr.upload.addEventListener("progress", function () { log("upload.progress"); }, true);
xhr.upload.addEventListener("load", function () { log("upload.load"); }, true);
xhr.upload.addEventListener("error", function () { log("upload.error"); }, true);
xhr.upload.addEventListener("loadend", function () { log("upload.loadend"); }, true);
xhr.send("foobar");
} catch (ex) {
log(ex);
}
}
log("Step 1: Same origin request");
test("xmlhttprequest-sync-vs-async-assertion-failure.html");
log("\nStep 2: Cross origin request, disallowed");
test("http://localhost:8000/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html");
log("\nStep 3: Cross origin request, allowed");
test("http://localhost:8000/xmlhttprequest/resources/access-control-basic-allow.cgi");
log("\nStep 4: Cross origin request, check that preflight isn't attempted");
test("http://localhost:8000/xmlhttprequest/resources/access-control-basic-post-fail-non-simple.cgi");
</script>
</body></html>