tor-browser

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

intercept-navigation-back.html (881B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script>
      5 async_test(t => {
      6  let start_length = navigation.entries().length;
      7  let start_index = navigation.currentEntry.index;
      8 
      9  // Wait for after the load event so that the navigation doesn't get converted
     10  // into a replace navigation.
     11  window.onload = () => t.step_timeout(() => {
     12    navigation.navigate("#foo").committed.then(() => {
     13      assert_true(navigation.canGoBack);
     14      navigation.onnavigate = t.step_func(e => e.intercept());
     15      navigation.back().committed.then(t.step_func_done(() => {
     16        assert_equals(navigation.entries().length, start_length + 1);
     17        assert_equals(navigation.currentEntry, navigation.entries()[start_index]);
     18      }));
     19    });
     20  }, 0);
     21 }, "event.intercept() can intercept navigation.back()");
     22 </script>