<!DOCTYPE html>
<html>
<body>
<p id="description">
This tests pressing a mouse button down inside a dragstart event.<br>
This happens when a user sets a breakpoint of a dragstart event handler in Inspector,
and clicks somewhere on the page while the script is paused at the breakpoint. WebKit should not crash.
</p>
<div id="container"><span id="target" draggable="true" ondragstart="onDragStart()">drag me</span></div>
<script>

if (!window.testRunner || !window.eventSender)
    document.body.innerHTML = 'This test requires eventSender';
else {
    testRunner.dumpAsText();

    var target = document.getElementById('target');
    var called = false;

    function onDragStart() {
        called = true;
        eventSender.mouseUp();
        eventSender.mouseDown();
    }

    eventSender.mouseMoveTo(target.offsetLeft + target.offsetWidth / 2, target.offsetTop + target.offsetHeight / 2);
    eventSender.mouseDown();
    eventSender.leapForward(100);
    eventSender.mouseMoveTo(500, 500);
    eventSender.mouseUp();

    document.getElementById('container').textContent = called ? 'PASS - mouse up and down inside a dragstart did not crash WebKit'
        : 'FAIL - dragstart was never fired.';
}

</script>
</body>
</html>
