tor-browser

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

test_mkv_playback.html (1366B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <title>MKV playback test</title>
      5    <link rel="stylesheet" href="/tests/SimpleTest/test.css">
      6    <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7    <script type="text/javascript" src="manifest.js"></script>
      8 </head>
      9 <body>
     10 <pre id="test">
     11 <script>
     12 /**
     13 * This test verifies supported codecs in MKV files play to the end.
     14 */
     15 add_task(async function test_supported_mkv_sources() {
     16  await SpecialPowers.pushPrefEnv({
     17    set: [["media.mkv.enabled", true]]
     18  });
     19  for (const test of gMKVtests) {
     20    let v = document.createElement("video");
     21    document.body.appendChild(v);
     22    v.src = test.name;
     23    v.preload = "auto";
     24    info(`Starting to play ${test.name}`);
     25 
     26    // Mime type check
     27    let canPlay = v.canPlayType(test.type);
     28    is(canPlay, "probably", `canPlayType(${canPlay}) should be 'probably' for ${test.type}`);
     29    let legacyType = test.type.replace(/^(audio|video)\//, "$1/x-");
     30    canPlay = v.canPlayType(legacyType);
     31    is(canPlay, "probably", `canPlayType(${canPlay}) should be 'probably' for ${legacyType}`);
     32 
     33    // Playback check
     34    let endPromise = once(v, "ended");
     35    ok(await v.play().then(_ => true, _ => false), "media started playing successfully");
     36    await endPromise;
     37    ok(true, `${test.name} played to the end`);
     38    removeNodeAndSource(v);
     39  }
     40 });
     41 </script>
     42 </pre>
     43 </body>
     44 </html>