chromium/content/test/data/before_unload_same_doc_nav.html

<!DOCTYPE html>
<meta charset="utf-8">
<!--
  On a mobile viewport we need to make sure the page does not stretch beyond the
  size of the viewport to avoid displaying a scroll bar.
-->
<meta name="viewport" content="width=device-width,minimum-scale=1">
<html>
  <body></body>
  <script>
    onbeforeunload = (event) => {
      history.pushState(null, '', `#foo`);
    };
  </script>
  <style>
    body {
      background-color:#0000FF;
      overflow: scroll;
    }
    #foo {
      position: relative;
      height: 100vh;
    }
  </style>
  <div id="foo"></div>
</html>