Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / onloadend-event-after-sync-requests.html
blobb4dd1ead422f9f73b0b2f347ebf1e132ec249342
1 <HTML>
2 <head>
3 <title>Test case for bug 40952</title>
4 </head>
5 <body>
6 <p> Test case for <a href="https://bugs.webkit.org/show_bug.cgi?id=40952"> bug 40952</a>: Onloadend event is not supported in XMLHttpRequest</p>
7 <p> Verify that a loadend ProgressEvent is dispatched after a load ProgressEvent when a synchronous request completes normally.<br/>
8 Verify that a loadend ProgressEvent is not dispatched after abort() is called when a synchronous request completes normally.</p>
9 <p>PASS PASS PASS should appear below:</p>
10 <p id=console></p>
11 <script type="text/javascript">
12 if (window.testRunner) {
13 testRunner.dumpAsText();
14 testRunner.waitUntilDone();
17 function log(message)
19 var consoleElt = document.getElementById("console");
20 consoleElt.appendChild(document.createTextNode(message + " "));
23 var xhr = new XMLHttpRequest();
24 var results;
26 function logProgressEvent(e) {
27 results += " " + e.type;
30 function logUnexpectedProgressEvent(e) {
31 results += " [unexpected ProgressEvent: " + e.type + "]";
32 completeTest();
35 function completeTest(expected)
37 log(results == expected ? "PASS" : "FAILED results : '" + results + "', expected : '" + expected + "'");
38 if (window.testRunner)
39 testRunner.notifyDone();
42 function testNormal()
44 results = "";
46 xhr.onloadstart = logUnexpectedProgressEvent;
47 xhr.onabort = logUnexpectedProgressEvent;
48 xhr.onerror = logUnexpectedProgressEvent;
49 xhr.onload = logProgressEvent;
50 xhr.onloadend = logProgressEvent;
52 xhr.open("GET", "resources/get.txt", false);
53 xhr.send();
55 completeTest(" load loadend");
58 function testError()
60 results = "";
62 xhr.onloadstart = logUnexpectedProgressEvent;
63 xhr.onabort = logUnexpectedProgressEvent;
64 xhr.onerror = logUnexpectedProgressEvent;
65 xhr.onload = logUnexpectedProgressEvent;
66 xhr.onloadend = logUnexpectedProgressEvent;
68 xhr.open("GET", "resources/infinite-loop.php", false);
69 try {
70 xhr.send();
72 catch (e) {
73 if (e.code != e.NETWORK_ERR)
74 results += " " + e;
77 completeTest("");
80 function testAbort()
82 results = "";
84 xhr.onloadstart = logUnexpectedProgressEvent;
85 xhr.onabort = logUnexpectedProgressEvent;
86 xhr.onerror = logUnexpectedProgressEvent;
87 xhr.onload = logUnexpectedProgressEvent;
88 xhr.onloadend = logProgressEvent;
89 xhr.onreadystatechange = function(e) {
90 if (xhr.readyState == xhr.DONE)
91 xhr.abort();
94 xhr.open("GET", "resources/get.txt", false);
95 try {
96 xhr.send();
98 catch (e) {
99 if (e.code != e.NETWORK_ERR)
100 results += " " + e;
103 completeTest("");
106 testNormal();
107 testError();
108 testAbort();
110 </script>
111 </body>