wpt / dom / events / scrolling / scrollend-event-fired-for-scroll-attr-change.html?include=root-scrollLeft-smooth

Open test on wpt.live | wpt.fyi

Runs: Chrome 160.0.8195.0 (wpt@1ab8957e4, 2026-12-01) | Firefox 163.0a1 (wpt@1ab8957e4, 2026-12-01) | Safari 257 preview (wpt@1ab8957e4, 2026-12-01) | Ladybird 1.0-6ebf3 (wpt@a812f468c, 2026-12-02) | Servo Servo 0.8 (wpt@75c11f957, 2026-12-01) | Blitz 713a982dc (wpt@705f393a6, 2026-12-01)

ChromeFirefoxSafariLadybirdServoBlitz
Total1/11/11/11/10/1NOT RUN
SubtestChromeFirefoxSafariLadybirdServoBlitz
Tests scrollend event for [scrollLeft] behavior:'smooth' on root.PASSPASSPASSPASSFAIL—

/dom/events/scrolling/scrollend-event-fired-for-scroll-attr-change.html

<!DOCTYPE HTML>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
<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="/common/subset-tests-by-key.js"></script>
<meta name="variant" content="?include=subframe-scrollTop-smooth"/>
<meta name="variant" content="?include=subframe-scrollLeft-smooth"/>
<meta name="variant" content="?include=root-scrollTop-smooth"/>
<meta name="variant" content="?include=root-scrollLeft-smooth"/>
<meta name="variant" content="?include=subframe-scrollTop-auto"/>
<meta name="variant" content="?include=subframe-scrollLeft-auto"/>
<meta name="variant" content="?include=root-scrollTop-auto"/>
<meta name="variant" content="?include=root-scrollLeft-auto"/>
<script src="scroll_support.js"></script>
<style>
html {
  height: 3000px;
  width: 3000px;
}
#targetDiv {
  width: 200px;
  height: 200px;
  overflow: scroll;
}

#innerDiv {
  width: 400px;
  height: 400px;
}
</style>

<body style="margin:0" onload=runTest()>
<div id="targetDiv">
  <div id="innerDiv">
  </div>
</div>
</body>
<script>
let invalid_scrollend_arrived = false;

function onInvalidScrollEnd(event) {
  invalid_scrollend_arrived = true;
}

let scroll_attr_change_variants = [
  {
    key: "subframe-scrollTop-smooth",
    target: targetDiv,
    behavior: "smooth",
    attribute: "scrollTop",
    title: "Tests scrollend event for [scrollTop] behavior:'smooth' on subframe."
  },
  {
    key: "subframe-scrollLeft-smooth",
    target: targetDiv,
    behavior: "smooth",
    attribute: "scrollLeft",
    title: "Tests scrollend event for [scrollLeft] behavior:'smooth' on subframe."
  },
  {
    key: "root-scrollTop-smooth",
    target: document.scrollingElement,
    behavior: "smooth",
    attribute: "scrollTop",
    title: "Tests scrollend event for [scrollTop] behavior:'smooth' on root."
  },
  {
    key: "root-scrollLeft-smooth",
    target: document.scrollingElement,
    behavior: "smooth",
    attribute: "scrollLeft",
    title: "Tests scrollend event for [scrollLeft] behavior:'smooth' on root."
  },
  {
    key: "subframe-scrollTop-auto",
    target: targetDiv,
    behavior: "auto",
    attribute: "scrollTop",
    title: "Tests scrollend event for [scrollTop] behavior:'auto' on subframe."
  },
  {
    key: "subframe-scrollLeft-auto",
    target: targetDiv,
    behavior: "auto",
    attribute: "scrollLeft",
    title: "Tests scrollend event for [scrollLeft] behavior:'auto' on subframe."
  },
  {
    key: "root-scrollTop-auto",
    target: document.scrollingElement,
    behavior: "auto",
    attribute: "scrollTop",
    title: "Tests scrollend event for [scrollTop] behavior:'auto' on root."
  },
  {
    key: "root-scrollLeft-auto",
    target: document.scrollingElement,
    behavior: "auto",
    attribute: "scrollLeft",
    title: "Tests scrollend event for [scrollLeft] behavior:'auto' on root."
  },
];

function runTest() {

  async function testScrollAttrChange(testInfo, t) {
    testInfo.target.style.scrollBehavior = testInfo.behavior;

    await waitForCompositorCommit();

    let scrollendPromise = null;
    const TIMEOUT = 2000;
    if (testInfo.target == document.scrollingElement) {
      targetDiv.addEventListener("scrollend", onInvalidScrollEnd);
      scrollendPromise = createScrollendPromiseForTarget(t, document, TIMEOUT, true);
    } else {
      document.addEventListener("scrollend", onInvalidScrollEnd);
      scrollendPromise = createScrollendPromiseForTarget(t, targetDiv, TIMEOUT, false);
    }

    testInfo.target[testInfo.attribute] = 200;

    await scrollendPromise;
    assert_false(invalid_scrollend_arrived, "Scrollend should not fire to target that has not scrolled");

    assert_equals(testInfo.target[testInfo.attribute], 200,
                  testInfo.target.tagName + "." + testInfo.attribute + " " + testInfo.behavior);
  }

  scroll_attr_change_variants.forEach((testInfo) => {
    subsetTestByKey(testInfo.key, promise_test,
                    async (t) => testScrollAttrChange(testInfo, t), testInfo.title);
  })
}
</script>