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() {
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");
30 async function waitForLoad() {
31 return new Promise(resolve =
> {
33 if (e.data.bodyOnLoad) {
34 bc.removeEventListener(
"message", listener);
35 setTimeout(() =
> resolve(e.data.bodyOnLoad),
0);
38 bc.addEventListener(
"message", listener);
44 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1745730">Bug
1745730</a>
46 <div id=
"content" style=
"display: none">
49 <script type=
"text/javascript">
50 SimpleTest
.waitForExplicitFinish();
53 <body onload=
"test()">