tor-browser

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

reload-no-args.html (2114B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <iframe id="i" src="/common/blank.html"></iframe>
      5 <script>
      6 async_test(t => {
      7  window.onload = t.step_func(() => {
      8    const navState = { key: "value" };
      9    i.contentWindow.navigation.navigate("#1", { state: navState }).committed.then(t.step_func(() => {
     10      // Make sure that state setting worked
     11      assert_equals(i.contentWindow.navigation.currentEntry.getState().key, "value");
     12      assert_not_equals(i.contentWindow.navigation.currentEntry.getState(), navState);
     13 
     14      let start_url = i.contentWindow.location.href;
     15      let start_key = i.contentWindow.navigation.currentEntry.key;
     16      let start_id = i.contentWindow.navigation.currentEntry.id;
     17      let start_state = i.contentWindow.navigation.currentEntry.getState();
     18      let onnavigate_called = false;
     19      let promise_settled = false;
     20      i.contentWindow.navigation.onnavigate = t.step_func(e => {
     21        onnavigate_called = true;
     22        assert_equals(e.info, undefined);
     23        assert_equals(e.navigationType, "reload");
     24        assert_equals(e.destination.getState().key, "value");
     25        assert_not_equals(e.destination.getState(), start_state);
     26      });
     27      i.contentWindow.navigation.reload().committed.finally(() => {
     28        promise_settled = true;
     29      });
     30      i.onload = t.step_func(() => {
     31        assert_true(onnavigate_called);
     32        assert_equals(i.contentWindow.location.href, start_url);
     33        assert_equals(i.contentWindow.navigation.currentEntry.key, start_key);
     34        assert_equals(i.contentWindow.navigation.currentEntry.id, start_id);
     35        assert_equals(i.contentWindow.navigation.currentEntry.getState().key, "value");
     36        assert_not_equals(i.contentWindow.navigation.currentEntry.getState(), start_state);
     37        assert_equals(i.contentWindow.navigation.entries().length, 2);
     38 
     39        t.step_timeout(t.step_func_done(() => {
     40          assert_equals(promise_settled, false);
     41        }), 0);
     42      });
     43    }));
     44  });
     45 }, "reload() variant with no state or info");
     46 </script>