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> |