2012-04-29 20:13:42 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test that reloading and seeking in a media element that's being captured doesn't crash</title>
|
|
|
|
<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>
|
|
|
|
<video id="v"></video>
|
|
|
|
<video id="vout"></video>
|
2012-08-19 21:57:12 -07:00
|
|
|
<video id="vout_untilended"></video>
|
2012-04-29 20:13:42 -07:00
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var v = document.getElementById('v');
|
|
|
|
var vout = document.getElementById('vout');
|
2012-08-19 21:57:12 -07:00
|
|
|
var vout_untilended = document.getElementById('vout_untilended');
|
2012-09-23 20:47:30 -07:00
|
|
|
vout.mozSrcObject = v.mozCaptureStream();
|
|
|
|
vout_untilended.mozSrcObject = v.mozCaptureStreamUntilEnded();
|
2012-04-29 20:13:42 -07:00
|
|
|
|
2012-05-03 22:05:42 -07:00
|
|
|
function dumpEvent(event) {
|
2012-05-09 20:30:34 -07:00
|
|
|
dump("GOT EVENT " + event.type + " currentTime=" + event.target.currentTime +
|
|
|
|
" paused=" + event.target.paused + " ended=" + event.target.ended +
|
|
|
|
" readyState=" + event.target.readyState + "\n");
|
2012-05-03 22:05:42 -07:00
|
|
|
}
|
|
|
|
var events = ["timeupdate", "seeking", "seeked", "ended", "playing", "pause"];
|
|
|
|
for (var i = 0; i < events.length; ++i) {
|
|
|
|
v.addEventListener(events[i], dumpEvent, false);
|
|
|
|
}
|
2012-08-19 21:57:12 -07:00
|
|
|
function isWithinEps(a, b, msg) {
|
|
|
|
ok(Math.abs(a - b) < 0.01,
|
|
|
|
"Got " + a + ", expected " + b + "; " + msg);
|
|
|
|
}
|
2012-05-03 22:05:42 -07:00
|
|
|
|
2012-04-29 20:13:42 -07:00
|
|
|
function startTest(test) {
|
|
|
|
var seekTime = test.duration/2;
|
|
|
|
|
2012-08-19 21:57:12 -07:00
|
|
|
function endedAfterReplay() {
|
|
|
|
isWithinEps(v.currentTime, test.duration, "checking v.currentTime at third 'ended' event");
|
|
|
|
isWithinEps(vout.currentTime, (v.currentTime - seekTime) + test.duration*2,
|
|
|
|
"checking vout.currentTime after seeking, playing through and reloading");
|
2012-04-29 20:13:42 -07:00
|
|
|
SimpleTest.finish();
|
|
|
|
};
|
2012-08-19 21:57:12 -07:00
|
|
|
function endedAfterSeek() {
|
|
|
|
isWithinEps(v.currentTime, test.duration, "checking v.currentTime at second 'ended' event");
|
|
|
|
isWithinEps(vout.currentTime, (v.currentTime - seekTime) + test.duration,
|
|
|
|
"checking vout.currentTime after seeking and playing through again");
|
|
|
|
v.removeEventListener("ended", endedAfterSeek, false);
|
|
|
|
v.addEventListener("ended", endedAfterReplay, false);
|
2012-04-29 20:13:42 -07:00
|
|
|
v.src = test.name + "?1";
|
|
|
|
v.play();
|
|
|
|
};
|
|
|
|
function seeked() {
|
2012-08-19 21:57:12 -07:00
|
|
|
isWithinEps(v.currentTime, seekTime, "Finished seeking");
|
|
|
|
isWithinEps(vout.currentTime, test.duration,
|
|
|
|
"checking vout.currentTime has not changed after seeking");
|
2012-04-29 20:13:42 -07:00
|
|
|
v.removeEventListener("seeked", seeked, false);
|
2012-08-19 21:57:12 -07:00
|
|
|
function dontPlayAgain() {
|
|
|
|
ok(false, "vout_untilended should not play again");
|
|
|
|
}
|
|
|
|
vout_untilended.addEventListener("playing", dontPlayAgain, false);
|
|
|
|
vout_untilended.addEventListener("ended", dontPlayAgain, false);
|
|
|
|
v.addEventListener("ended", endedAfterSeek, false);
|
|
|
|
v.play();
|
2012-04-29 20:13:42 -07:00
|
|
|
};
|
2012-08-19 21:57:12 -07:00
|
|
|
function ended() {
|
|
|
|
isWithinEps(vout.currentTime, test.duration, "checking vout.currentTime at first 'ended' event");
|
|
|
|
isWithinEps(v.currentTime, test.duration, "checking v.currentTime at first 'ended' event");
|
|
|
|
is(vout.ended, false, "checking vout has not ended");
|
|
|
|
is(vout_untilended.ended, true, "checking vout_untilended has actually ended");
|
|
|
|
vout_untilended.removeEventListener("ended", ended, false);
|
|
|
|
v.pause();
|
2012-04-29 20:13:42 -07:00
|
|
|
v.currentTime = seekTime;
|
|
|
|
v.addEventListener("seeked", seeked, false);
|
|
|
|
};
|
2012-08-19 21:57:12 -07:00
|
|
|
vout_untilended.addEventListener("ended", ended, false);
|
2012-04-29 20:13:42 -07:00
|
|
|
|
|
|
|
v.src = test.name;
|
|
|
|
v.play();
|
2012-08-19 21:57:12 -07:00
|
|
|
function checkNoEnded() {
|
|
|
|
ok(false, "ended event received unexpectedly");
|
|
|
|
};
|
|
|
|
vout.addEventListener("ended", checkNoEnded, false);
|
2012-04-29 20:13:42 -07:00
|
|
|
vout.play();
|
2012-08-19 21:57:12 -07:00
|
|
|
vout_untilended.play();
|
2012-04-29 20:13:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var testVideo = getPlayableVideo(gSmallTests);
|
|
|
|
if (testVideo) {
|
|
|
|
startTest(testVideo);
|
|
|
|
} else {
|
|
|
|
todo(false, "No playable video");
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|