tor-browser

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

navigation-back-cross-document-preventDefault.html (1343B)


      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 <script src="/common/get-host-info.sub.js"></script>
      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.
     10  let w = window.open("resources/opener-postMessage-onpageshow.html");
     11  await new Promise(resolve => window.onmessage = resolve);
     12  // Navigate to a url that will notify us when the navigation is complete.
     13  w.navigation.navigate("opener-postMessage-onpageshow.html?1");
     14 
     15  await new Promise(resolve => window.onmessage = resolve);
     16  assert_equals(w.navigation.entries().length, 2);
     17  assert_equals(w.navigation.currentEntry.index, 1);
     18  let navigate_called = false;
     19  w.navigation.onnavigate = t.step_func(e => {
     20    navigate_called = true;
     21    assert_false(e.destination.sameDocument);
     22    assert_false(e.cancelable);
     23    // Should do nothing.
     24    e.preventDefault();
     25  });
     26  w.navigation.back();
     27  await new Promise(resolve => window.onmessage = resolve);
     28  assert_equals(w.navigation.currentEntry.index, 0);
     29  assert_true(navigate_called);
     30 }, "navigation.back() cross-document cannot be cancelled with the navigate event");
     31 </script>