blob: d897a71109e24dc9946a659c4dd4dffe40c59f02 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>ProgressEvent: firing events for HTTP with Content-Length</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="http://dvcs.w3.org/hg/progress/raw-file/tip/Overview.html#firing-events-using-the-progressevent-interface-for-http" data-tested-assertations="/following-sibling::ol/li[1] /following-sibling::ol/li[2]" />
</head>
<body>
<div id="log"></div>
<script>
var test = async_test();
test.step(function() {
var xhr = new XMLHttpRequest();
xhr.onprogress = function(pe) {
test.step(function() {
if(pe.type == "progress") {
assert_true(pe.loaded >= 0, "loaded is initialize to the number of HTTP entity body bytes transferred.");
assert_true(pe.lengthComputable, "lengthComputable is true.");
assert_not_equals(pe.total, 0, "total is not zero.");
}
}, "Check lengthComputed, loaded, total when Content-Length is given.");
}
// "loadstart", "error", "abort", "load" tests are out of scope.
// They SHOULD be tested in each spec that implement ProgressEvent.
xhr.onloadend = function(pe) {
test.done();
}
xhr.open("GET", "resources/img.jpg", true);
xhr.send(null);
})
</script>
</body>
</html>