4 <title>Test playback of media files that should play OK
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
7 <script type=
"text/javascript" src=
"manifest.js"></script>
11 <script class=
"testbody" type=
"text/javascript">
13 var manager = new MediaTestManager;
15 function startTest(test, token) {
16 var video = document.createElement('video');
18 manager.started(token);
19 video.src = test.name;
20 video.name = test.name;
21 video.playingCount =
0;
22 video._playedOnce = false;
24 var check = function(t, v) { return function() {
25 checkMetadata(t.name, v, test);
28 var noLoad = function(t, v) { return function() {
29 ok(false, t.name +
" should not fire 'load' event");
33 removeNodeAndSource(v);
34 manager.finished(v.token);
37 function mayFinish(v) {
38 if (v.seenEnded && v.seenSuspend) {
43 var checkEnded = function(t, v) { return function() {
45 ok(Math.abs(v.currentTime - t.duration) <
0.1,
46 t.name +
" current time at end: " + v.currentTime);
49 is(v.readyState, v.HAVE_CURRENT_DATA, t.name +
" checking readyState");
50 ok(v.ended, t.name +
" checking playback has ended");
51 ok(v.playingCount
> 0,
"Expect at least one playing event");
63 var checkSuspended = function(t, v) { return function() {
69 ok(true, t.name +
" got suspend");
73 var checkPlaying = function(t, v) { return function() {
74 is(t.name, v.name,
"Should be testing file we think we're testing...");
78 video.addEventListener(
"load", noLoad);
79 video.addEventListener(
"loadedmetadata", check);
80 video.addEventListener(
"playing", checkPlaying);
82 // We should get
"ended" and
"suspend" events for every resource
83 video.addEventListener(
"ended", checkEnded);
84 video.addEventListener(
"suspend", checkSuspended);
86 document.body.appendChild(video);
90 manager.runTests(gReplayTests, startTest);