gecko/content/media/test/test_play_events.html
Chris Pearce c7317b404d Bug 564720 - Refactor media tests to be backend independent were possible. r=roc
--HG--
rename : content/media/test/test_play.html => content/media/test/test_play_events.html
rename : content/media/test/test_progress2.html => content/media/test/test_progress.html
rename : content/media/test/test_onloadedmetadata.html => content/media/test/test_replay_metadata.html
rename : content/media/test/test_wav_trunc_seek.html => content/media/test/test_seek_out_of_range.html
rename : content/media/test/test_bug495319.html => content/media/test/test_timeupdate_small_files.html
rename : content/media/test/test_bug486646.html => content/media/test/test_video_to_canvas.html
2010-05-31 10:02:06 +12:00

71 lines
1.7 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Media test: play() method</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>
var videos = [];
var tokens = {
0: ["play"],
"play": ["canplay"],
"canplay": ["playing"],
"playing": ["canplay", "canplaythrough"],
"canplaythrough": ["canplay", "canplaythrough"]
};
function gotPlayEvent(event) {
var v = event.target;
ok(tokens[v._state].indexOf(event.type) >= 0,
"Check expected event got " + event.type + " at " + v._state + " for " + v.src);
v._state = event.type;
}
function ended(event) {
var v = event.target;
v._finished = true;
is(v._state, "canplaythrough", "Last event should be canplaythrough for " + v.src);
if (AllFinished(videos)) {
SimpleTest.finish();
}
}
for (var i=0; i<gSmallTests.length; ++i) {
var v = document.createElement('video');
var test = gSmallTests[i];
if (!v.canPlayType(test.type))
continue;
v._state = 0;
v._finished = false;
["play", "canplay", "playing", "canplaythrough"].forEach(function (e) {
v.addEventListener(e, gotPlayEvent, false);
});
v.addEventListener("ended", ended, false);
v.src = test.name;
document.body.appendChild(v); // Causes load.
v.play();
videos.push(v);
}
if (videos.length == 0) {
todo(false, "No types supported");
} else {
SimpleTest.waitForExplicitFinish();
}
</script>
</pre>
</body>
</html>