tor-browser

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

muted-errors.sub.html (4545B)


      1 <!DOCTYPE html>
      2 <title>Muted Errors</title>
      3 
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 // https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error
      8 // If script's muted errors is true, then set message to "Script error.",
      9 // urlString to the empty string, line and col to 0, and errorValue to null.
     10    setup({allow_uncaught_exception: true});
     11 
     12    window.log = [];
     13    window.addEventListener("error", ev => log.push(ev));
     14 
     15    function check(shouldBeMuted) {
     16      assert_equals(log.length, 1);
     17      var ev = log[0];
     18      log = [];
     19      if (shouldBeMuted) {
     20        assert_equals(ev.message, "Script error.");
     21        assert_equals(ev.error, null, 'error');
     22        assert_equals(ev.filename, "", 'filename');
     23        assert_equals(ev.lineno, 0, 'lineno');
     24        assert_equals(ev.colno, 0, 'colno');
     25      } else {
     26        assert_not_equals(ev.message, "Script error.");
     27        assert_not_equals(ev.error, null);
     28      }
     29    }
     30 
     31    var test1 = async_test("Errors for same-origin script shouldn't be muted");
     32    var check1 = test1.step_func_done(() => check(false));
     33 
     34    var test2 = async_test("Errors for cross-origin script should be muted");
     35    var check2 = test2.step_func_done(() => check(true));
     36 
     37    var test3 = async_test("Errors for cross-origin script should be muted " +
     38                           "even if the script is once loaded as same-origin");
     39    function step3() {
     40      var script = document.createElement('script');
     41      script.setAttribute('src', "//{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/cacheable-script-throw.py?iframe");
     42      script.onerror = test3.unreached_func();
     43      script.onload = test3.step_func_done(() => check(true));
     44      document.body.appendChild(script);
     45    }
     46 
     47    var test4 = async_test("Errors for same-origin scripts redirected to a " +
     48                           "cross-origin url and redirected back to " +
     49                           "same-origin should be muted");
     50    var check4 = test4.step_func_done(() => check(true));
     51 
     52    var test5 = async_test("Errors for cross-origin scripts redirected to a " +
     53                           "same-origin url should be muted");
     54    var check5 = test5.step_func_done(() => check(true));
     55 
     56    const test6 = async_test("Non-synthetic errors for same-origin scripts redirected to a " +
     57                             "cross-origin URL and redirected back to same-origin should be " +
     58                             "muted");
     59    const check6 = test6.step_func_done(() => check(true));
     60 
     61    const test7 = async_test("Syntax error for same-origin script redirected to a " +
     62                             "cross-origin URL and redirected back to same-origin should be " +
     63                             "muted");
     64    const check7 = test7.step_func_done(() => check(true));
     65 
     66    function unreachable() { log.push("unexpected"); }
     67 </script>
     68 <script src="cacheable-script-throw.py" onerror="test1.unreached_func()()" onload="check1()"></script>
     69 <script src="//{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/cacheable-script-throw.py"
     70    onerror="test2.unreached_func()()" onload="check2()"></script>
     71 <iframe src="//{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/muted-errors-iframe.html"
     72    onerror="test3.unreached_func()()" onload="step3()"></iframe>
     73 <script src="/fetch/api/resources/redirect.py?location=
     74 //{{domains[www2]}}:{{ports[http][0]}}/fetch/api/resources/redirect.py?location=
     75 //{{host}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/cacheable-script-throw.py?same-cross-same"
     76 onerror="test4.unreached_func()()" onload="check4()"></script>
     77 <script src="//{{domains[www2]}}:{{ports[http][0]}}/fetch/api/resources/redirect.py?location=
     78 //{{host}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/cacheable-script-throw.py?cross-same"
     79 onerror="test5.unreached_func()()" onload="check5()"></script>
     80 <script src="//{{domains[www2]}}:{{ports[http][0]}}/fetch/api/resources/redirect.py?location=
     81 //{{host}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/resources/throw.js"
     82 onerror="test6.unreached_func()()" onload="check6()"></script>
     83 <script src="//{{domains[www2]}}:{{ports[http][0]}}/fetch/api/resources/redirect.py?location=
     84 //{{host}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/resources/syntax-error.js"
     85 onerror="test7.unreached_func()()" onload="check7()"></script>