tor-browser

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

navigation-traverseTo-same-document-preventDefault-multiple-windows.html (1520B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="../navigation-methods/return-value/resources/helpers.js"></script>
      5 <iframe id="i" src="/common/blank.html"></iframe>
      6 <script>
      7 promise_test(async t => {
      8  let start_length = navigation.entries().length;
      9  let start_index = navigation.currentEntry.index;
     10 
     11  // Wait for after the load event so that the navigation doesn't get converted
     12  // into a replace navigation.
     13  await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
     14  await navigation.navigate("#").finished;
     15  await i.contentWindow.navigation.navigate("#").finished;
     16  assert_equals(navigation.entries().length, start_length + 1);
     17  assert_equals(i.contentWindow.navigation.entries().length, 2);
     18  assert_equals(navigation.currentEntry.index, start_index + 1);
     19  assert_equals(i.contentWindow.navigation.currentEntry.index, 1);
     20 
     21  navigation.onnavigate = e => e.preventDefault();
     22  i.contentWindow.navigation.onnavigate = t.unreached_func("navigate event should not fire in the iframe, because the traversal was cancelled in the top window");
     23  await assertBothRejectDOM(t, navigation.traverseTo(navigation.entries()[start_index].key), "AbortError");
     24  assert_equals(navigation.currentEntry.index, start_index + 1);
     25  assert_equals(i.contentWindow.navigation.currentEntry.index, 1);
     26 }, "navigation.traverseTo() - if a top window cancels the traversal, any iframes should not fire navigate");
     27 </script>