tor-browser

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

intercept-handler-throws.html (872B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script>
      5 async_test(t => {
      6  const err = new TypeError("a message");
      7  let start_href = location.href;
      8 
      9  navigation.onnavigatesuccess = t.step_func_done(assert_unreached);
     10  navigation.onnavigateerror = t.step_func_done(e => {
     11    assert_equals(location.hash, "#1");
     12    assert_equals(e.constructor, ErrorEvent);
     13    assert_true(e.error === err);
     14    assert_true(e.message.includes("TypeError: a message"));
     15    assert_equals(e.filename, start_href);
     16    assert_greater_than(e.colno, 0);
     17    assert_greater_than(e.lineno, 0);
     18  });
     19  navigation.onnavigate = e => {
     20    e.intercept({ handler() { throw err; }});
     21  };
     22 
     23  location.href = "#1";
     24  assert_equals(location.hash, "#1");
     25 }, "event.intercept() should abort if the handler throws");
     26 </script>