chromium/third_party/blink/web_tests/fast/dom/zoom-scroll-page-test.html

<!DOCTYPE html>
<html>
<head>
    <style>
        body    { position: relative; height: 4000px; }
    </style>
    <script src="../../resources/js-test.js"></script>
    <script>
        description('This tests that window.scrollBy respects the page\'s zoom and scale factor when scrolling.');

        function zoomBy(zoomFactor)
        {
            while (zoomFactor > 0) {
                testRunner.zoomPageIn();
                zoomFactor--;
            }
            while (zoomFactor < 0) {
                testRunner.zoomPageOut();
                zoomFactor++;
            }
        }
        function testScroll(zoomFactor, scaleFactor) {
            debug('Testing at zoom ' + zoomFactor + ' and scale ' + scaleFactor);
            if (window.testRunner) {
                var y = 221;
                internals.setPageScaleFactor(scaleFactor);
                zoomBy(zoomFactor);
                window.scrollTo(10, 10);
                window.scrollBy(0, y);
                shouldBeCloseTo('window.pageYOffset', y+10, 4, false);
                zoomBy(-zoomFactor);
            }
            else
                testFailed('This test only operates as a web test.');
        }

        function runTests() {
            if (window.internals)
                internals.setPageScaleFactorLimits(0.5, 4);
            testScroll(-1,1.2);
            var zoomLevels = [-3, -2, -1, 0, 1, 3, 5];
            var scaleLevels = [0.75, 1, 1.2, 1.6];
            for (zoom in zoomLevels)
                for (scale in scaleLevels)
                    testScroll(zoomLevels[zoom], scaleLevels[scale]);

            wasPostTestScriptParsed = true;
            finishJSTest();
        }
    </script>
</head>

<body onload="runTests()">
    <div id="target"></div>
</body>
</html>