<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
var ddLink;
var didDragStart = false;

window.jsTestIsAsync = true;

window.onload = function ()
{
    ddLink = document.getElementById("ddLink");

    ddLink.ondragstart = dragStart;
    document.body.onmouseup = mouseUp;

    runTests();
}

function dragStart(e)
{
    didDragStart = true;
    debug('<br><span class="fail">FAIL! Got dragStart().</span>');
}

function mouseUp(e)
{
    var testContainer = document.getElementById("test-container");
    if (testContainer)
        document.body.removeChild(testContainer);
    if (!didDragStart)
        debug('<br><span class="pass">TEST COMPLETE</span>');
    finishJSTest();
}

function dragAndDrop(beginX, beginY, endX, endY)
{
    if (!window.eventSender)
        return;
    eventSender.mouseMoveTo(beginX, beginY);
    eventSender.mouseDown();
    eventSender.leapForward(100);
    eventSender.mouseMoveTo(endX, endY);
    eventSender.mouseUp();
}

function runTests()
{
    if (!window.testRunner)
        return;

    debug("<br>Trying to drag Data Detectors link (should fail)<br>");
    dragAndDrop(ddLink.offsetLeft, ddLink.offsetTop + ddLink.offsetHeight / 2, 100, 100);
}
</script>
</head>
<body>
<div id="description"></div>
<div id="test-container">
    <a href="x-apple-data-detectors://1" id="ddLink">Data Detectors Link</a>
</div>
<div id="console"></div>
<script>
description("This test checks that drag-and-drop is blocked for Data Detectors links.");
</script>
</body>
</html>
