content/media/test/test_reset_src.html

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=804875
     5 -->
     7 <head>
     8   <title>Test for bug 804875</title>
     9   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <script type="text/javascript" src="manifest.js"></script>
    11   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    12 </head>
    13 <body>
    14 <a target="_blank"
    15 href="https://bugzilla.mozilla.org/show_bug.cgi?id=804875">Mozilla Bug 804875</a>
    17 <video style="border: 4px solid red" controls></video>
    18 <canvas></canvas>
    20 <pre id="test">
    21 <script class="testbody" type="text/javascript">
    23 function onLoadedMetadata_Audio(e) {
    24   var t = e.target;
    25   is(t.videoHeight, 0, "videoHeight should be zero when there is no video.");
    26   is(t.videoWidth, 0, "videoWidth should be zero when there is no video.");
    27   is(t.mozPaintedFrames, 0, "mozPaintedFrames should be zero when there is no video.");
    28   is(t.mozFrameDelay, 0, "mozFrameDelay should be zero when there is no video.");
    29   var c = document.getElementsByTagName("canvas")[0].getContext("2d");
    30   try {
    31     c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth);
    32   } catch (e) {
    33     ok(true, "Trying to draw to a canvas should throw, since we don't have a frame anymore");
    34     SimpleTest.finish();
    35     return;
    36   }
    37   ok(false, "We should not succeed to draw a video frame on the canvas.");
    38 }
    40 function onTimeUpdate_Video(e) {
    41   var t = e.target;
    42   if (t.currentTime < t.duration / 4) {
    43     return;
    44   }
    45   t.removeEventListener("timeupdate", onTimeUpdate_Video);
    46   ok(t.mozPaintedFrames > 0, "mozPaintedFrames should be positive, is " + t.mozPaintedFrames + ".");
    47   ok(t.mozFrameDelay >= 0, "mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
    49   if (v._firstTime) {
    50     t.src = t.src;
    51     v._firstTime = false;
    52   } else {
    53     var source = getPlayableAudio(gPlayTests);
    54     if (!source) {
    55       todo("No audio file available.")
    56       SimpleTest.finish();
    57     } else {
    58       t.removeEventListener("loadedmetadata", onLoadedMetadata_Video);
    59       t.addEventListener("loadedmetadata", onLoadedMetadata_Audio);
    60       t.src = source.name;
    61     }
    62   }
    63 }
    65 function onLoadedMetadata_Video(e) {
    66   var t = e.target;
    67   ok(t.videoHeight != 0, "We should have a videoHeight.");
    68   ok(t.videoWidth != 0, "We should have a videoWidth.");
    69   t.addEventListener("timeupdate", onTimeUpdate_Video);
    70   t.play();
    71 }
    73 var v = document.getElementsByTagName("video")[0];
    74 v._firstTime = true;
    75 var source = getPlayableVideo(gPlayTests);
    76 if (!source) {
    77   todo("No video file available.");
    78 } else {
    79   v.addEventListener("loadedmetadata", onLoadedMetadata_Video);
    80   v.src = source.name;
    81   SimpleTest.waitForExplicitFinish();
    82 }
    83 </script>
    84 </pre>
    85 </body>
    86 </html>

mercurial