Skip to content

Truly independent web browser

1.3 KB
Raw Blame
<!doctype html>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
<link rel="help" href="https://html.spec.whatwg.org/#process-scroll-behavior">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<div style="height: 1000px; width: 200vw;"></div>
<div id="frag"></div>
<div style="height: 1000px; width: 200vw;"></div>
<div id="other"></div>
<div style="height: 2000px; width: 200vw;"></div>
<script>
promise_test(async t => {
  await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
  await navigation.navigate("#frag").finished;
  const frag_key = navigation.currentEntry.key;
  const scrollY_frag = window.scrollY;
  window.scrollBy(0, 10);

  await navigation.navigate("#other").finished;
  await navigation.traverseTo(frag_key).finished;
  window.scrollTo(0, scrollY_frag + 30);
  assert_equals(window.scrollY, scrollY_frag + 30);

  navigation.onnavigate = e => e.intercept({ scroll: "after-transition" });
  await navigation.reload().finished;
  assert_equals(window.scrollY, scrollY_frag,
    "should scroll to the fragment, ignoring any saved scroll position");
}, "scroll: after-transition on a reload of a traversed-to fragment entry scrolls to the fragment");
</script>
</body>