tor-browser

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

same-document-nav-same-document-nav.html (2094B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Same-document navigation after a same-document navigation</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <!--
      8  These tests are kind of silly since it's hard to imagine any other result:
      9  same-document navigations are always synchronous so of course two in a row
     10  will succeed.
     11 
     12  Nevertheless they're nice as a basis from which to write corresponding app
     13  history tests, where the consequences aren't as obvious.
     14 -->
     15 
     16 <body>
     17 <script type="module">
     18 import { createIframe } from "./resources/helpers.mjs";
     19 
     20 promise_test(async t => {
     21  const iframe = await createIframe(t);
     22 
     23  iframe.contentWindow.location.hash = "#1";
     24  assert_equals(iframe.contentWindow.location.hash, "#1");
     25 
     26  iframe.contentWindow.location.hash = "#2";
     27  assert_equals(iframe.contentWindow.location.hash, "#2");
     28 }, "fragment navigation then fragment navigation");
     29 
     30 promise_test(async t => {
     31  const iframe = await createIframe(t);
     32 
     33  iframe.contentWindow.history.pushState(null, "", "?1");
     34  assert_equals(iframe.contentWindow.location.search, "?1");
     35 
     36  iframe.contentWindow.history.pushState(null, "", "?2");
     37  assert_equals(iframe.contentWindow.location.search, "?2");
     38 }, "pushState() then pushState()");
     39 
     40 promise_test(async t => {
     41  const iframe = await createIframe(t);
     42 
     43  iframe.contentWindow.history.pushState(null, "", "?1");
     44  assert_equals(iframe.contentWindow.location.search, "?1");
     45 
     46  iframe.contentWindow.location.hash = "#2";
     47  assert_equals(iframe.contentWindow.location.search, "?1");
     48  assert_equals(iframe.contentWindow.location.hash, "#2");
     49 }, "pushState() then fragment navigation");
     50 
     51 promise_test(async t => {
     52  const iframe = await createIframe(t);
     53 
     54  iframe.contentWindow.location.hash = "#1";
     55  assert_equals(iframe.contentWindow.location.hash, "#1");
     56 
     57  iframe.contentWindow.history.pushState(null, "", "?2");
     58  assert_equals(iframe.contentWindow.location.search, "?2");
     59  assert_equals(iframe.contentWindow.location.hash, "");
     60 }, "fragment navigation then pushState()");
     61 </script>