summaryrefslogtreecommitdiffstats
path: root/docshell/test/navigation/file_meta_refresh.html
blob: 274084b03b84ca59b527c1dee704c3683ff75dbb (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
30
31
32
33
34
35
36
37
38
39
<html>
  <head>
  </head>
  <body>
    <script>
      function addMetaRefresh() {
        document.head.innerHTML = "<meta http-equiv='refresh' content='5; url=" +
          location.href.replace("?initial", "?refresh") + "'>";
      }

      onpageshow = function() {
        let bc = new BroadcastChannel("test_meta_refresh");
        bc.onmessage = function(event) {
          if (event.data == "loadnext") {
            bc.close();
            addMetaRefresh();
            location.href = location.href.replace("?initial", "?nextpage");
          } else if (event.data == "back") {
            bc.close();
            history.back();
          } else if (event.data == "ensuremetarefresh") {
            bc.close();
            // This test is designed to work with and without bfcache, but
            // if bfcache is enabled, meta refresh should be suspended/resumed.
            if (document.head.firstChild.localName != "meta") {
              addMetaRefresh();
            }
          } else if (event.data == "close") {
            bc.postMessage("closed");
            bc.close();
            window.close();
          }
        };

        bc.postMessage({ load: location.search.substr(1) });
      }
    </script>
  </body>
</html>