tor-browser

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

same-url.html (1565B)


      1 <title>Test same-URL navigation and its effects on history</title>
      2 <script src=/resources/testharness.js></script>
      3 <script src=/resources/testharnessreport.js></script>
      4 <div id=log></div>
      5 <iframe src=resources/a.html></iframe>
      6 <script>
      7 async_test((t) => {
      8  let state = "begin"
      9  let initialLength = history.length
     10 
     11  self[0].frameElement.onload = t.step_func(() => {
     12    if(state === "b first") {
     13      assert_equals(history.length, initialLength + 1, state)
     14 
     15      state = "c first"
     16      navigateFrameAfterDelay(t, "resources/c.html")
     17    } else if (state === "c first") {
     18      assert_equals(history.length, initialLength + 2, state)
     19 
     20      state = "a second"
     21      history.back(2)
     22    } else if (state === "a second") {
     23      assert_equals(history.length, initialLength + 2, state)
     24 
     25      state = "a third"
     26      navigateFrameAfterDelay(t, "resources/a.html")
     27    } else if (state === "a third") {
     28      assert_equals(history.length, initialLength + 2, state)
     29      t.done()
     30    }
     31  })
     32  onload = t.step_func(() => {
     33    assert_equals(state, "begin")
     34 
     35    state = "b first"
     36 
     37    navigateFrameAfterDelay(t, "resources/b.html")
     38  })
     39 })
     40 
     41 function navigateFrameAfterDelay(t, url) {
     42  // Delay to avoid triggering the "replace" behavior which occurs if
     43  // the page isn't yet completely loaded, which only occurs after the
     44  // load event handlers have finished:
     45  // https://html.spec.whatwg.org/#location-object-navigate
     46  // https://html.spec.whatwg.org/#the-end:completely-finish-loading
     47  t.step_timeout(() => {
     48    self[0].location = url
     49  }, 0)
     50 }
     51 </script>