tor-browser

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

transition-to.html (1479B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script>
      5 promise_test(async (t) => {
      6  // Wait for after the load event so that the navigation doesn't get converted
      7  // into a replace navigation.
      8  await new Promise(r => window.onload = () => t.step_timeout(r, 0));
      9  const precommit = Promise.withResolvers();
     10  const handler = Promise.withResolvers();
     11  const handler_done = Promise.withResolvers();
     12  const commit = Promise.withResolvers();
     13  navigation.addEventListener("navigate", e => {
     14    e.intercept({
     15        async precommitHandler() {
     16            precommit.resolve(e);
     17            await commit.promise;
     18        },
     19        async handler() {
     20            handler.resolve();
     21            await handler_done.promise;
     22        }
     23    });
     24  });
     25 
     26  assert_equals(navigation.transition, null);
     27  navigation.navigate("?next");
     28  const navigate_event = await precommit.promise;
     29  const old_entry = navigation.currentEntry;
     30  assert_equals(navigation.transition.from, old_entry);
     31  assert_equals(navigation.transition.to, navigate_event.destination);
     32  commit.resolve();
     33  await handler.promise;
     34  assert_equals(navigation.transition.from, old_entry);
     35  assert_equals(navigation.transition.to, navigate_event.destination);
     36  assert_equals(navigation.transition.to.url, navigation.currentEntry.url);
     37  handler_done.resolve();
     38 }, "navigation.transition.to matches the navigate event's destination");
     39 </script>