Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: LayoutTests/http/tests/xmlhttprequest/upload-onload-event.html

Issue 79953004: Improve fidelity of XHR progress events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test stable Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!doctype html>
1 <html> 2 <html>
3 <head>
4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 </head>
2 <body> 7 <body>
3 <p>This test that the load event is fired for XMLHttpRequestUpload objects.</p> 8 <div id="log"></div>
4 <pre id='console'></pre>
5 <script type="text/javascript"> 9 <script type="text/javascript">
6 if (window.testRunner) {
7 testRunner.dumpAsText();
8 testRunner.waitUntilDone();
9 }
10 10
11 function log(message) 11 var xhr;
12 { 12 var payload = "data";
13 document.getElementById('console').appendChild(document.createTextNode(m essage + "\n")); 13 var expectedLength = payload.length;
14 }
15 14
16 var xhr; 15 function verifyProgressEvent(eventName, e, expected)
16 {
17 assert_true(e.lengthComputable);
18 assert_equals(e.loaded, expected, "Expected 'loaded' value of '" + eventName + "' event.");
19 assert_equals(e.total, expected, "Expected 'total' value of '" + eventName + "' event.");
20 }
17 21
18 function loadHandler(evt) 22 function loadHandler(e)
19 { 23 {
20 log("PASS: load event fired on XMLHttpRequestUpload."); 24 assert_true(e instanceof ProgressEvent);
21 } 25 verifyProgressEvent("onload", e, expectedLength);
26 testUploadLoadEvent.done();
27 }
22 28
23 function readystatechangeHandler(evt) 29 var testUploadLoadEvent = async_test("Check that upload 'load' events are delive red and have expected values.");
24 { 30 testUploadLoadEvent.step(function () {
25 if (xhr.readyState == xhr.DONE) { 31 xhr = new XMLHttpRequest();
26 if (window.testRunner) 32 xhr.upload.onload = testUploadLoadEvent.step_func(loadHandler);
27 testRunner.notifyDone(); 33 xhr.open("POST", "resources/post-echo.php", true);
28 } 34 xhr.send(payload);
29 } 35 });
30
31 xhr = new XMLHttpRequest;
32 xhr.upload.onload = loadHandler;
33 xhr.onreadystatechange = readystatechangeHandler;
34 xhr.open("POST", "resources/post-echo.cgi", true);
35 xhr.send("data");
36 </script> 36 </script>
37 </body> 37 </body>
38 </html> 38 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698