tor-browser

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

navigate-history-traversal-during-onnavigate.html (2428B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src=/resources/testdriver.js></script>
      5 <script src=/resources/testdriver-vendor.js></script>
      6 <script>
      7 promise_test(async t => {
      8  let w = window.open("/common/blank.html");
      9  await new Promise(resolve => w.onload = resolve);
     10 
     11  await test_driver.bless("navigate", async function() {
     12    w.navigation.navigate(new URL('resources/navigate-history-traversal-during-onnavigate-helper.html?count=1', location.href).href);
     13  });
     14 
     15  await new Promise(resolve => onmessage = resolve);
     16  w.postMessage("start", "*");
     17  await new Promise(resolve => onmessage = resolve);
     18 
     19  await new Promise(resolve => w.onhashchange = resolve);
     20 
     21  w.onpopstate = () => assert_unreached("No more popstate events");
     22 
     23  assert_equals(w.navigation.currentEntry.index, 1);
     24  assert_equals(new URL(w.navigation.currentEntry.url).pathname, "/navigation-api/navigate-event/resources/navigate-history-traversal-during-onnavigate-helper.html");
     25  assert_equals(new URL(w.navigation.currentEntry.url).hash, "");
     26  w.close();
     27 }, "Test that navigation.back() silently aborts during onnavigate");
     28 
     29 promise_test(async t => {
     30  let w = window.open("/common/blank.html");
     31  await new Promise(resolve => w.onload = resolve);
     32 
     33  await test_driver.bless("navigate", async function() {
     34    w.navigation.navigate(new URL('resources/navigate-history-traversal-during-onnavigate-helper.html?count=3', location.href).href);
     35  });
     36 
     37  await new Promise(resolve => onmessage = resolve);
     38  w.postMessage("start", "*");
     39  await new Promise(resolve => onmessage = resolve);
     40 
     41  await new Promise(resolve => w.onhashchange = resolve);
     42  assert_equals(w.navigation.currentEntry.index, 3);
     43  assert_equals(new URL(w.navigation.currentEntry.url).pathname, "/navigation-api/navigate-event/resources/navigate-history-traversal-during-onnavigate-helper.html");
     44  assert_equals(new URL(w.navigation.currentEntry.url).hash, "#1");
     45 
     46  await new Promise(resolve => w.onhashchange = resolve);
     47  assert_equals(w.navigation.currentEntry.index, 1);
     48  assert_equals(new URL(w.navigation.currentEntry.url).pathname, "/navigation-api/navigate-event/resources/navigate-history-traversal-during-onnavigate-helper.html");
     49  assert_equals(new URL(w.navigation.currentEntry.url).hash, "");
     50  w.close();
     51 }, "Test that navigation.traverseTo() works during onnavigate");
     52 </script>