summaryrefslogtreecommitdiffstats
path: root/docshell/test/navigation/file_scrollRestoration_bfcache_and_nobfcache.html
blob: fec51f821dc4baae063ac724cb31f73184802c21 (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
<html>
  <head>
    <script>
      // Ensure layout is flushed before doing anything with scrolling.
      function flushAndExecute(callback) {
        window.requestAnimationFrame(function() {
          setTimeout(callback);
        });
      }

      var bc = new BroadcastChannel("bfcached");
      bc.onmessage = (msgEvent) => {
        if (msgEvent.data == "loadNext") {
          flushAndExecute(() => {
            location.href = "file_scrollRestoration_bfcache_and_nobfcache_part2.html";
          });
        } else if (msgEvent.data == "forward") {
          flushAndExecute(() => {
            history.forward();
          });
        }
      };
      window.onpageshow = (event) => {
        bc.postMessage({command: "pageshow", persisted: event.persisted});
      };
    </script>
  </head>
  <body>
  </body>
</html>