tor-browser

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

same-document-traversal-same-document-nav.html (2045B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Same-document navigations during same-document traversals</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <!--
      8  Per spec, same-document navigations ignore the "ongoing navigation" flag and
      9  just happen synchronously, then queue onto the session history traversal queue
     10  to update the source of truth. However, the traversal was queued first, so it
     11  will ignore that update when calculating its endpoint.
     12 -->
     13 
     14 <body>
     15 <script type="module">
     16 import { createIframe, delay } from "./resources/helpers.mjs";
     17 
     18 promise_test(async t => {
     19  const iframe = await createIframe(t);
     20 
     21  // Setup
     22  iframe.contentWindow.location.hash = "#1";
     23  await delay(t, 0);
     24  iframe.contentWindow.location.hash = "#2";
     25  await delay(t, 0);
     26 
     27  iframe.contentWindow.history.back();
     28 
     29  assert_equals(iframe.contentWindow.location.hash, "#2", "must not go back synchronously");
     30 
     31  iframe.contentWindow.location.hash = "#3";
     32  assert_equals(iframe.contentWindow.location.hash, "#3");
     33 
     34  // Eventually ends up on #1
     35  await t.step_wait(() => iframe.contentWindow.location.hash === "#1");
     36 }, "same-document traversals are not canceled by fragment navigations and calculate their endpoint based on the original placement");
     37 
     38 promise_test(async t => {
     39  const iframe = await createIframe(t);
     40 
     41  // Setup
     42  iframe.contentWindow.history.pushState(null, "", "/1");
     43  await delay(t, 0);
     44  iframe.contentWindow.history.pushState(null, "", "/2");
     45  await delay(t, 0);
     46 
     47  iframe.contentWindow.history.back();
     48 
     49  assert_equals(iframe.contentWindow.location.pathname, "/2", "must not go back synchronously");
     50 
     51  iframe.contentWindow.history.pushState(null, "", "/3");
     52  assert_equals(iframe.contentWindow.location.pathname, "/3");
     53 
     54  // Eventually ends up on /1
     55  await t.step_wait(() => iframe.contentWindow.location.pathname === "/1");
     56 }, "same-document traversals are not canceled by pushState() and calculate their endpoint based on the original placement");
     57 </script>