4 https://bugzilla.mozilla.org/show_bug.cgi?id=1364364
8 <title>Test for Bug
1364364</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <script type=
"application/javascript">
13 /** Test for Bug
1364364 */
15 async function test() {
16 SimpleTest.waitForExplicitFinish();
17 if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
18 // This test relies on the possibility to modify the bfcached document.
19 // The new implementation is more restricted and thus works only
20 // when the bfcached browsing context is the only top level one
21 // in the browsing context group.
22 ok(true,
"This test is for the old bfcache implementation only.");
26 testWin = window.open(
"file_bug1364364-1.html");
27 await waitForLoad(testWin);
28 testDoc = testWin.document;
30 // file_bug1364364-
1.html will load a few dynamic iframes and then navigate
31 // top browsing context to file_bug1364364-
2.html, which will postMessage
35 function waitForLoad(win) {
36 return new Promise(r =
> win.addEventListener(
"load", r, { once: true}));
39 window.addEventListener(
"message", async function(msg) {
40 if (msg.data ==
"navigation-done") {
41 is(testWin.history.length,
6,
"check history.length");
43 // Modify a document in bfcache should cause the cache being dropped tho
44 // RemoveFromBFCacheAsync.
45 testDoc.querySelector(
"#content").textContent =
"modified";
46 await new Promise(r =
> setTimeout(r,
0));
48 is(testWin.history.length,
2,
"check history.length after bfcache dropped");
56 <body onload=
"test();">
57 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1364364">Mozilla Bug
1364364</a>
59 <div id=
"content" style=
"display: none">