tor-browser

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

intercept-and-navigate.html (1290B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script>
      5 promise_test(async 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  await new Promise(r => window.onload = () => t.step_timeout(r, 0));
     12  await navigation.navigate("#1").finished;
     13 
     14  navigation.onnavigate = e => e.intercept();
     15  navigation.oncurrententrychange = e => {
     16    if (e.navigationType == "traverse") {
     17      assert_equals(location.hash, "");
     18      assert_equals(navigation.currentEntry.index, start_index);
     19      assert_equals(navigation.entries().length, start_length + 1);
     20      navigation.navigate("#2");
     21    }
     22  };
     23  let back_result = navigation.back();
     24  await back_result.committed;
     25  assert_equals(location.hash, "#2");
     26  await promise_rejects_dom(t, "AbortError", back_result.finished);
     27  assert_equals(navigation.currentEntry.index, start_index + 1);
     28  assert_equals(navigation.entries().length, start_length + 1);
     29 }, "Using intercept() then navigate() in the ensuing currententrychange should abort the finished promise (but not the committed promise)");
     30 </script>