<!DOCTYPE html>
<html>
<head>
    <title>The page should scroll back to the top</title>
    <style>
        body {
            height: 2000px;
            background-image: repeating-linear-gradient(white, silver 200px);
        }
        
        .box {
            width: 100px;
            height: 100px;
            background-color: green;
        }
    </style>
    <script src="../../resources/ui-helper.js"></script>
    <script>
		if (window.testRunner)
            testRunner.waitUntilDone();

		async function doTest()
        {
            document.scrollingElement.scrollTop = 20;
            document.scrollingElement.scrollTop = 0;

            await UIHelper.startMonitoringWheelEvents();
            eventSender.mouseMoveTo(20, 20);
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, "began", "none");
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, "changed", "none");
            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, "ended", "none");
            
            await UIHelper.waitForScrollCompletion();

            document.scrollingElement.scrollTop = 0;
            testRunner.notifyDone();
        }

        window.addEventListener('load', doTest, false);
    </script>
</head>
<body>
    <div class="box"></div>
</body>
</html>
