tor-browser

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

same-document-traversal-cross-document-traversal.html (4232B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Cross-document traversals during same-document traversals</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <!--
      8  Compare this to cross-document-traversal-cross-document-traversal.html. Since
      9  there are no network loads for the first traversal here, it does observably go
     10  through. So we end up with both traversals before observable in sequence.
     11 -->
     12 
     13 <body>
     14 <script type="module">
     15 import { createIframe, waitForLoad, waitForHashchange, delay } from "./resources/helpers.mjs";
     16 
     17 promise_test(async t => {
     18  const iframe = await createIframe(t);
     19 
     20  // Setup
     21  // Extra delay()s are necessary because if we navigate "inside" the load
     22  // handler (i.e. in a promise reaction for the load handler) then it will
     23  // be a replace navigation.
     24  iframe.contentWindow.location.search = "?1";
     25  await waitForLoad(iframe);
     26  await delay(t, 0);
     27  iframe.contentWindow.location.search = "?2";
     28  await waitForLoad(iframe);
     29  await delay(t, 0);
     30  iframe.contentWindow.location.hash = "#3";
     31  await waitForHashchange(iframe.contentWindow);
     32 
     33  iframe.contentWindow.history.back();
     34  assert_equals(iframe.contentWindow.location.search, "?2", "must not go back synchronously 1 (search)");
     35  assert_equals(iframe.contentWindow.location.hash, "#3", "must not go back synchronously 1 (hash)");
     36 
     37  iframe.contentWindow.history.back();
     38  assert_equals(iframe.contentWindow.location.search, "?2", "must not go back synchronously 1 (search)");
     39  assert_equals(iframe.contentWindow.location.hash, "#3", "must not go back synchronously 1 (hash)");
     40 
     41  await waitForHashchange(iframe.contentWindow);
     42  assert_equals(iframe.contentWindow.location.search, "?2", "first hashchange event must be going back (search)");
     43  assert_equals(iframe.contentWindow.location.hash, "", "first hashchange event must be going back (hash)");
     44 
     45  await waitForLoad(iframe);
     46  assert_equals(iframe.contentWindow.location.search, "?1", "first load event must be going back (search)");
     47  assert_equals(iframe.contentWindow.location.hash, "", "first load event must be going back (hash)");
     48 }, "traversals in the same (back) direction: queued up");
     49 
     50 promise_test(async t => {
     51  const iframe = await createIframe(t);
     52 
     53  // Setup
     54  // Extra delay()s are necessary because if we navigate "inside" the load
     55  // handler (i.e. in a promise reaction for the load handler) then it will
     56  // be a replace navigation.
     57  iframe.contentWindow.location.search = "?1";
     58  await waitForLoad(iframe);
     59  await delay(t, 0);
     60  iframe.contentWindow.location.hash = "#2";
     61  await waitForHashchange(iframe.contentWindow);
     62  iframe.contentWindow.location.search = "?3";
     63  await waitForLoad(iframe);
     64  await delay(t, 0);
     65  iframe.contentWindow.history.back();
     66  await waitForLoad(iframe);
     67  iframe.contentWindow.history.back();
     68  await waitForHashchange(iframe.contentWindow);
     69  assert_equals(iframe.contentWindow.location.search, "?1", "we made our way to ?1 for setup (search)");
     70  assert_equals(iframe.contentWindow.location.hash, "", "we made our way to ?1 for setup (search)");
     71 
     72  iframe.contentWindow.history.forward();
     73  assert_equals(iframe.contentWindow.location.search, "?1", "must not go forward synchronously 1 (search)");
     74  assert_equals(iframe.contentWindow.location.hash, "", "must not go forward synchronously 1 (hash)");
     75 
     76  iframe.contentWindow.history.forward();
     77  assert_equals(iframe.contentWindow.location.search, "?1", "must not go forward synchronously 2 (search)");
     78  assert_equals(iframe.contentWindow.location.hash, "", "must not go forward synchronously 2 (hash)");
     79 
     80  await waitForHashchange(iframe.contentWindow);
     81  assert_equals(iframe.contentWindow.location.search, "?1", "first hashchange event must be going forward (search)");
     82  assert_equals(iframe.contentWindow.location.hash, "#2", "first hashchange event must be going forward (hash)");
     83 
     84  await waitForLoad(iframe);
     85  assert_equals(iframe.contentWindow.location.search, "?3", "first load event must be going forward (search)");
     86  assert_equals(iframe.contentWindow.location.hash, "#2", "first load event must be going forward (hash)");
     87 }, "traversals in the same (forward) direction: queued up");
     88 </script>