gecko/content/media/test/test_reset_src.html

87 lines
2.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=804875
-->
<head>
<title>Test for bug 804875</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="manifest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=804875">Mozilla Bug 804875</a>
<video style="border: 4px solid red" controls></video>
<canvas></canvas>
<pre id="test">
<script class="testbody" type="text/javascript">
function onLoadedMetadata_Audio(e) {
var t = e.target;
is(t.videoHeight, 0, "videoHeight should be zero when there is no video.");
is(t.videoWidth, 0, "videoWidth should be zero when there is no video.");
is(t.mozPaintedFrames, 0, "mozPaintedFrames should be zero when there is no video.");
is(t.mozFrameDelay, 0, "mozFrameDelay should be zero when there is no video.");
var c = document.getElementsByTagName("canvas")[0].getContext("2d");
try {
c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth);
} catch (e) {
ok(true, "Trying to draw to a canvas should throw, since we don't have a frame anymore");
SimpleTest.finish();
return;
}
ok(false, "We should not succeed to draw a video frame on the canvas.");
}
function onTimeUpdate_Video(e) {
var t = e.target;
if (t.currentTime < t.duration / 4) {
return;
}
t.removeEventListener("timeupdate", onTimeUpdate_Video);
ok(t.mozPaintedFrames > 0, "mozPaintedFrames should be positive, is " + t.mozPaintedFrames + ".");
ok(t.mozFrameDelay >= 0, "mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
if (v._firstTime) {
t.src = t.src;
v._firstTime = false;
} else {
var source = getPlayableAudio(gPlayTests);
if (!source) {
todo("No audio file available.")
SimpleTest.finish();
} else {
t.removeEventListener("loadedmetadata", onLoadedMetadata_Video);
t.addEventListener("loadedmetadata", onLoadedMetadata_Audio);
t.src = source.name;
}
}
}
function onLoadedMetadata_Video(e) {
var t = e.target;
ok(t.videoHeight != 0, "We should have a videoHeight.");
ok(t.videoWidth != 0, "We should have a videoWidth.");
t.addEventListener("timeupdate", onTimeUpdate_Video);
t.play();
}
var v = document.getElementsByTagName("video")[0];
v._firstTime = true;
var source = getPlayableVideo(gPlayTests);
if (!source) {
todo("No video file available.");
} else {
v.addEventListener("loadedmetadata", onLoadedMetadata_Video);
v.src = source.name;
SimpleTest.waitForExplicitFinish();
}
</script>
</pre>
</body>
</html>