summaryrefslogtreecommitdiffstats
path: root/docshell/test/navigation/file_reload_nonbfcached_srcdoc.sjs
blob: e1ef75efa079ecade1a61df1bf0efba7608c2814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const createPage = function (msg) {
  return `
<html>
<script>
  onpageshow = function() {
    opener.postMessage(document.body.firstChild.contentDocument.body.textContent);
  }
</script>
<body><iframe srcdoc="${msg}"></iframe><body>
</html>
`;
};

function handleRequest(request, response) {
  response.setHeader("Cache-Control", "no-store");
  response.setHeader("Content-Type", "text/html");

  let currentState = getState("reload_nonbfcached_srcdoc");
  let srcdoc = "pageload:" + currentState;
  if (currentState != "second") {
    setState("reload_nonbfcached_srcdoc", "second");
  } else {
    setState("reload_nonbfcached_srcdoc", "");
  }

  response.write(createPage(srcdoc));
}