tor-browser

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

script-html-js-polyglot.sub.html (1176B)


      1 <!DOCTYPE html>
      2 <!-- Test verifies that CORB won't block a polyglot script that is
      3     both a valid HTML document and also valid Javascript.
      4 -->
      5 <meta charset="utf-8">
      6 <script src=/resources/testharness.js></script>
      7 <script src=/resources/testharnessreport.js></script>
      8 <div id=log></div>
      9 <script>
     10 ["html-js-polyglot.js", "html-js-polyglot2.js"].forEach(polyglot_name => {
     11  async_test(function(t) {
     12    window[polyglot_name] = false;
     13    var script = document.createElement("script");
     14 
     15    script.onload = t.step_func_done(function(){
     16      // Verify that the script response wasn't blocked - that script
     17      // should have set window[polyglot_name] to true.
     18      assert_true(window[polyglot_name]);
     19    })
     20    addEventListener("error",function(e) {
     21      t.step(function() {
     22        assert_unreached("No errors are expected with or without CORB.");
     23        t.done();
     24      })
     25    });
     26 
     27    // www1 is cross-origin, so the HTTP response is CORB-eligible.
     28    script.src = "http://{{domains[www1]}}:{{ports[http][0]}}/fetch/corb/resources/" + polyglot_name;
     29    document.body.appendChild(script);
     30  }, "CORB cannot block polyglot HTML/JS: " + polyglot_name);
     31 });
     32 </script>