tor-browser

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

choice-of-error-3.html (1397B)


      1 <!DOCTYPE html>
      2 <title>Choice of evaluation 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        "Evaluation errors are cached in intermediate module scripts");
     16    window.addEventListener("load", test_load.step_func_done(ev => {
     17      assert_equals(log.length, 5);
     18 
     19      // Evaluation errors, unlike parse/instantiation errors, are remembered
     20      // and cached in module scripts between the root and the script that
     21      // caused an evaluation error, and thus the same evaluation error
     22      // is reported for both <script> elements.
     23      assert_equals(log[0], "throw2");
     24      assert_true(log[1].bar);
     25      assert_equals(log[2], 1);
     26 
     27      assert_true(log[3].bar);
     28      assert_equals(log[4], 2);
     29 
     30      assert_equals(log[1], log[3], 'evaluation errors must be the same');
     31    }));
     32 
     33    function unreachable() { log.push("unexpected"); }
     34 </script>
     35 <script type="module" src="./choice-of-error-3a.js"
     36    onerror="unreachable()" onload="log.push(1)"></script>
     37 <script type="module" src="./choice-of-error-3b.js"
     38    onerror="unreachable()" onload="log.push(2)"></script>