no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / docshell / test / mochitest / test_bug1773192.html
blobd4c42dc1a7787f62605149d876ee40fbd96ca353
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Test referrer with going back</title>
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
8 <script>
9 SimpleTest.waitForExplicitFinish();
11 // file_bug1773192_1.html will send a message with some data on pageshow.
12 function waitForData(bc) {
13 return new Promise(resolve => {
14 bc.addEventListener(
15 "message",
16 ({ data }) => {
17 resolve(data);
19 { once: true }
21 });
23 async function runTest() {
24 let bc = new BroadcastChannel("bug1743353");
26 let getData = waitForData(bc);
28 window.open("file_bug1773192_1.html", "", "noreferrer");
30 await getData.then(({ referrer }) => {
31 is(referrer, "", "Referrer should be empty at first.");
32 });
34 getData = waitForData(bc);
36 // When file_bug1773192_1.html receives this message it will navigate to
37 // file_bug1773192_2.html. file_bug1773192_2.html removes itself from
38 // history with replaceState and submits a form with the POST method to
39 // file_bug1773192_3.sjs. file_bug1773192_3.sjs goes back in history.
40 // We should end up back at file_bug1773192_1.html, which will send a
41 // message with some data on pageshow.
42 bc.postMessage("next");
44 await getData.then(({ location, referrer }) => {
45 let firstURL = new URL("file_bug1773192_1.html", location).toString();
46 is(location, firstURL, "Location should be the first page again.");
47 is(referrer, firstURL, "Referrer should also be the first page.");
48 });
50 bc.postMessage("close");
52 SimpleTest.finish();
54 </script>
55 </head>
56 <body onload="runTest();">
57 <p id="display"></p>
58 <div id="content" style="display: none"></div>
59 <pre id="test"></pre>
60 </body>
61 </html>