tor-browser

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

activation-traverse-then-clobber.html (2636B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <iframe id="i" src="/common/blank.html"></iframe>
      5 <script>
      6 promise_test(async t => {
      7  // Wait for after the load event so that the navigation doesn't get converted
      8  // into a replace navigation.
      9  await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
     10 
     11  i.contentWindow.navigation.navigate("/common/blank.html?a");
     12  await new Promise(resolve => i.onload = () => t.step_timeout(resolve, 0));
     13 
     14  assert_equals(i.contentWindow.navigation.entries().length, 2);
     15 
     16  i.contentWindow.navigation.back();
     17  await new Promise(resolve => i.onload = () => t.step_timeout(resolve, 0));
     18 
     19  // activation.entry is the current entry. activation.from is the entry the
     20  // traverse came from.
     21  assert_equals(i.contentWindow.navigation.entries().length, 2);
     22  assert_equals(i.contentWindow.navigation.activation.entry, i.contentWindow.navigation.currentEntry);
     23  assert_equals(i.contentWindow.navigation.activation.entry.index, 0);
     24  assert_equals(i.contentWindow.navigation.activation.from,
     25                i.contentWindow.navigation.entries()[1]);
     26  assert_equals(i.contentWindow.navigation.activation.navigationType, "traverse");
     27 
     28  let from_key_before_push = i.contentWindow.navigation.activation.from.key;
     29  let from_id_before_push = i.contentWindow.navigation.activation.from.id;
     30  let from_url_before_push = i.contentWindow.navigation.activation.from.url;
     31  await i.contentWindow.navigation.navigate("/common/blank.html#fragment").finished;
     32 
     33  // pushing same document will not change activation.entry, but it will cut
     34  // activation.from out of the entries array. Its parameters should not change
     35  //except for its index, which becomes -1.
     36  assert_equals(i.contentWindow.navigation.entries().length, 2);
     37  assert_equals(i.contentWindow.navigation.activation.entry, i.contentWindow.navigation.entries()[0]);
     38  assert_equals(i.contentWindow.navigation.activation.entry.index, 0);
     39  assert_not_equals(i.contentWindow.navigation.activation.from,
     40                    i.contentWindow.navigation.entries()[1]);
     41  assert_equals(i.contentWindow.navigation.activation.from.key, from_key_before_push);
     42  assert_equals(i.contentWindow.navigation.activation.from.id, from_id_before_push);
     43  assert_equals(i.contentWindow.navigation.activation.from.url, from_url_before_push);
     44  assert_equals(i.contentWindow.navigation.activation.from.index, -1);
     45  assert_equals(i.contentWindow.navigation.activation.navigationType, "traverse");
     46 }, "navigation.activation - traverse, then push same-document");
     47 </script>