gecko/content/media/test/test_bug495145.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

96 lines
2.0 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=495145
-->
<head>
<title>Bug 495145 - pausing while ended shouldn't cause problems</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>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495145">Mozilla Bug 495145</a>
<pre id="test">
<script class="testbody" type="text/javascript">
var videos = [];
function start(e) {
e.target.play();
}
function ended1(e) {
var v = e.target;
if (v._finished)
return;
++v._endCount;
if (v._endCount == 2) {
ok(true, "Playing after pause while ended works for " + v._name);
v._finished = true;
if (AllFinished(videos))
SimpleTest.finish();
return;
}
v.pause();
v.play();
}
function ended2(e) {
var v = e.target;
if (v._finished)
return;
v.pause();
v.currentTime = 0;
}
function seeked2(e) {
var v = e.target;
if (v._finished)
return;
ok(v.paused, "Paused after seek after pause while ended for " + v._name);
v._finished = true;
if (AllFinished(videos))
SimpleTest.finish();
}
function createVideo(test, x) {
var v = document.createElement('video');
if (!v.canPlayType(test.type))
return null;
v.src = test.name;
v._name = test.name + "#" + x;
v._endCount = 0;
v._finished = false;
v.addEventListener("loadedmetadata", start, false);
v.addEventListener("ended", x == 1 ? ended1 : ended2, false);
if (x == 2)
v.addEventListener("seeked", seeked2, false);
document.body.appendChild(v);
videos.push(v);
}
for (var i=0; i<gSmallTests.length; ++i) {
var test = gSmallTests[i];
createVideo(test, 1);
createVideo(test, 2);
}
if (videos.length == 0) {
todo(false, "No types supported");
} else {
SimpleTest.waitForExplicitFinish();
}
</script>
</pre>
</body>
</html>