tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_reset_src.html (2991B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=804875
      5 -->
      6 
      7 <head>
      8  <title>Test for bug 804875</title>
      9  <script 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>
     16 
     17 <canvas></canvas>
     18 
     19 <pre id="test">
     20 <script class="testbody" type="text/javascript">
     21 
     22 var manager = new MediaTestManager;
     23 
     24 function finish(v) {
     25  removeNodeAndSource(v);
     26  manager.finished(v.token);
     27 }
     28 
     29 function onLoadedData_Audio(e) {
     30  var t = e.target;
     31  is(t.videoHeight, 0, t.name + ": videoHeight should be zero when there is no video.");
     32  is(t.videoWidth, 0, t.name + ": videoWidth should be zero when there is no video.");
     33  is(t.mozPaintedFrames, 0, t.name + ": mozPaintedFrames should be zero when there is no video.");
     34  is(t.mozFrameDelay, 0, t.name + ": mozFrameDelay should be zero when there is no video.");
     35  var c = document.getElementsByTagName("canvas")[0].getContext("2d");
     36  var threw = false;
     37  try {
     38    c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth);
     39  } catch (ex) {
     40    threw = true;
     41  }
     42  ok(!threw, t.name + ": Even though we don't succeed to draw a video frame on the canvas, we shouldn't throw.");
     43  finish(t);
     44 }
     45 
     46 function onTimeUpdate_Video(e) {
     47  var t = e.target;
     48  if (t.currentTime < t.duration / 4) {
     49    return;
     50  }
     51  t.removeEventListener("timeupdate", onTimeUpdate_Video);
     52  // There's no guarantee that a video frame composite notification reaches
     53  // us before timeupdate fires.
     54  ok(t.mozPaintedFrames >= 0, t.name + ": mozPaintedFrames should be positive or zero, is " + t.mozPaintedFrames + ".");
     55  ok(t.mozFrameDelay >= 0, t.name + ": mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
     56 
     57  if (t._firstTime) {
     58    // eslint-disable-next-line no-self-assign
     59    t.src = t.src;
     60    t._firstTime = false;
     61  } else {
     62    var source = getPlayableAudio(gPlayTests);
     63    if (!source) {
     64      todo("No audio file available.")
     65      finish(t);
     66    } else {
     67      t.removeEventListener("loadeddata", onLoadedData_Video);
     68      t.addEventListener("loadeddata", onLoadedData_Audio);
     69      t.src = source.name;
     70    }
     71  }
     72 }
     73 
     74 function onLoadedData_Video(e) {
     75  var t = e.target;
     76  isnot(t.videoHeight, 0, t.name + ": We should have a videoHeight.");
     77  isnot(t.videoWidth, 0, t.name + ": We should have a videoWidth.");
     78  t.addEventListener("timeupdate", onTimeUpdate_Video);
     79  t.play();
     80 }
     81 
     82 function startTest(test, token) {
     83  var v = document.createElement('video');
     84  document.body.appendChild(v);
     85  v._firstTime = true;
     86  v.addEventListener("loadeddata", onLoadedData_Video);
     87  v.src = test.name;
     88  v.token = token;
     89  v.name = test.name;
     90  v.play();
     91  manager.started(token);
     92 }
     93 
     94 manager.runTests(getPlayableVideos(gSmallTests.concat(gSeekTests)), startTest);
     95 </script>
     96 </pre>
     97 </body>
     98 </html>