4 https://bugzilla.mozilla.org/show_bug.cgi?id=
7 <title>Test for Bug
1379762</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <body onload=
"runTest()">
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1379762">Mozilla Bug
1379762</a>
14 <div id=
"content" style=
"display: none">
18 <script type=
"application/javascript">
20 * - This page opens new window
21 * - new window sends 'init' msg
22 * - onload() in new window sends 'increment_loadCount' msg
23 * - onpageshow() in new window sends 'increment_testCount' msg
24 * - This page sends 'forward_back' msg
25 * - onpageshow() in new window 'increment_testCount'
26 * - This page sends 'finish_test' msg
27 * - onpageshow() in new window sends 'finished' msg
29 var testCount =
0; // Used by the test files.
32 var bc = new BroadcastChannel(
"bug1379762");
33 bc.onmessage = (messageEvent) =
> {
34 let message = messageEvent.data;
35 if (message ==
"init") {
36 is(testCount,
0,
"new window should only be loaded once; otherwise the loadCount variable makes no sense");
37 } else if (message ==
"increment_loadCount") {
39 is(loadCount,
1,
"Should only get one load")
40 } else if (message == 'increment_testCount') {
43 bc.postMessage(
"forward_back");
45 } else if (testCount ==
2) {
46 ok(goneBack,
"We had a chance to navigate backwards and forwards in the new window to test BFCache");
47 bc.postMessage(
"finish_test");
49 } else if (message ==
"finished") {
55 SimpleTest.waitForExplicitFinish();
58 // If Fission is disabled, the pref is no-op.
59 SpecialPowers.pushPrefEnv({set: [[
"fission.bfcacheInParent", true]]}, () =
> {
60 window.open(
"file_bug1379762-1.html",
"",
"width=360,height=480,noopener");