2009-07-10 06:03:01 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test playback of media files that should play OK</title>
|
2019-04-16 06:53:28 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2009-07-10 06:03:01 +04:00
|
|
|
<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">
|
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
var manager = new MediaTestManager;
|
2009-07-10 06:03:01 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
function startTest(test, token) {
|
|
|
|
var v = document.createElement('video');
|
2013-07-31 11:35:44 +04:00
|
|
|
v.preload = "metadata";
|
2010-08-27 06:11:46 +04:00
|
|
|
v.token = token;
|
2014-10-07 21:55:00 +04:00
|
|
|
v.prevTime = 0;
|
2015-04-15 06:12:57 +03:00
|
|
|
v.seenEnded = false;
|
|
|
|
v.seenSuspend = false;
|
|
|
|
|
|
|
|
var handler = {
|
|
|
|
"ontimeout": function() {
|
|
|
|
Log(token, "timed out: ended=" + v.seenEnded + ", suspend=" + v.seenSuspend);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
manager.started(token, handler);
|
2009-07-10 06:03:01 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
v.src = test.name;
|
|
|
|
v.name = test.name;
|
2014-10-07 21:55:00 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
var check = function(test, v) { return function() {
|
2014-10-07 21:55:00 +04:00
|
|
|
is(test.name, v.name, test.name + ": Name should match #1");
|
2010-08-27 06:11:46 +04:00
|
|
|
checkMetadata(test.name, v, test);
|
|
|
|
}}(test, v);
|
2014-10-07 21:55:00 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
var noLoad = function(test, v) { return function() {
|
|
|
|
ok(false, test.name + " should not fire 'load' event");
|
|
|
|
}}(test, v);
|
2014-10-07 21:55:00 +04:00
|
|
|
|
2018-01-18 00:38:02 +03:00
|
|
|
var noError = function(test, v) { return function() {
|
|
|
|
ok(false, test.name + " should not fire 'error' event " + v.error.message);
|
|
|
|
}}(test, v);
|
|
|
|
|
2014-10-07 21:57:00 +04:00
|
|
|
var finish = function() {
|
|
|
|
v.finished = true;
|
2017-01-17 13:50:25 +03:00
|
|
|
v.removeEventListener("timeupdate", timeUpdate);
|
2014-10-07 21:57:00 +04:00
|
|
|
removeNodeAndSource(v);
|
|
|
|
manager.finished(v.token);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We should get "ended" and "suspend" events to finish the test.
|
|
|
|
var mayFinish = function() {
|
|
|
|
if (v.seenEnded && v.seenSuspend) {
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
var checkEnded = function(test, v) { return function() {
|
2014-10-07 21:55:00 +04:00
|
|
|
is(test.name, v.name, test.name + ": Name should match #2");
|
2014-10-07 21:57:00 +04:00
|
|
|
checkMetadata(test.name, v, test);
|
2010-08-27 06:11:46 +04:00
|
|
|
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
|
|
|
|
ok(v.ended, test.name + " checking playback has ended");
|
2014-10-07 21:57:00 +04:00
|
|
|
ok(!v.finished, test.name + " shouldn't be finished");
|
|
|
|
ok(!v.seenEnded, test.name + " shouldn't be ended");
|
|
|
|
|
|
|
|
v.seenEnded = true;
|
|
|
|
mayFinish();
|
2010-08-27 06:11:46 +04:00
|
|
|
}}(test, v);
|
2014-10-07 21:55:00 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
var checkSuspended = function(test, v) { return function() {
|
2014-10-07 21:55:00 +04:00
|
|
|
if (v.seenSuspend) {
|
2010-08-27 06:11:46 +04:00
|
|
|
return;
|
2014-10-07 21:55:00 +04:00
|
|
|
}
|
2014-10-07 21:57:00 +04:00
|
|
|
is(test.name, v.name, test.name + ": Name should match #3");
|
2009-07-10 06:03:01 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
v.seenSuspend = true;
|
2014-10-07 21:57:00 +04:00
|
|
|
mayFinish();
|
2010-08-27 06:11:46 +04:00
|
|
|
}}(test, v);
|
2014-10-07 21:55:00 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
var timeUpdate = function(test, v) { return function() {
|
2014-10-07 21:55:00 +04:00
|
|
|
if (v.prevTime > v.currentTime) {
|
|
|
|
ok(false, test.name + " time should run forwards: p=" +
|
|
|
|
v.prevTime + " c=" + v.currentTime);
|
|
|
|
}
|
2010-08-27 06:11:46 +04:00
|
|
|
v.prevTime = v.currentTime;
|
|
|
|
}}(test, v);
|
2014-10-07 21:55:00 +04:00
|
|
|
|
2017-01-17 13:50:25 +03:00
|
|
|
v.addEventListener("load", noLoad);
|
2018-01-18 00:38:02 +03:00
|
|
|
v.addEventListener("error", noError);
|
2017-01-17 13:50:25 +03:00
|
|
|
v.addEventListener("loadedmetadata", check);
|
|
|
|
v.addEventListener("timeupdate", timeUpdate);
|
2009-10-09 15:48:55 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
// We should get "ended" and "suspend" events for every resource
|
2017-01-17 13:50:25 +03:00
|
|
|
v.addEventListener("ended", checkEnded);
|
|
|
|
v.addEventListener("suspend", checkSuspended);
|
2009-10-09 15:48:55 +04:00
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
document.body.appendChild(v);
|
|
|
|
v.play();
|
2009-07-10 06:03:01 +04:00
|
|
|
}
|
|
|
|
|
2010-08-27 06:11:46 +04:00
|
|
|
manager.runTests(gPlayTests, startTest);
|
2009-07-10 06:03:01 +04:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|