summaryrefslogtreecommitdiffstats
path: root/docshell/test/navigation/redirect_handlers.sjs
blob: c2b39e61c990308eb8ddda325384bcf1cd915ad4 (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
28
29
function handleRequest(request, response) {
  response.setHeader("Cache-Control", "no-cache", false);
  response.setHeader("Cache-Control", "no-store", false);

  let state = getState("sessionhistory_do_redirect");
  if (state != "doredirect") {
    response.setHeader("Content-Type", "text/html");
    const contents = `
      <script>
        window.onpageshow = function(event) {
          opener.pageshow();
        }
      </script>
      `;
    response.write(contents);

    // The next load should do a redirect.
    setState("sessionhistory_do_redirect", "doredirect");
  } else {
    setState("sessionhistory_do_redirect", "");

    response.setStatusLine("1.1", 302, "Found");
    response.setHeader(
      "Location",
      "file_session_history_on_redirect_2.html",
      false
    );
  }
}