tor-browser

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

navigate-destination-after-detach.html (1406B)


      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  let destination_key = i.contentWindow.navigation.currentEntry.key;
     12  let destination_id = i.contentWindow.navigation.currentEntry.id;
     13  let destination_index = i.contentWindow.navigation.currentEntry.index;
     14  await i.contentWindow.navigation.navigate("#1").finished;
     15 
     16  let back_destination;
     17  i.contentWindow.navigation.onnavigate = e => back_destination = e.destination;
     18  await i.contentWindow.navigation.back().finished;
     19 
     20  // Before detach, key/id/index are valid.
     21  assert_equals(back_destination.key, destination_key);
     22  assert_equals(back_destination.id, destination_id);
     23  assert_equals(back_destination.index, destination_index);
     24 
     25  i.remove();
     26 
     27  // After detach, key/id/index are invalid, but the url is still valid.
     28  assert_equals(back_destination.key, "");
     29  assert_equals(back_destination.id, "");
     30  assert_equals(new URL(back_destination.url).pathname, "/common/blank.html");
     31  assert_equals(back_destination.index, -1);
     32 }, "navigate event destination after iframe detach");
     33 </script>