tor-browser

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

precommitHandler-new-navigation-before-commit.html (994B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="../navigation-methods/return-value/resources/helpers.js"></script>
      5 <body>
      6 <script>
      7 promise_test(async t => {
      8  navigation.addEventListener("navigate", e => e.intercept({ precommitHandler: async () => {} }), { once: "true" });
      9 
     10  let navigateerror_called = false;
     11  navigation.onnavigateerror = t.step_func(() => {
     12    navigateerror_called = true;
     13    assert_equals(location.hash, "");
     14  });
     15 
     16  let promises_should_not_commit = navigation.navigate("#ShouldNotCommit");
     17  let promises_fulfilled = navigation.navigate("#1");
     18  await assertBothRejectDOM(t, promises_should_not_commit, "AbortError");
     19  await assertBothFulfill(t, promises_fulfilled, navigation.currentEntry);
     20 
     21  assert_equals(location.hash, "#1");
     22  assert_true(navigateerror_called);
     23 }, "Cancel a navigation with a precommitHandler before commit by starting a new navigation");
     24 </script>
     25 </body>