tor-browser

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

media-src-7_3_2.sub.html (2324B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4    <title>Video track src attribute must match src list - negative test</title>
      5    <meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline'; media-src 'self';">
      6    <script src='/resources/testharness.js'></script>
      7    <script src='/resources/testharnessreport.js'></script>
      8 </head>
      9 <body>
     10    <h1>Video track src attribute must match src list - negative test</h1>
     11    <div id='log'></div>
     12 
     13  <script>
     14    var source_test =
     15        async_test("Disallowed track element onerror handler fires.");
     16 
     17    var trackURL = location.protocol + "//{{domains[www]}}:{{ports[http][0]}}/media/foo.vtt";
     18 
     19    var t_spv = async_test("Test that securitypolicyviolation events are fired");
     20    var test_count = 1;
     21    window.addEventListener("securitypolicyviolation", t_spv.step_func(function(e) {
     22          assert_equals(e.violatedDirective, "media-src");
     23          assert_equals(e.blockedURI, trackURL);
     24          if (--test_count <= 0) {
     25              t_spv.done();
     26          }
     27      }));
     28 
     29 
     30    function media_loaded(t) {
     31     t.step( function () {
     32          assert_unreached("Disllowed track source loaded.");
     33      });
     34      t.done();
     35    }
     36 
     37    function media_error_handler(t) {
     38      t.done();
     39    }
     40  </script>
     41 
     42    <video id="videoObject" width="320" height="240" controls
     43           onerror="media_error_handler(source_test)"
     44           crossorigin>
     45        <source id="audioSourceObject"
     46                type="video/webm"
     47                src="/media/A4.webm">
     48        <track default
     49               id="trackObject"
     50               kind="subtitles"
     51               srclang="en"
     52               label="English"
     53               onerror="media_error_handler(source_test)"
     54               onload="media_loaded(source_test)"
     55               onloadeddata="media_loaded(source_test)">
     56    </video>
     57    <script>
     58        document.getElementById("trackObject").src = trackURL;
     59        source_test.step(function() {
     60            source_test.set_status(source_test.FAIL);
     61        });
     62 
     63        setTimeout(function() {
     64          if(source_test.phase != source_test.phases.COMPLETE) {
     65            source_test.step( function () { assert_unreached("Onerror event never fired for track element."); });
     66            source_test.done();
     67          }
     68        }, 2 * 1000);
     69    </script>
     70 
     71 </body>
     72 </html>