blob: 3bd4e7d042b20f1b3c32b56912800f68ba7e4144 [file] [log] [blame]
<!-- webkit-test-runner [ enableDragDestinationActionLoad=true ] -->
<!DOCTYPE html>
<html>
<head>
<style>
div, span {
border: 1px solid black;
};
</style>
<script>
var dropReceived;
function log(str)
{
var result = document.getElementById('result');
result.appendChild(document.createTextNode(str));
result.appendChild(document.createElement('br'));
}
function dragDrop(target)
{
log('Starting drag...');
eventSender.beginDragWithFiles(['test']);
eventSender.leapForward(100);
eventSender.mouseMoveTo(target.offsetLeft + target.offsetWidth / 2,
target.offsetTop + target.offsetHeight / 2);
eventSender.mouseUp();
}
window.onload = function()
{
var drop1 = document.getElementById('drop1');
var drop2 = document.getElementById('drop2');
document.body.addEventListener('dragover', function () {
dropReceived = false;
}, false);
drop1.addEventListener('dragover', function(e) {
e.preventDefault();
}, false);
drop1.addEventListener('drop', function(e) {
e.preventDefault();
dropReceived = true;
log('Drop received in drop target 1');
}, false);
drop2.addEventListener('dragover', function() {
}, false);
drop2.addEventListener('drop', function(e) {
e.preventDefault();
dropReceived = true;
log('Drop received in drop target 2');
}, false);
if (!window.testRunner)
return;
testRunner.dumpAsText();
testRunner.waitUntilDone();
window.addEventListener('beforeunload', function () {
if (!dropReceived)
log('Drop not received');
testRunner.notifyDone();
});
dragDrop(drop1);
unloadExpected = true;
dragDrop(drop2);
window.setTimeout(function () {
// Deadman's switch to fail quickly.
log('FAIL: navigation expected');
testRunner.notifyDone();
}, 0);
}
</script>
</head>
<body>
<p>To run this test manually, drag a file to one of the two boxes below.
<div id="drop1">Dropping in drop target 1 should result in a drop event.</div>
<div id="drop2">Dropping in drop target 2 should NOT result in a drop event (page will navigate).</div>
<div id="result">
</div>
</body>
</html>