<!DOCTYPE html> <!-- webkit-test-runner [ ScrollAnimatorEnabled=true ] -->
<html>
    <head>
    <style>
        body {
            height: 10000px;
            background-image: repeating-linear-gradient(white, silver 200px);
        }

        .fixed {
            position: fixed;
            top: 0;
        }
    </style>
    <script src="../../../resources/js-test-pre.js"></script>
    <script src="../../../resources/ui-helper.js"></script>
    <script>
        var jsTestIsAsync = true;

        async function scrollTest()
        {
            await UIHelper.renderingUpdate();

            await UIHelper.startMonitoringWheelEvents();
            eventSender.mouseMoveTo(100, 100);

            // normal scroll
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "began", "none");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "changed", "none");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "changed", "none");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "changed", "none");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, "ended", "none");
            await UIHelper.renderingUpdate();

            // momentum scroll
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "none", "begin");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "none", "continue");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "none", "continue");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "none", "continue");
            await UIHelper.renderingUpdate();

            startY = window.scrollY;

            await UIHelper.rawKeyDown("upArrow");
            await UIHelper.renderingUpdate();

            await UIHelper.delayFor(100);

            await UIHelper.rawKeyUp("upArrow");
            await UIHelper.renderingUpdate();

            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "none", "continue");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "none", "continue");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "none", "continue");
            await UIHelper.renderingUpdate();
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, "none", "end");
            await UIHelper.renderingUpdate();

            endY = window.scrollY;
            shouldBeTrue('endY >= startY');

            finishJSTest();
        }

        window.addEventListener('load', scrollTest, false);
    </script>
    </head>
    <body>
    <div class="fixed">fixed</div>
    <script src="../../../resources/js-test-post.js"></script>
    </body>
</html>