test_same_url.html (1791B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 6 <script type="application/javascript" src="/tests/SimpleTest/SpecialPowers.js"></script> 7 <script type="application/javascript"> 8 // Since BFCache in parent requires no opener, use BroadcastChannel 9 // to communicate with file_same_url.html. 10 let bc = SpecialPowers.wrap(BroadcastChannel).unpartitionedTestingChannel("test_same_url"); 11 async function test() { 12 var promise; 13 let historyLength; 14 15 promise = waitForLoad(); 16 window.open("file_same_url.html", "_blank", "noopener=yes"); 17 historyLength = await promise; 18 is(historyLength, 1, "before same page navigation"); 19 20 promise = waitForLoad(); 21 bc.postMessage("linkClick"); 22 historyLength = await promise; 23 is(historyLength, 1, "after same page navigation"); 24 bc.postMessage("closeWin"); 25 26 SimpleTest.finish(); 27 } 28 29 async function waitForLoad() { 30 return new Promise(resolve => { 31 let listener = e => { 32 if (e.data.bodyOnLoad) { 33 bc.removeEventListener("message", listener); 34 setTimeout(() => resolve(e.data.bodyOnLoad), 0); 35 } 36 }; 37 bc.addEventListener("message", listener); 38 }); 39 } 40 </script> 41 </head> 42 43 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1745730">Bug 1745730</a> 44 <p id="display"></p> 45 <div id="content" style="display: none"> 46 </div> 47 <pre id="test"> 48 <script type="text/javascript"> 49 SimpleTest.waitForExplicitFinish(); 50 </script> 51 </pre> 52 <body onload="test()"> 53 </body> 54 </html>