<!DOCTYPE html> <!-- webkit-test-runner [ AsyncOverflowScrollingEnabled=true ] -->
<html>
<head>
    <meta name="viewport" content="initial-scale=1">
    <script src="../../../../resources/ui-helper.js"></script>
    <script src="../../../../resources/js-test-pre.js"></script>
    <style>
        body {
            margin: 0;
        }
    </style>
</head>
<body>
    <div id="eventTarget" style="overflow: scroll; height: 200px">
        <div style="height: 3000px"></div>
    </div>
    <p id="description"></p>
    <div id="console">
    </div>
    <script>
        description("Test scrolling on a block without -webkit-overflow-scrolling.");
        window.jsTestIsAsync = true;

        async function runTest()
        {
            let eventTarget = document.getElementById("eventTarget");

            function touchEventHandler(event) {
                if (event.touches.length)
                    debug("Received" + (event.cancelable ? " cancelable" : "") + " event " + event.type + " at " + event.touches[0].clientX + ", " + event.touches[0].clientY);
                else
                    debug("Received" + (event.cancelable ? " cancelable" : "") + " event " + event.type);
            }
            eventTarget.addEventListener('touchstart', touchEventHandler, { 'passive': true });
            eventTarget.addEventListener('touchmove', touchEventHandler, { 'passive': true });
            eventTarget.addEventListener('touchend', touchEventHandler, { 'passive': true });
            eventTarget.addEventListener('touchcancel', touchEventHandler, { 'passive': true });

            shouldBe("window.scrollX", "0");
            shouldBe("window.scrollY", "0");
            shouldBe("document.documentElement.scrollTop", "0");
            shouldBe("document.documentElement.scrollLeft", "0");
            shouldBe("document.getElementById('eventTarget').scrollTop", "0");
            shouldBe("document.getElementById('eventTarget').scrollLeft", "0");

            await UIHelper.callFunctionAndWaitForTargetScrollToFinish(eventTarget, async () => {
                await UIHelper.dragFromPointToPoint(50, 150, 50, 50, 0.15);
            });

            shouldBe("window.scrollX", "0");
            shouldBe("window.scrollY", "0");
            shouldBe("document.documentElement.scrollTop", "0");
            shouldBe("document.documentElement.scrollLeft", "0");
            shouldBeTrue("document.getElementById('eventTarget').scrollTop > 0");
            shouldBe("document.getElementById('eventTarget').scrollLeft", "0");
            finishJSTest();
        }

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