tor-browser

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

forward-to-pruned-entry.html (1791B)


      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  // Wait for after the load event so that the navigation doesn't get converted
      9  // into a replace navigation.
     10  await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
     11  await navigation.navigate("#foo").finished;
     12  assert_equals(navigation.entries().length, start_length+1);
     13  await navigation.back().finished;
     14  assert_equals(navigation.currentEntry.index, start_index);
     15 
     16  // Traverse forward then immediately do a same-document push. This will
     17  // truncate the back forward list, and by the time the traverse commits, the
     18  // destination key will no longer be present in navigation.entries(). The
     19  // traverse should abort. Because the traverse aborts before the navigate
     20  // event fires, the navigateerror event should not fire.
     21  navigation.onnavigateerror = t.unreached_func("navigateerror should not fire");
     22  let forward_value = navigation.forward();
     23  await navigation.navigate("#clobber").finished;
     24  assert_equals(navigation.currentEntry.index, start_index+1);
     25  await promise_rejects_dom(t, "AbortError", forward_value.committed);
     26  await promise_rejects_dom(t, "AbortError", forward_value.finished);
     27 
     28  // This leaves navigation.entries() in a consistent state where traversing
     29  // back and forward still works.
     30  await navigation.back().finished;
     31  assert_equals(navigation.currentEntry.index, start_index);
     32  await navigation.forward().finished;
     33  assert_equals(navigation.currentEntry.index, start_index+1);
     34 }, "If forward pruning clobbers the target of a traverse, abort");
     35 </script>