chromium/third_party/blink/web_tests/synthetic_gestures/animated-wheel-tiny-delta.html

<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script src='../resources/gesture-util.js'></script>
<script src="../resources/percent-based-util.js"></script>

<style>
  body, html {
    margin: 0;
    height: 10000px;
  }
</style>

<script>
  // This test ensures that animated mouse wheel scrolls with tiny amounts are
  // accurately propagated in the renderer.

  async function tryScroll(distance, source, expectedScrollY) {
      const x = 400;
      const y = 300;
      const precise_deltas = false;

      const scrollYBefore = window.scrollY;

      await waitForCompositorCommit();

      await smoothScroll(distance,
                         x, y,
                         source,
                         'down',
                         SPEED_INSTANT,
                         precise_deltas);



      await waitFor(() => { return window.scrollY - scrollYBefore >= expectedScrollY; },
                    "Didn't scroll by expected amount: " + expectedScrollY);
      await waitForCompositorCommit();
  }

  window.onload = async () => {
    const source_type = GestureSourceType.MOUSE_INPUT;

    promise_test(async () => {
      const expectedScrollY =
              calculateExpectedScroll(document.scrollingElement, 0, 1).y;
      assert_equals(window.scrollY, 0);
      await tryScroll(1, source_type, expectedScrollY);
      assert_approx_equals(window.scrollY, expectedScrollY, 0.00001);
    }, 'Synthetic animated ' + GestureSourceType.ToString(source_type) +
       ' gestures accurately scroll delta (0, 1).');

    promise_test(async () => {
      const scrollYBefore = window.scrollY;
      const expectedScrollY =
              calculateExpectedScroll(document.scrollingElement, 0, 2).y;
      await tryScroll(2, source_type, expectedScrollY);
      assert_approx_equals(window.scrollY, scrollYBefore + expectedScrollY, 0.00001);
      window.scrollTo(0, 0);
    }, 'Synthetic animated ' + GestureSourceType.ToString(source_type) +
       ' gestures accurately scroll delta (0, 2).');
  }
</script>