tor-browser

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

reload-no-popstate.html (1719B)


      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, hasVariant } 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 from = navigation.currentEntry;
     14 
     15  const recorder = new Recorder({
     16    finalExpectedEvent: "transition.finished fulfilled"
     17  });
     18 
     19  recorder.setUpNavigationAPIListeners();
     20  addEventListener("popstate", e => {
     21    recorder.record("popstate");
     22  });
     23  navigation.addEventListener("navigate", e => {
     24    e.intercept({ handler() { recorder.record("handler run"); } });
     25  });
     26 
     27  const result = navigation.reload();
     28  recorder.setUpResultListeners(result);
     29 
     30  Promise.resolve().then(() => recorder.record("promise microtask"));
     31 
     32  await recorder.readyToAssert;
     33 
     34  recorder.assert([
     35    /* event name, location.hash value, navigation.transition properties */
     36    ["navigate", "", null],
     37    ["currententrychange", "", { from, navigationType: "reload" }],
     38    ["handler run", "", { from, navigationType: "reload" }],
     39    ["committed fulfilled", "", { from, navigationType: "reload" }],
     40    ["transition.committed fulfilled", "", { from, navigationType: "reload" }],
     41    ["promise microtask", "", { from, navigationType: "reload" }],
     42    ["navigatesuccess", "", { from, navigationType: "reload" }],
     43    ["finished fulfilled", "", null],
     44    ["transition.finished fulfilled", "", null],
     45  ]);
     46 }, "event and promise ordering for navigation.reload() intercepted by intercept()");
     47 </script>