<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="initial-scale=1.0">
    <style>
        body {
            margin: 0;
            height: 2000px;
        }
        
        .box {
            height: 100px;
            width: 100px;
            background-color: blue;
        }
        
        .outer {
            position: absolute;
            top: 0;
        }
        
        .box:hover {
            background-color: green;
        }
        
        .container {
            position: absolute;
            top: 50px;
            left: 50px;
            height: 300px;
            width: 300px;
            overflow: scroll;
            -webkit-overflow-scrolling: touch;
            border: 1px solid black;
            visibility: hidden;
            box-shadow: 0 0 10px black;
        }
        
        .content {
            height: 600px;
        }
    </style>
    <script src="../../../resources/js-test-pre.js"></script>
    <script src="../../../resources/ui-helper.js"></script>
    <script>
        window.jsTestIsAsync = true;

        var hitElement;
        var documentDidScroll;
        async function runTest()
        {
            hitElement = document.elementFromPoint(20, 20);
            shouldBeEqualToString("hitElement.id", "under-target");
            
            var scroller = document.getElementById('scroller');
            shouldBe("scroller.scrollTop", "0");

            await UIHelper.callFunctionAndWaitForScrollToFinish(async () => {
                await UIHelper.dragFromPointToPoint(60, 200, 60, 100, 0.25);
            });

            debug("swipe complete");
            shouldBe("scroller.scrollTop", "0");
            
            documentDidScroll = document.scrollingElement.scrollTop > 0;
            shouldBeTrue("documentDidScroll");
            finishJSTest();
        }
        window.addEventListener('load', runTest, false);
    </script>
</head>
<body>
<div class="outer box" id="under-target">
</div>

<div id="scroller" class="container" onscroll="debug('overflow scroll')">
    <div class="content">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        <div class="inner box" style="visibility: visible">
        </div>
    </div>
</div>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
