2009-07-09 19:03:01 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test playback of media files that should play OK</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" />
|
|
|
|
<script type="text/javascript" src="manifest.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
var PARALLEL_TESTS = 2;
|
|
|
|
|
|
|
|
var testIndex = 0;
|
|
|
|
var videos = [];
|
|
|
|
|
|
|
|
var testsWaiting = 0;
|
|
|
|
|
|
|
|
function startTests() {
|
|
|
|
for (var i = 0; i < videos.length; ++i) {
|
|
|
|
document.body.removeChild(videos[i]);
|
|
|
|
}
|
|
|
|
videos = [];
|
|
|
|
while (videos.length < PARALLEL_TESTS && testIndex < gPlayTests.length) {
|
|
|
|
var v = document.createElement('video');
|
|
|
|
var test = gPlayTests[testIndex];
|
|
|
|
++testIndex;
|
2009-07-14 07:04:56 -07:00
|
|
|
if (!v.canPlayType(test.type))
|
2009-07-09 19:03:01 -07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
v.src = test.name;
|
|
|
|
var check = function(test, v) { return function() {
|
|
|
|
checkMetadata(test.name, v, test);
|
|
|
|
}}(test, v);
|
|
|
|
var checkEnded = function(test, v) { return function() {
|
|
|
|
if (test.duration) {
|
|
|
|
ok(Math.abs(v.currentTime - test.duration) < 0.1,
|
|
|
|
test.name + " current time at end: " + v.currentTime);
|
|
|
|
}
|
2009-09-29 14:32:41 -07:00
|
|
|
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
|
2009-07-09 19:03:01 -07:00
|
|
|
ok(v.ended, test.name + " checking playback has ended");
|
|
|
|
--testsWaiting;
|
|
|
|
if (testsWaiting == 0) {
|
|
|
|
setTimeout(startTests, 0);
|
|
|
|
}
|
|
|
|
}}(test, v);
|
2009-08-16 14:32:24 -07:00
|
|
|
v.prevTime = 0;
|
|
|
|
var timeUpdate = function(v) { return function() {
|
|
|
|
ok(v.prevTime <= v.currentTime,
|
|
|
|
test.name + " time should run forwards: p=" +
|
|
|
|
v.prevTime + " c=" + v.currentTime);
|
|
|
|
v.prevTime = v.currentTime;
|
|
|
|
}}(v);
|
2009-07-09 19:03:01 -07:00
|
|
|
v.addEventListener("loadedmetadata", check, false);
|
|
|
|
v.addEventListener("ended", checkEnded, false);
|
2009-08-16 14:32:24 -07:00
|
|
|
v.addEventListener("timeupdate", timeUpdate, false);
|
2009-07-09 19:03:01 -07:00
|
|
|
++testsWaiting;
|
|
|
|
document.body.appendChild(v);
|
|
|
|
v.play();
|
|
|
|
videos.push(v);
|
|
|
|
}
|
|
|
|
if (videos.length == 0) {
|
|
|
|
// No new tests were spawned, perhaps the remaining tests on the list are
|
|
|
|
// not supported, or we just reached the end of the list.
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
addLoadEvent(startTests);
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|