tor-browser

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

navigate-multiple-history-pushState.html (1017B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script>
      5 async_test(t => {
      6  const expected = [
      7    "navigate #1",
      8    "navigateerror #1",
      9    "navigate #3",
     10    "navigateerror #3",
     11    "navigate #2",
     12    "navigatesuccess #2"
     13  ];
     14 
     15  const result = [];
     16  navigation.onnavigate = t.step_func(e => {
     17    result.push(`${e.type} ${new URL(e.destination.url).hash}`);
     18  });
     19 
     20  navigation.onnavigateerror = t.step_func(e => {
     21    result.push(`${e.type} ${new URL(navigation.currentEntry.url).hash}`);
     22 
     23    if (navigation.currentEntry.url.endsWith("#1")) {
     24      history.pushState(1, null, "#3");
     25    }
     26  });
     27 
     28  navigation.onnavigatesuccess = t.step_func_done(e => {
     29    result.push(`${e.type} ${new URL(navigation.currentEntry.url).hash}`);
     30    assert_array_equals(result, expected);
     31  });
     32 
     33  history.pushState(1, null, "#1");
     34  history.pushState(1, null, "#2");
     35 
     36 }, "history.pushState() called multiple times gives correct event order");
     37 </script>