tor-browser

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

navigation-navigate-replace-intercept.html (1026B)


      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 promise_test(async t => {
      7  await new Promise(resolve => window.onload = resolve);
      8 
      9  let oncurrententrychange_called = false;
     10  let original_entry = i.contentWindow.navigation.currentEntry;
     11  i.contentWindow.navigation.oncurrententrychange = t.step_func(e => {
     12    oncurrententrychange_called = true;
     13    assert_equals(e.from, original_entry);
     14    assert_equals(e.from.index, -1);
     15    assert_equals(e.navigationType, "replace");
     16    assert_equals(i.contentWindow.navigation.currentEntry.index, 0);
     17  });
     18  i.contentWindow.navigation.onnavigate = e => e.intercept();
     19  let result = i.contentWindow.navigation.navigate("/common/blank.html?1", { history: "replace" });
     20  assert_true(oncurrententrychange_called);
     21  await result.committed;
     22 }, "currententrychange fires for navigation.navigate() with replace intercepted by intercept()");
     23 </script>