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