tor-browser

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

test_load_no_preload.html (1490B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test load on no preload element</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 <script class="testbody" type="text/javascript">
     11 
     12 // This test checks the scenario where the `canplaythrough` event is fired
     13 // after calling load() on an element that does not have a preload attribute.
     14 //
     15 // The spec does not define how much data should be loaded in this case —
     16 // the behavior is left to the user agent.
     17 //
     18 // This behavior can be reconsidered once bug 1969224 is resolved.
     19 
     20 add_task(async function testLoadOnNoPreloadElement() {
     21  for (let test of gSmallTests) {
     22    let tag;
     23    if (test.type.startsWith("audio/")) {
     24      tag = "audio";
     25    } else if (test.type.startsWith("video/")) {
     26      tag = "video";
     27    } else {
     28      tag = "unknown";
     29    }
     30    info(`run ${test.name}, type=${test.type}, tag=${tag}`);
     31    let ele = document.createElement(tag);
     32    if (typeof ele.canPlayType != "function" || !ele.canPlayType(test.type)) {
     33      // Skip unsupported files.
     34      continue;
     35    }
     36    ele.src = test.name;
     37    ele.load();
     38    info(`load an element without preload attribute should fire a canplaythrough`);
     39    await once(ele, "canplaythrough");
     40    ok(true, `${test.name} fired 'canplaythrough' event`);
     41    removeNodeAndSource(ele);
     42  }
     43 });
     44 
     45 </script>
     46 </body>
     47 </html>