| <html> |
| <head> |
| <title>Test case for bug 40952</title> |
| </head> |
| <body> |
| <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> |
| <p> Verify that a loadend ProgressEvent is dispatched after the error ProgressEvent when an async request fails.</p> |
| <p> Verify also that a progress ProgressEvent is sent between readystatechange and error ProgressEvent (<a href="https://bugs.webkit.org/show_bug.cgi?id=126575">bug 126575</a>).</p> |
| <p>PASS should appear below:</p> |
| <p id=console></p> |
| <script type="text/javascript"> |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| function log(message) |
| { |
| var consoleElt = document.getElementById("console"); |
| consoleElt.appendChild(document.createTextNode(message)); |
| } |
| |
| var xhr = new XMLHttpRequest(); |
| var results = ""; |
| var expected = " loadstart readyState=DONE error loadend"; |
| |
| |
| function logProgressEvent(e) { |
| results += " " + e.type; |
| } |
| |
| function logUnexpectedProgressEvent(e) { |
| results += " [unexpected ProgressEvent: " + e.type + "]"; |
| completeTest(); |
| } |
| |
| function completeTest() |
| { |
| log(results == expected ? "PASS" : "FAILED results : '" + results + "', expected : '" + expected + "'"); |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| function test() |
| { |
| xhr.onreadystatechange = function(e) { |
| if (xhr.readyState == xhr.DONE) { |
| results += " readyState=DONE"; |
| xhr.onprogress = logProgressEvent; |
| } |
| } |
| xhr.onloadstart = logProgressEvent; |
| xhr.onabort = logUnexpectedProgressEvent; |
| xhr.onerror = logProgressEvent; |
| xhr.onload = logUnexpectedProgressEvent; |
| xhr.onloadend = function(e) { |
| logProgressEvent(e); |
| completeTest(); |
| } |
| |
| xhr.open("GET", "resources/infinite-loop.php", true); |
| xhr.send(); |
| } |
| |
| test(); |
| |
| </script> |
| </body> |
| |