tor-browser

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

test_script_loader_crossorigin_data_url.html (1314B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Test for handling of 'crossorigin' attribute on script with data: URL</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <div id="log"></div>
      7 <script>
      8  // We're going to mess with window.onerror.
      9  setup({ allow_uncaught_exception: true });
     10 </script>
     11 <!-- First check that data: scripts with @crossorigin run at all -->
     12 <script>
     13  var ran = false;
     14 </script>
     15 <script crossorigin src="data:application/javascript,ran = true"></script>
     16 <script>
     17 test(function() {
     18  assert_true(ran);
     19 }, "script@crossorigin with data: src should have run");
     20 </script>
     21 <!-- Then check that their syntax errors are not sanitized -->
     22 <script>
     23 var errorFired = false;
     24 ran = false;
     25 window.onerror = function(message, uri, line) {
     26  errorFired = true;
     27  test(function() {
     28    assert_equals(line, 3);
     29  }, "Should have a useful line number for exception in script@crossorigin with data: src");
     30 }
     31 </script>
     32 <script crossorigin src="data:application/javascript,var%20a;%0aran=true%0anoSuchFunctionHere()"></script>
     33 <script>
     34  test(function() {
     35    assert_true(ran, "Script with error should have run");
     36    assert_true(errorFired, "Script with error should have fired onerror");
     37  }, "Should run and correctly fire onerror");
     38 </script>