tor-browser

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

choice-of-error-2.html (1336B)


      1 <!DOCTYPE html>
      2 <title>Choice of instantiation errors</title>
      3 
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7    setup({allow_uncaught_exception: true});
      8 
      9    window.log = [];
     10 
     11    window.addEventListener("error", ev => log.push(ev.error));
     12    window.addEventListener("unhandledrejection", unreachable);
     13 
     14    const test_load = async_test(
     15        "Instantiation errors in different files should be reported " +
     16        "depending on different roots");
     17    window.addEventListener("load", test_load.step_func_done(ev => {
     18      assert_equals(log.length, 4);
     19 
     20      // Two different instantiation errors from different module scripts
     21      // should be reported for each <script> element.
     22      assert_equals(log[0].constructor, SyntaxError);
     23      assert_equals(log[1], 1);
     24 
     25      assert_equals(log[2].constructor, SyntaxError);
     26      assert_equals(log[3], 2);
     27 
     28      assert_not_equals(log[0], log[2],
     29          'two different instantiation errors should be reported');
     30    }));
     31 
     32    function unreachable() { log.push("unexpected"); }
     33 </script>
     34 <script type="module" src="./choice-of-error-2a.js"
     35    onerror="unreachable()" onload="log.push(1)"></script>
     36 <script type="module" src="./choice-of-error-2b.js"
     37    onerror="unreachable()" onload="log.push(2)"></script>