tor-browser

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

test_duration_after_error.html (1349B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test playback of media files that should have errors</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7  <script type="text/javascript" src="manifest.js"></script>
      8 </head>
      9 <body>
     10 <pre id="test">
     11 <script class="testbody" type="text/javascript">
     12 
     13 var manager = new MediaTestManager;
     14 
     15 function checkDuration(name, e, test) {
     16  if (test.duration) {
     17    ok(Math.abs(e.duration - test.duration) < 0.1,
     18       name + " duration (" + e.duration + ") should be around " + test.duration);
     19  } else {
     20    ok(false, "Test doesn't include the duration field!")
     21  }
     22 }
     23 
     24 function startTest(test, token) {
     25  manager.started(token);
     26 
     27  let v = document.createElement('video');
     28  v._loadedMetadata = false;
     29  let name = test.name;
     30 
     31  v.onloadedmetadata = function() {
     32    v.onloadedmetadata = null;
     33    v._loadedMetadata = true;
     34    ok(v._loadedMetadata , name + " has loaded metadata.");
     35  }
     36 
     37  v.onerror = function() {
     38    v.onerror = null;
     39    ok(v._loadedMetadata , name + " should load metadata before getting error.");
     40    checkDuration(name, v, test);
     41    manager.finished(token);
     42  }
     43 
     44  v.src = name;
     45  document.body.appendChild(v);
     46  v.play();
     47 }
     48 
     49 manager.runTests(gDurationTests, startTest);
     50 
     51 </script>
     52 </pre>
     53 </body>
     54 </html>