chromium/third_party/blink/web_tests/fast/dom/viewport/viewport-scrolling-element-inert.html

<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
</style>
<h1>Viewport: scrollingElement scroll properties inert</h1>
<h4>
    Test Description: This test checks that when the scroll properties are used
    on the scrollingElement, they delegate to the layout viewport only.
</h4>
<script>
    addEventListener("load", function() {
        if (!window.internals)
          return;

        // Zoom into the page, innerWidth and innerHeight shouldn't be affected.
        internals.setPageScaleFactor(2);
        internals.setVisualViewportOffset(0, 0);

        test(function() {
              // Try scrollTo(). Since the page has no overflow, the only
              // scroll possible is by panning the visual viewport. However,
              // scrollingElement.scrollTo should apply only to the layout
              // viewport, so make sure the visual viewport isn't affected.
              document.scrollingElement.scrollTo(1000, 1000);
              assert_equals(window.visualViewport.offsetLeft, 0);
              assert_equals(window.visualViewport.offsetTop, 0);
            }, "visualViewport not affected by scrollingElement.scrollTo");

        test(function() {
              // Try the same this for scrollBy.
              document.scrollingElement.scrollBy(1000, 1000);
              assert_equals(window.visualViewport.offsetLeft, 0);
              assert_equals(window.visualViewport.offsetTop, 0);
            }, "visualViewport not affected by scrollingElement.scrollBy");

        test(function() {
              // And finally, scroll(). (which is an alias for scrollTo).
              document.scrollingElement.scroll(1000, 1000);
              assert_equals(window.visualViewport.offsetLeft, 0);
              assert_equals(window.visualViewport.offsetTop, 0);
            }, "visualViewport not affected by scrollingElement.scroll");

        test(function() {
              // Ensure that setting scrollLeft and scrollTop doesn't affect
              // the visual viewport.
              document.scrollingElement.scrollLeft = 100;
              document.scrollingElement.scrollTop = 100;
              assert_equals(window.visualViewport.offsetLeft, 0);
              assert_equals(window.visualViewport.offsetTop, 0);

              // Ensure scrollLeft and scrollTop don't report visual viewport
              // offset.
              internals.setVisualViewportOffset(200, 200);
              assert_equals(document.scrollingElement.scrollLeft, 0);
              assert_equals(document.scrollingElement.scrollTop, 0);
            }, "scrollLeft and scrollTop are layout-viewport relative");
    });
</script>