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

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

mercurial