testing/web-platform/tests/css/css-overscroll-behavior/overscroll-behavior-root.html
author Duncan McIntosh <dmcintosh@mozilla.com>
Wed, 09 Jul 2025 19:42:02 +0000 (6 hours ago)
changeset 795924 9ccc6a2267cbf69c621fec973bd28573c2a45a1f
parent 784560 c206bbf111f656a78365f53e4fd415a398335de7
permissions -rw-r--r--
Bug 1966586 - Reuse other browser windows when opening _blank links in Taskbar Tabs windows. r=nrishel This doesn't affect other tab additions, nor does it stop the tab bar from appearing altogether. The idea is that _if_ another tab is somehow made, the user should see it; but we should not create new tabs if we can avoid it. This also adds tests for opening URIs in popups and taskbar tabs to make it less likely that this breaks in future. Differential Revision: https://phabricator.services.mozilla.com/D253726
<!doctype html>
<meta charset="utf-8">
<title>overscroll-behavior in root works</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/css/css-scroll-snap/support/common.js"></script>
<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=954423">

<div style="height: 200vh"></div>

<iframe srcdoc="<style>:root { overscroll-behavior-y: contain }</style><div style='height: 200vh'></div>"></iframe>

<script>
promise_test(async function() {
  await new Promise(r => window.addEventListener("load", r, { once: true }));

  const iframe = document.querySelector("iframe");
  iframe.scrollIntoView();

  const bounds = iframe.getBoundingClientRect();

  const originalScrollPos = window.scrollY;

  assert_equals(typeof originalScrollPos, "number", "Scroll position should be a number");
  assert_not_equals(originalScrollPos, 0, "Should have scrolled to get the iframe into view");

  await new test_driver.Actions()
    .scroll(Math.round(bounds.left + bounds.width / 2),
            Math.round(bounds.top + bounds.height / 2), 0, -100)
    .send();

  // Await two animation frames to give a chance to scroll.
  await new Promise(resolve => requestAnimationFrame(resolve));
  await new Promise(resolve => requestAnimationFrame(resolve));

  assert_equals(window.scrollY, originalScrollPos, "overscroll-behavior should work on the root");
});
</script>