tor-browser

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

navigation-back-forward-same-doc.html (1897B)


      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(resolve => window.onload = () => t.step_timeout(resolve, 0));
     12  await navigation.navigate("#foo").committed;
     13  assert_equals(navigation.entries().length, start_length + 1);
     14 
     15  let oncurrententrychange_back_called = false;
     16  let back_committed = false;
     17  navigation.oncurrententrychange = t.step_func(e => {
     18    oncurrententrychange_back_called = true;
     19    assert_equals(e.from, navigation.entries()[start_index + 1]);
     20    assert_equals(e.navigationType, "traverse");
     21    assert_equals(navigation.currentEntry.index, start_index);
     22    assert_false(back_committed);
     23  });
     24  let back_result = navigation.back();
     25  assert_false(oncurrententrychange_back_called);
     26  await back_result.committed.then(() => back_committed = true);
     27  assert_true(oncurrententrychange_back_called);
     28 
     29  let oncurrententrychange_forward_called = false;
     30  let forward_committed = false;
     31  navigation.oncurrententrychange = t.step_func(e => {
     32    oncurrententrychange_forward_called = true;
     33    assert_equals(e.from, navigation.entries()[start_index]);
     34    assert_equals(e.navigationType, "traverse");
     35    assert_equals(navigation.currentEntry.index, start_index + 1);
     36    assert_false(forward_committed);
     37  });
     38  let forward_result = navigation.forward();
     39  assert_false(oncurrententrychange_forward_called);
     40  await forward_result.committed.then(() => forward_committed = true);
     41  assert_true(oncurrententrychange_forward_called);
     42 }, "currententrychange fires for same-document navigation.back() and navigation.forward()");
     43 </script>