5 <title>Test form restoration for no-store pages
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css"/>
9 function waitForMessage(aBroadcastChannel
) {
10 return new Promise(resolve
=> {
11 aBroadcastChannel
.addEventListener("message", ({ data
}) => {
17 function postMessageAndWait(aBroadcastChannel
, aMsg
) {
18 let promise
= waitForMessage(aBroadcastChannel
);
19 aBroadcastChannel
.postMessage(aMsg
);
23 async
function startTest(aTestFun
) {
24 let bc
= new BroadcastChannel("form_restoration");
26 let promise
= waitForMessage(bc
);
27 window
.open("file_form_restoration_no_store.html", "", "noopener");
33 // close broadcast channel and window
34 bc
.postMessage("close");
38 /* Test for bug1740517 */
39 add_task(async
function history_back() {
40 await
startTest(async (aBroadcastChannel
) => {
42 aBroadcastChannel
.postMessage("enter_data");
45 await
postMessageAndWait(aBroadcastChannel
, "navigate");
48 let { persisted
, formData
} = await
postMessageAndWait(aBroadcastChannel
, "back");
51 ok(!persisted
, "Page with a no-store header shouldn't be bfcached.");
52 is(formData
, "initial", "We shouldn't restore form data when going back to a page with a no-store header.");
56 /* Test for bug1752250 */
57 add_task(async
function location_reload() {
58 await
startTest(async (aBroadcastChannel
) => {
60 aBroadcastChannel
.postMessage("enter_data");
63 let { persisted
, formData
} = await
postMessageAndWait(aBroadcastChannel
, "reload");
66 ok(!persisted
, "Page with a no-store header shouldn't be bfcached.");
67 is(formData
, "initial", "We shouldn't restore form data when reload a page with a no-store header.");
74 <div id=
"content" style=
"display: none"></div>