<html>
    <head>
        <script src="../../resources/ui-helper.js"></script>
        <script>
            if (window.testRunner) {
                testRunner.dumpAsText();
                testRunner.waitUntilDone();
            }

            async function dispatchScrollEvents()
            {
                if (window.eventSender && window.testRunner) {
                    testRunner.waitUntilDone();
                    var scrollCount = 0;
                    document.getElementById('dv').addEventListener(
                        'scroll',
                        function(event) {
                            this.removeChild(this.firstChild);
                            scrollCount++;
                            if (scrollCount == 1)
                                eventSender.mouseScrollBy(-1, -1);
                            else
                                testRunner.notifyDone();
                        },
                        false);

                    await UIHelper.statelessMouseWheelScrollAt(100, 100, 0, -1);
                }
            }
        </script>
    </head>
    <body onload="setTimeout('dispatchScrollEvents();', 1);">
        This test verifies that children can be removed by their parent element's onscroll event handler.  The test succeeds if this is the only text remaining after the two scroll events are dispatched.  The test fails if the inner div remains in the output or if WebKit crashes.<br><br>
        <div id="dv" style="overflow: auto; width: 200px; height: 200px; whitespace: nowrap;">
        <div style="width:300px; height:300px">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>
        </div>
    </body>
</html>
