chromium/third_party/blink/web_tests/fast/scrolling/scrolling-apis-subpixel.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>

<style>
.spacer {
  height: 1000px;
  width: 1000px;
}
#scroller {
  height: 100px;
  width: 100px;
  overflow: scroll;
}

</style>
<div id=scroller>
    <div class=spacer></div>
</div>
<div class=spacer></div>

<script>
// FIXME: Make this smaller. crbug.com/414283.
var floatPrecision = 0.01;

function testScroll(scrollOffset, expectedScrollOffset) {
  // Scrolling DIV with scrollTop/scrollLeft
  scroller.scrollTop = scrollOffset;
  scroller.scrollLeft = scrollOffset;
  assert_approx_equals(scroller.scrollTop, expectedScrollOffset, floatPrecision);
  assert_approx_equals(scroller.scrollLeft, expectedScrollOffset, floatPrecision);

  //Scrolling the document with window.scroll
  window.scroll(0,0);
  scrollOffset++;
  expectedScrollOffset++;
  window.scroll(scrollOffset, scrollOffset);
  assert_approx_equals(window.scrollY, expectedScrollOffset, floatPrecision);
  assert_approx_equals(window.scrollX, expectedScrollOffset, floatPrecision);

  // Scrolling the document with window.scrollTo
  window.scroll(0,0);
  window.scrollTo(scrollOffset, scrollOffset);
  assert_approx_equals(window.pageYOffset, expectedScrollOffset, floatPrecision);
  assert_approx_equals(window.pageXOffset, expectedScrollOffset, floatPrecision);

  // Scrolling the document with window.scrollBy
  window.scroll(1,1);
  window.scrollBy(scrollOffset - 1, scrollOffset - 1);
  assert_approx_equals(window.scrollY, expectedScrollOffset, floatPrecision);
  assert_approx_equals(window.scrollX, expectedScrollOffset, floatPrecision);
}

test( () => {
  const setOffset = 4.2;
  let expectedOffset = 4;

  testScroll(setOffset, expectedOffset);
}, "Set fractional scroll offset without zoom");

test( () => {
  testRunner.setPageZoomFactor(2);

  // Zooming provides additional granularity, regardless of the runtimeFlag
  // being enabled or not.
  const setOffset = 4.5;
  const expectedOffset = 4.5;
  testScroll(setOffset, expectedOffset);
}, "Set fractional scroll offset when zoomed");

test( () => {
  testRunner.setPageZoomFactor(2);

  // Zooming provides additional granularity but we try to set a value beyond the 0.5 increment.
  const setOffset = 4.6;
  let expectedOffset = 4.5;

  testScroll(setOffset, expectedOffset);
}, "Set fractional scroll offset to higher granularity when zoomed.");

</script>