navigate-intercept-stop.html (1913B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <meta name="variant" content="?no-currententrychange"> 5 <meta name="variant" content="?currententrychange"> 6 7 <script type="module"> 8 import { Recorder, hasVariant } from "./resources/helpers.mjs"; 9 10 promise_test(async t => { 11 // Wait for after the load event so that the navigation doesn't get converted 12 // into a replace navigation. 13 await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); 14 15 const from = navigation.currentEntry; 16 17 const recorder = new Recorder({ 18 skipCurrentChange: !hasVariant("currententrychange"), 19 finalExpectedEvent: "transition.finished rejected" 20 }); 21 22 recorder.setUpNavigationAPIListeners(); 23 24 navigation.addEventListener("navigate", e => { 25 e.intercept({ handler() { recorder.record("handler run"); } }); 26 }); 27 28 const result = navigation.navigate("/common/blank.html#1"); 29 recorder.setUpResultListeners(result); 30 31 Promise.resolve().then(() => recorder.record("promise microtask")); 32 33 window.stop(); 34 35 await recorder.readyToAssert; 36 37 recorder.assert([ 38 /* event name, location.hash value, navigation.transition properties */ 39 ["navigate", "", null], 40 ["currententrychange", "#1", { from, navigationType: "push" }], 41 ["handler run", "#1", { from, navigationType: "push" }], 42 ["AbortSignal abort", "#1", { from, navigationType: "push" }], 43 ["navigateerror", "#1", { from, navigationType: "push" }], 44 ["committed fulfilled", "#1", null], 45 ["transition.committed fulfilled", "#1", null], 46 ["promise microtask", "#1", null], 47 ["finished rejected", "#1", null], 48 ["transition.finished rejected", "#1", null], 49 ]); 50 51 recorder.assertErrorsAreAbortErrors(); 52 }, "event and promise ordering for navigation.navigate() intercepted by intercept() but then stopped using window.stop()"); 53 </script>