forward-triggers-hashchange.html (1650B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Navigating forward after replace() should still trigger hashchange</title> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#history-traversal"> 5 <link rel="author" href="mailto:d@domenic.me" title="Domenic Denicola"> 6 7 <!-- While writing ./replacement-enabled.html, a bug was discovered in Firefox where it does not 8 fire hashchange when using history.forward(), at least under certain conditions. So, this test 9 exercises that specifically. --> 10 11 <script src="/resources/testharness.js"></script> 12 <script src="/resources/testharnessreport.js"></script> 13 <script src="navigate-helpers.js"></script> 14 15 <body> 16 17 <script> 18 "use strict"; 19 let resolve, iframe; 20 promise_test(() => { 21 iframe = document.createElement("iframe"); 22 iframe.src = "/common/blank.html"; 23 iframe.addEventListener("load", runTest); 24 document.body.appendChild(iframe); 25 26 return new Promise(r => resolve = r); 27 }); 28 29 function runTest() { 30 iframe.removeEventListener("load", runTest); 31 const frameWindow = iframe.contentWindow; 32 33 resolve((async () => { 34 await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#apple"); 35 await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#banana"); 36 await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#cat"); 37 38 await navigateAndWaitForChange(frameWindow, w => w.history.back()); 39 await navigateAndWaitForChange(frameWindow, 40 w => w.location.replace("/common/blank.html#zebra")); 41 await navigateAndWaitForChange(frameWindow, w => w.history.forward()); 42 })()); 43 } 44 </script>