tor-browser

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

navigate-multiple-location.html (1006B)


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