tor-browser

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

evaluation-error-3.html (1411B)


      1 <!DOCTYPE html>
      2 <title>Handling of evaluation errors, 3</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        "Test that exceptions during evaluation lead to error events on " +
     16        "window, and that exceptions are remembered.\n");
     17    window.addEventListener("load", test_load.step_func_done(ev => {
     18      const exn = log[1];
     19      assert_array_equals(log,
     20          ["throw", exn, "load", exn, "load", exn, "load", exn, "load",
     21           exn, "load"]);
     22      assert_true(exn.foo);
     23    }));
     24 
     25    function logLoad() { log.push("load"); }
     26    function unreachable() { log.push("unexpected"); }
     27 </script>
     28 <script type="module" src="./throw.js" onerror="unreachable()"
     29    onload="logLoad()"></script>
     30 <script type="module" src="./throw.js" onerror="unreachable()"
     31    onload="logLoad()"></script>
     32 <script type="module" src="./throw-nested.js" onerror="unreachable()"
     33    onload="logLoad()"></script>
     34 <script type="module" src="./throw.js" onerror="unreachable()"
     35    onload="logLoad()"></script>
     36 <script type="module" src="./throw-nested.js" onerror="unreachable()"
     37    onload="logLoad()"></script>