2009-01-15 12:26:51 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Media test: progress events</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
2009-01-15 12:26:51 -08:00
|
|
|
<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">
|
2009-03-31 17:52:56 -07:00
|
|
|
<script src="use_large_cache.js"></script>
|
2009-01-15 12:26:51 -08:00
|
|
|
<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;
|
2009-02-05 00:02:21 -08:00
|
|
|
var last_progress_total = 0;
|
2009-01-15 12:26:51 -08:00
|
|
|
|
|
|
|
function on_loadedmetadata() {
|
|
|
|
var v = document.getElementById('v');
|
2009-02-05 00:02:21 -08:00
|
|
|
ok(v, "Found video element after metadata loaded");
|
2009-01-15 12:26:51 -08:00
|
|
|
v.play();
|
2009-02-05 00:02:21 -08:00
|
|
|
dump('test_progress3: on_loadedmetadata exiting\n');
|
2009-01-15 12:26:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function do_progress(e) {
|
2009-02-05 00:02:21 -08:00
|
|
|
dump('test_progress3: do_progress ' + e.loaded + '/' + e.total + '\n');
|
|
|
|
ok(!completed, "Check for progress event after completed");
|
2009-01-15 12:26:51 -08:00
|
|
|
ok(e.lengthComputable, "Check progress lengthComputable");
|
2009-02-05 00:02:21 -08:00
|
|
|
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");
|
2009-01-15 12:26:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function do_ended() {
|
2009-02-05 00:02:21 -08:00
|
|
|
dump('test_progress3: do_ended\n');
|
2009-01-15 12:26:51 -08:00
|
|
|
ok(!completed, "Check for duplicate ended event");
|
|
|
|
completed = true;
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function do_timeupdate() {
|
|
|
|
var v = document.getElementById('v');
|
2009-02-05 00:02:21 -08:00
|
|
|
dump('test_progress3: timeupdate: ' + v.currentTime + "\n");
|
2009-01-15 12:26:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function do_play() {
|
2009-02-05 00:02:21 -08:00
|
|
|
dump('test_progress3: do_play\n');
|
2009-01-15 12:26:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
<video id='v'
|
2009-01-16 01:07:26 -08:00
|
|
|
src='320x240.ogv'
|
2009-01-15 12:26:51 -08:00
|
|
|
onloadedmetadata='on_loadedmetadata()'
|
|
|
|
onended='do_ended()'
|
|
|
|
ontimeupdate='do_timeupdate()'
|
|
|
|
onplay='do_play()'
|
|
|
|
onprogress='do_progress(event)'>
|
|
|
|
</video>
|
|
|
|
</body>
|
|
|
|
</html>
|