blob: b431b0ca70ef89b3a6c45149ed52e4275611899f [file] [log] [blame]
<html>
<head>
<title>Test case for bug 120828</title>
</head>
<body>
<p> Test case for <a href="https://bugs.webkit.org/show_bug.cgi?id=120828"> bug 120828</a>: Correctly set XHR loadend attributes (loaded and total).</p>
<p> Upload case: verify that load and loadend events have their ProgressEvent attributes (loaded, total and lengthComputable) correctly set.</p>
<p id=console></p>
<script type="text/javascript">
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var status = "PASS";
var total = 1;
var loaded = 1;
var uploadedData = "d";
function onProgressEvent(e)
{
if (!e.lengthComputable)
fail("Event " + e.type + "event lengthComputable = false");
if (e.total != total || e.loaded != loaded)
fail("Event " + e.type + "total/loaded values not matching: "
+ "(" + e.loaded + " / " + e.total + "), expected (" + loaded + " / " + total + ")");
}
function onUnexpectedProgressEvent(e)
{
fail("unexpected ProgressEvent: " + e.type);
}
function fail(msg)
{
status = "FAILED: " + msg;
completeTest();
status = "";
}
function completeTest()
{
log(status);
if (window.testRunner)
testRunner.notifyDone();
}
function test()
{
var req = new XMLHttpRequest();
req.upload.onabort = onUnexpectedProgressEvent;
req.upload.onerror = onUnexpectedProgressEvent;
req.upload.onprogress = onProgressEvent;
req.upload.onload = onProgressEvent;
req.upload.onloadend = function(e) {
onProgressEvent(e);
completeTest();
}
req.open("POST", "resources/post-echo.cgi", true);
req.send(uploadedData);
}
function log(message)
{
var consoleElt = document.getElementById("console");
consoleElt.innerHTML += message + "<br/>";
}
test();
</script>
</body>
</html>