tor-browser

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

intercept-reject.html (969B)


      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: async () => {
     21      await new Promise(r => t.step_timeout(r, 0));
     22      return Promise.reject(err);
     23    }});
     24  };
     25 
     26  location.href = "#1";
     27  assert_equals(location.hash, "#1");
     28 }, "event.intercept() should abort if the given promise rejects");
     29 </script>