gecko/content/media/test/test_progress3.html

64 lines
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Media test: progress events</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script src="use_large_cache.js"></script>
<script class="testbody" type="text/javascript">
// Same as test_progress1 but uses a smaller file to test resource loaded
// before metadata loaded is fired.
var completed = false;
var last_progress_total = 0;
function on_loadedmetadata() {
var v = document.getElementById('v');
ok(v, "Found video element after metadata loaded");
v.play();
dump('test_progress3: on_loadedmetadata exiting\n');
}
function do_progress(e) {
dump('test_progress3: do_progress ' + e.loaded + '/' + e.total + '\n');
ok(!completed, "Check for progress event after completed");
ok(e.lengthComputable, "Check progress lengthComputable");
ok(e.loaded >= last_progress_total, "Check progress increasing: " + e.loaded);
last_progress_total = e.loaded;
ok(e.loaded <= e.total, "Check progress in bounds: " + e.loaded);
is(e.total, 28942, "Check progress total");
}
function do_ended() {
dump('test_progress3: do_ended\n');
ok(!completed, "Check for duplicate ended event");
completed = true;
SimpleTest.finish();
}
function do_timeupdate() {
var v = document.getElementById('v');
dump('test_progress3: timeupdate: ' + v.currentTime + "\n");
}
function do_play() {
dump('test_progress3: do_play\n');
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<video id='v'
src='320x240.ogv'
onloadedmetadata='on_loadedmetadata()'
onended='do_ended()'
ontimeupdate='do_timeupdate()'
onplay='do_play()'
onprogress='do_progress(event)'>
</video>
</body>
</html>