navigation-api-traverseto.tentative.html (1254B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Detect navigation.traverseTo()</title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 <script src="resources/soft-navigation-helper.js"></script> 11 </head> 12 <body> 13 <a id=link>Click me!</a> 14 <main id=main> 15 </main> 16 <script> 17 let key; 18 window.onload = async () => { 19 // Wait for after the load event so that the navigation doesn't get converted 20 // into a replace navigation. 21 await new Promise(r => step_timeout(r, 0)); 22 23 navigation.onnavigate = e => { 24 e.intercept(); 25 }; 26 // Push a couple of navigation entries, so that we'd have a navigation entry to traverse to. 27 await navigation.navigate("foobar.html").finished; 28 key = navigation.currentEntry.key; 29 await navigation.navigate("another.html").finished; 30 31 testSoftNavigation({ 32 testName: "`navigation.traverseTo()` properly works with SoftNavigationHeuristics", 33 pushState: async () =>{ 34 await navigation.traverseTo(key).committed; 35 }, 36 }); 37 }; 38 </script> 39 </body> 40 </html>