tor-browser

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

same-document-traversal-cross-document-nav.html (1575B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Cross-document navigations during same-document traversals</title>
      4 <meta name="timeout" content="long">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <!--
      9  The spec says that navigations are ignored if there is an ongoing traversal.
     10 -->
     11 
     12 <body>
     13 <script type="module">
     14 import { createIframe, delay, waitForPotentialNetworkLoads } from "./resources/helpers.mjs";
     15 
     16 promise_test(async t => {
     17  const iframe = await createIframe(t);
     18 
     19  // Setup
     20  iframe.contentWindow.location.hash = "#1";
     21  await delay(t, 0);
     22  iframe.contentWindow.location.hash = "#2";
     23  await delay(t, 0);
     24 
     25  iframe.contentWindow.history.back();
     26 
     27  assert_equals(iframe.contentWindow.location.hash, "#2", "must not go back synchronously");
     28 
     29  iframe.contentWindow.location.search = "?1";
     30  assert_equals(iframe.contentWindow.location.search, "", "must not navigate synchronously (search)");
     31  assert_equals(iframe.contentWindow.location.hash, "#2", "must not navigate synchronously (hash)");
     32 
     33  // Eventually ends up on #1.
     34  await t.step_wait(() => iframe.contentWindow.location.hash === "#1", "traversal");
     35 
     36  // Never loads a different document.
     37  iframe.onload = t.unreached_func("load event");
     38  await waitForPotentialNetworkLoads(t);
     39  assert_equals(iframe.contentWindow.location.search, "", "must stay on #2 (search)");
     40  assert_equals(iframe.contentWindow.location.hash, "#2", "must stay on #2 (hash)");
     41 }, "same-document traversals are not canceled by cross-document navigations");
     42 </script>