content/media/test/test_reset_src.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_reset_src.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=804875
     1.8 +-->
     1.9 +
    1.10 +<head>
    1.11 +  <title>Test for bug 804875</title>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="text/javascript" src="manifest.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank"
    1.18 +href="https://bugzilla.mozilla.org/show_bug.cgi?id=804875">Mozilla Bug 804875</a>
    1.19 +
    1.20 +<video style="border: 4px solid red" controls></video>
    1.21 +<canvas></canvas>
    1.22 +
    1.23 +<pre id="test">
    1.24 +<script class="testbody" type="text/javascript">
    1.25 +
    1.26 +function onLoadedMetadata_Audio(e) {
    1.27 +  var t = e.target;
    1.28 +  is(t.videoHeight, 0, "videoHeight should be zero when there is no video.");
    1.29 +  is(t.videoWidth, 0, "videoWidth should be zero when there is no video.");
    1.30 +  is(t.mozPaintedFrames, 0, "mozPaintedFrames should be zero when there is no video.");
    1.31 +  is(t.mozFrameDelay, 0, "mozFrameDelay should be zero when there is no video.");
    1.32 +  var c = document.getElementsByTagName("canvas")[0].getContext("2d");
    1.33 +  try {
    1.34 +    c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth);
    1.35 +  } catch (e) {
    1.36 +    ok(true, "Trying to draw to a canvas should throw, since we don't have a frame anymore");
    1.37 +    SimpleTest.finish();
    1.38 +    return;
    1.39 +  }
    1.40 +  ok(false, "We should not succeed to draw a video frame on the canvas.");
    1.41 +}
    1.42 +
    1.43 +function onTimeUpdate_Video(e) {
    1.44 +  var t = e.target;
    1.45 +  if (t.currentTime < t.duration / 4) {
    1.46 +    return;
    1.47 +  }
    1.48 +  t.removeEventListener("timeupdate", onTimeUpdate_Video);
    1.49 +  ok(t.mozPaintedFrames > 0, "mozPaintedFrames should be positive, is " + t.mozPaintedFrames + ".");
    1.50 +  ok(t.mozFrameDelay >= 0, "mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
    1.51 +
    1.52 +  if (v._firstTime) {
    1.53 +    t.src = t.src;
    1.54 +    v._firstTime = false;
    1.55 +  } else {
    1.56 +    var source = getPlayableAudio(gPlayTests);
    1.57 +    if (!source) {
    1.58 +      todo("No audio file available.")
    1.59 +      SimpleTest.finish();
    1.60 +    } else {
    1.61 +      t.removeEventListener("loadedmetadata", onLoadedMetadata_Video);
    1.62 +      t.addEventListener("loadedmetadata", onLoadedMetadata_Audio);
    1.63 +      t.src = source.name;
    1.64 +    }
    1.65 +  }
    1.66 +}
    1.67 +
    1.68 +function onLoadedMetadata_Video(e) {
    1.69 +  var t = e.target;
    1.70 +  ok(t.videoHeight != 0, "We should have a videoHeight.");
    1.71 +  ok(t.videoWidth != 0, "We should have a videoWidth.");
    1.72 +  t.addEventListener("timeupdate", onTimeUpdate_Video);
    1.73 +  t.play();
    1.74 +}
    1.75 +
    1.76 +var v = document.getElementsByTagName("video")[0];
    1.77 +v._firstTime = true;
    1.78 +var source = getPlayableVideo(gPlayTests);
    1.79 +if (!source) {
    1.80 +  todo("No video file available.");
    1.81 +} else {
    1.82 +  v.addEventListener("loadedmetadata", onLoadedMetadata_Video);
    1.83 +  v.src = source.name;
    1.84 +  SimpleTest.waitForExplicitFinish();
    1.85 +}
    1.86 +</script>
    1.87 +</pre>
    1.88 +</body>
    1.89 +</html>

mercurial