tor-browser

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

navigate-canceled.html (1309B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 
      5 <script type="module">
      6 import { Recorder } from "./resources/helpers.mjs";
      7 
      8 promise_test(async t => {
      9  // Wait for after the load event so that the navigation doesn't get converted
     10  // into a replace navigation.
     11  await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
     12 
     13  const recorder = new Recorder({
     14    finalExpectedEvent: "finished rejected"
     15  });
     16 
     17  recorder.setUpNavigationAPIListeners();
     18 
     19  navigation.addEventListener("navigate", t.step_func(e => {
     20    e.preventDefault();
     21  }));
     22 
     23  const result = navigation.navigate("/common/blank.html#1");
     24  recorder.setUpResultListeners(result);
     25 
     26  Promise.resolve().then(() => recorder.record("promise microtask"));
     27 
     28  await recorder.readyToAssert;
     29 
     30  recorder.assert([
     31    /* event name, location.hash value, navigation.transition properties */
     32    ["navigate", "", null],
     33    ["AbortSignal abort", "", null],
     34    ["navigateerror", "", null],
     35    ["committed rejected", "", null],
     36    ["finished rejected", "", null],
     37    ["promise microtask", "", null]
     38  ]);
     39 
     40  recorder.assertErrorsAreAbortErrors();
     41 }, "event and promise ordering for navigation.navigate() where the navigate event is canceled");
     42 </script>