tor-browser

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

test_standalone.html (1446B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Media test: standalone video documents</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 <script class="testbody" type="text/javascript">
     10 
     11 // Test whether video can be played correctly in a video document
     12 add_task(async function testStandAloneVideoDocument() {
     13  for (let i=0; i<gSmallTests.length; ++i) {
     14    const test = gSmallTests[i];
     15 
     16    // We can't play WAV files in stand alone documents, so just don't
     17    // run the test on non-video content types.
     18    if (getMajorMimeType(test.type) != "video" ||
     19        !document.createElement("video").canPlayType(test.type)) {
     20      continue;
     21    }
     22 
     23    let f = document.createElement("iframe");
     24    f.src = test.name;
     25    document.body.appendChild(f);
     26 
     27    info(`waiting iframe loading ${test.name}`);
     28    await new Promise(r => f.onload = r);
     29 
     30    const v = f.contentDocument.body.firstChild;
     31    is(v.tagName.toLowerCase(), "video", "Is video element");
     32    const src = filename(v.currentSrc);
     33    is(src, test.name, `Name (${src}) should match (${test.name})`);
     34    is(v.controls, true, `Controls set (${src})`);
     35    is(v.autoplay, true, `Autoplay set (${src})`);
     36  }
     37 });
     38 
     39 // Helper function
     40 function filename(uri) {
     41  return uri.substr(uri.lastIndexOf("/")+1);
     42 }
     43 
     44 </script>
     45 </body>
     46 </html>