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

function log(message) {
    var console = document.getElementById("console");
    var li = document.createElement("li");
    var text = document.createTextNode(message);
    
    console.appendChild(li);
    li.appendChild(text);
}

function step1() {
    window.frames[0].document.write("<div contenteditable>drag<img src='../resources/abe.png' id=dragme>me<span id=target>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div>");
    setTimeout("step2()", 100);
}

function step2() {
    if (!window.testRunner) {
        log("This test uses eventSender. To run it manually, drag the selected image to another position in the editable div and drop it. It should not disappear.");
        return;
    }
    
    var doc = window.frames[0].document;
    e = doc.getElementById("dragme");
    x = e.offsetLeft + e.offsetWidth / 2;
    y = e.offsetTop + e.offsetHeight / 2;
    
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();    
    e = doc.getElementById("target");
    x = e.offsetLeft + e.offsetWidth / 2;
    y = e.offsetTop + e.offsetHeight / 2;
    
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseUp();

    document.write("<p><a href='http://bugs.webkit.org/show_bug.cgi?id=14428'>Bug 14428</a>: FCKEditor: Images disappear on drag/drop and copy/paste</p>");

    if (doc.getElementById("dragme").parentNode.tagName == "SPAN" && doc.getElementById("dragme").src.length > 10)
        document.write("<p>SUCCESS</p>");
    else
        document.write("<p>FAILURE</p>");

    testRunner.notifyDone();
}
</script>
</head>
<body onload="setTimeout('step1()', 100)">
<iframe src="about:blank"></iframe>
<ul id="console"></ul>
</body>
</html>
