tor-browser

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

test_clone_media_element.html (1631B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test: cloned media element should continue to play to the end even after the source of the original element is cleared</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 // tests must run in sequence otherwise concurrent running test will also
     14 // update media cache which will hide the fact media cache not updated
     15 // after changes in media cache streams.
     16 PARALLEL_TESTS = 1;
     17 
     18 function startTest(test, token) {
     19  manager.started(token);
     20  info("Trying to load " + token);
     21  var v = document.createElement('video');
     22  v.preload = "metadata";
     23  v.token = token;
     24  v.src = test.name;
     25 
     26  v.onloadedmetadata = function(evt) {
     27    info(evt.target.token + " metadata loaded.");
     28    evt.target.onloadedmetadata = null;
     29    var clone = evt.target.cloneNode(false);
     30    clone.token = evt.target.token;
     31    clone.play();
     32 
     33    clone.onloadstart = function(event) {
     34      info("cloned " + event.target.token + " start loading.");
     35      event.target.onloadstart = null;
     36      removeNodeAndSource(v);
     37    }
     38 
     39    clone.onended = function(event) {
     40      ok(true, "cloned " + event.target.token + " ended.");
     41      event.target.onended = null;
     42      removeNodeAndSource(event.target);
     43      manager.finished(event.target.token);
     44    }
     45  }
     46 }
     47 
     48 var manager = new MediaTestManager;
     49 manager.runTests(gSmallTests.concat(gPlayedTests), startTest);
     50 
     51 </script>
     52 </pre>
     53 </body>
     54 </html>