blob: 0f9d0b6753c466361281b4a8b39728a7e289e675 [file] [log] [blame]
<html manifest="resources/progress-counter.manifest">
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText()
layoutTestController.waitUntilDone();
}
var expectedTotal = 2
var eventsReceived = 0;
function done() {
if (window.layoutTestController)
layoutTestController.notifyDone();
}
function progress(event)
{
if (!event.lengthComputable) {
document.getElementById('result').innerHTML = "FAILURE: expected progressEvent.lengthComputable to be true";
done();
return;
}
if (event.total != expectedTotal) {
document.getElementById('result').innerHTML = "FAILURE: expected progressEvent.total to be " + expectedTotal + " but was " + event.total;
done();
return;
}
if (event.loaded != eventsReceived) {
document.getElementById('result').innerHTML = "FAILURE: expected progressEvent.loaded to be " + eventsReceived + " but was " + event.loaded;
done();
return;
}
eventsReceived++;
}
function cached()
{
if (eventsReceived != 3) {
document.getElementById('result').innerHTML = "FAILURE: expected 3 progress events, but got " + eventsReceived;
done();
return;
}
document.getElementById('result').innerHTML = "SUCCESS";
done();
}
function noupdate()
{
document.getElementById('result').innerHTML = "FAILURE: unable to conduct test since the appcache already exists, please remove the appcache and try again";
done();
}
applicationCache.addEventListener('cached', cached, false);
applicationCache.addEventListener('noupdate', noupdate, false);
applicationCache.addEventListener('progress', progress, false);
</script>
<div>This tests that the lengthComputable / loaded / total properties of the progress event are set correctly.</div>
<div id="result">FAILURE</div>
</html>