2 <script src=
"/js-test-resources/testharness.js"></script>
3 <script src=
"/js-test-resources/testharnessreport.js"></script>
5 <script type=
"text/javascript">
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
) {
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
);
37 xhr
.open("POST", "resources/post-echo.cgi", true);