tor-browser

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

navigate-history-push-same-url-cross-document.html (1289B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="resources/helpers.js"></script>
      5 <iframe id="i" src="/common/blank.html"></iframe>
      6 <script>
      7 promise_test(async t => {
      8  // Wait for after the load event so that the navigation doesn't get converted
      9  // into a replace navigation due to onload not having completed.
     10  await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
     11  assert_equals(i.contentWindow.navigation.entries().length, 1);
     12 
     13  i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called");
     14  i.contentWindow.navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called");
     15 
     16  let navigateEventType;
     17  i.contentWindow.navigation.onnavigate = e => navigateEventType = e.navigationType;
     18 
     19  i.contentWindow.navigation.navigate(i.contentWindow.location, { history: "push" });
     20  await new Promise(resolve => i.onload = resolve);
     21  assert_equals(navigateEventType, "push");
     22  assert_equals(i.contentWindow.navigation.entries().length, 2);
     23  assert_equals(i.contentWindow.navigation.currentEntry.index, 1);
     24 }, "navigate() to the current URL with history: 'push' and allow it to go cross document");
     25 </script>