Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / upload-progress-events.html
blobeb52ff108a678e793cf80324116b755a58c0fea2
1 <!DOCTYPE html>
2 <script src="/js-test-resources/testharness.js"></script>
3 <script src="/js-test-resources/testharnessreport.js"></script>
4 <p></p>
5 <script type="text/javascript">
6 var log = "";
8 function recordEvent(eventName, evt)
10 log += eventName + ": " + evt + "\n";
13 var test = async_test("progress events are fired for XMLHttpRequestUpload objects in the correct order, loadstart, progress, load, and then loadend.");
14 test.step(function() {
15 var xhr = new XMLHttpRequest;
17 xhr.upload.onprogress = function(evt)
19 log += "progress: " + evt + " (loaded=" + evt.loaded + ", total=" + evt.total + ")\n";
21 xhr.upload.onloadstart = recordEvent.bind(undefined, "loadstart");
22 xhr.upload.onload = recordEvent.bind(undefined, "load");
23 xhr.upload.onloadend = recordEvent.bind(undefined, "loadend");
24 xhr.onreadystatechange = function(evt)
26 if (xhr.readyState == xhr.DONE) {
27 var expectedLog =
28 "loadstart: [object XMLHttpRequestProgressEvent]\n" +
29 "progress: [object XMLHttpRequestProgressEvent] (loaded=4, total=4)\n" +
30 "load: [object XMLHttpRequestProgressEvent]\n" +
31 "loadend: [object XMLHttpRequestProgressEvent]\n"
32 assert_equals(log, expectedLog);
33 test.done();
37 xhr.open("POST", "resources/post-echo.cgi", true);
38 xhr.send("data");
39 });
40 </script>