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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/xmlhttprequest/upload-onload-event.html
diff --git a/LayoutTests/http/tests/xmlhttprequest/upload-onload-event.html b/LayoutTests/http/tests/xmlhttprequest/upload-onload-event.html
index 505cacf9211cfd43616bcd70503f3165a68a88f7..4a9b0f04931ef129a2f9748e9156a55336ea6a94 100644
--- a/LayoutTests/http/tests/xmlhttprequest/upload-onload-event.html
+++ b/LayoutTests/http/tests/xmlhttprequest/upload-onload-event.html
@@ -1,38 +1,38 @@
+<!doctype html>
<html>
+<head>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+</head>
<body>
-<p>This test that the load event is fired for XMLHttpRequestUpload objects.</p>
-<pre id='console'></pre>
+<div id="log"></div>
<script type="text/javascript">
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
- function log(message)
- {
- document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
- }
+var xhr;
+var payload = "data";
+var expectedLength = payload.length;
- var xhr;
+function verifyProgressEvent(eventName, e, expected)
+{
+ assert_true(e.lengthComputable);
+ assert_equals(e.loaded, expected, "Expected 'loaded' value of '" + eventName + "' event.");
+ assert_equals(e.total, expected, "Expected 'total' value of '" + eventName + "' event.");
+}
- function loadHandler(evt)
- {
- log("PASS: load event fired on XMLHttpRequestUpload.");
- }
+function loadHandler(e)
+{
+ assert_true(e instanceof ProgressEvent);
+ verifyProgressEvent("onload", e, expectedLength);
+ testUploadLoadEvent.done();
+}
- function readystatechangeHandler(evt)
- {
- if (xhr.readyState == xhr.DONE) {
- if (window.testRunner)
- testRunner.notifyDone();
- }
- }
-
- xhr = new XMLHttpRequest;
- xhr.upload.onload = loadHandler;
- xhr.onreadystatechange = readystatechangeHandler;
- xhr.open("POST", "resources/post-echo.cgi", true);
- xhr.send("data");
+var testUploadLoadEvent = async_test("Check that upload 'load' events are delivered and have expected values.");
+testUploadLoadEvent.step(function () {
+ xhr = new XMLHttpRequest();
+ xhr.upload.onload = testUploadLoadEvent.step_func(loadHandler);
+ xhr.open("POST", "resources/post-echo.php", true);
+ xhr.send(payload);
+});
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698