Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-sync-no-progress-events.html
blob982b9491d69612d295ea10f4cbd5e1596bd9dd36
1 <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>
2 <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>
3 <pre id=log></pre>
5 <script type="text/javascript">
6 if (window.testRunner)
7 testRunner.dumpAsText();
9 function log(message)
11 document.getElementById("log").innerHTML += message + "\n";
14 function test(url)
16 try {
17 var xhr = new XMLHttpRequest();
18 xhr.open("POST", url, false);
19 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
21 xhr.addEventListener("loadstart", function () { log("loadstart"); }, true);
22 xhr.addEventListener("readystatechange", function () { log("readystatechange " + xhr.readyState); }, true);
23 xhr.addEventListener("progress", function () { log("progress"); }, true);
24 xhr.addEventListener("load", function () { log("load"); }, true);
25 xhr.addEventListener("error", function () { log("error"); }, true);
26 xhr.addEventListener("loadend", function () { log("loadend"); }, true);
28 xhr.upload.addEventListener("loadstart", function () { log("upload.loadstart"); }, true);
29 xhr.upload.addEventListener("readystatechange", function () { log("upload.readystatechange"); }, true); // No such event on upload object, but let's add a listener anyway.
30 xhr.upload.addEventListener("progress", function () { log("upload.progress"); }, true);
31 xhr.upload.addEventListener("load", function () { log("upload.load"); }, true);
32 xhr.upload.addEventListener("error", function () { log("upload.error"); }, true);
33 xhr.upload.addEventListener("loadend", function () { log("upload.loadend"); }, true);
35 xhr.send("foobar");
36 } catch (ex) {
37 log(ex);
42 log("Step 1: Same origin request");
43 test("xmlhttprequest-sync-vs-async-assertion-failure.html");
45 log("\nStep 2: Cross origin request, disallowed");
46 test("http://localhost:8000/xmlhttprequest/xmlhttprequest-sync-vs-async-assertion-failure.html");
48 log("\nStep 3: Cross origin request, allowed");
49 test("http://localhost:8000/xmlhttprequest/resources/access-control-basic-allow.cgi");
51 log("\nStep 4: Cross origin request, check that preflight isn't attempted");
52 test("http://localhost:8000/xmlhttprequest/resources/access-control-basic-post-fail-non-simple.cgi");
53 </script>
55 </body></html>