Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / onloadend-event-after-error.html
blob1d5835ca9f11d4fb651fd29fc09bc55dabe5b2c4
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 the error ProgressEvent when an async request fails.</p>
8 <p>PASS should appear below:</p>
9 <p id=console></p>
10 <script type="text/javascript">
11 if (window.testRunner) {
12 testRunner.dumpAsText();
13 testRunner.waitUntilDone();
16 function log(message)
18 var consoleElt = document.getElementById("console");
19 consoleElt.appendChild(document.createTextNode(message));
22 var xhr = new XMLHttpRequest();
23 var results = "";
24 var expected = " loadstart readyState=DONE error loadend";
27 function logProgressEvent(e) {
28 results += " " + e.type;
31 function logUnexpectedProgressEvent(e) {
32 results += " [unexpected ProgressEvent: " + e.type + "]";
33 completeTest();
36 function completeTest()
38 log(results == expected ? "PASS" : "FAILED results : '" + results + "', expected : '" + expected + "'");
39 if (window.testRunner)
40 testRunner.notifyDone();
43 function test()
45 xhr.onreadystatechange = function(e) {
46 if (xhr.readyState == xhr.DONE)
47 results += " readyState=DONE";
49 xhr.onloadstart = logProgressEvent;
50 xhr.onabort = logUnexpectedProgressEvent;
51 xhr.onerror = logProgressEvent;
52 xhr.onload = logUnexpectedProgressEvent;
53 xhr.onloadend = function(e) {
54 logProgressEvent(e);
55 completeTest();
58 xhr.open("GET", "resources/infinite-loop.php", true);
59 xhr.send();
62 test();
64 </script>
65 </body>