<!DOCTYPE html>
<html>
<head>
    <script>
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.waitUntilDone();
        }

        function test()
        {
            var dropTarget = document.getElementById("drop-target");
            dropTarget.addEventListener("dragleave", function() {
                dropTarget.style.display = "none";
            }, false);

            if (window.eventSender) {
                eventSender.beginDragWithFiles(["resources/abe.png"]);
                var x = dropTarget.offsetLeft + dropTarget.offsetWidth / 2;
                var y = dropTarget.offsetTop + dropTarget.offsetHeight / 2;
                eventSender.mouseMoveTo(x, y);
                eventSender.mouseMoveTo(0, 0);

                // The test harness wants us to call eventSender.mouseUp() before finishing,
                // but we need to not navigate when that happens, so add a drop handler that
                // prevents navigation.
                window.addEventListener("dragover", function() {
                    event.preventDefault();
                }, false);
                window.addEventListener("drop", function() {
                    event.preventDefault();
                }, false);
                eventSender.mouseUp();
            }

            if (window.testRunner)
                testRunner.notifyDone();
        }
    </script>
</head>
<body onload="test()">
    <p>This test passes if there is no crash when dragging a file over and then away from the file input element below.</p>
    <input type="file" id="drop-target">
</body>
</html>
