Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / onloadend-event-after-abort.html
blob3766d0a141e7929b6c5f20b6105aa2ad42240ae0
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 abort ProgressEvent when an async request is aborted.</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 abort loadend";
26 function logProgressEvent(e) {
27 results += " " + e.type;
30 function logUnexpectedProgressEvent(e) {
31 results += " [unexpected ProgressEvent: " + e.type + "]";
32 completeTest();
35 function completeTest()
37 log(results == expected ? "PASS" : "FAILED results : '" + results + "', expected : '" + expected + "'");
38 if (window.testRunner)
39 testRunner.notifyDone();
42 function test()
44 xhr.onreadystatechange = function(e) {
45 if (xhr.readyState == xhr.DONE)
46 results += " readyState=DONE";
47 else if (xhr.readyState > xhr.OPENED)
48 xhr.abort();
50 xhr.onloadstart = logProgressEvent;
51 xhr.onabort = logProgressEvent;
52 xhr.onerror = logUnexpectedProgressEvent;
53 xhr.onload = logUnexpectedProgressEvent;
54 xhr.onloadend = function(e) {
55 logProgressEvent(e);
56 completeTest();
59 xhr.open("GET", "resources/get.txt", true);
60 xhr.send();
63 test();
65 </script>
66 </body>