blob: 2f55c0865b19c944a7f10f892b69045961c1ecb8 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../editing.js" type="text/javascript"></script>
<script type="text/javascript">
if (window.layoutTestController) {
window.layoutTestController.waitUntilDone();
layoutTestController.dumpAsText();
}
var handleDrop = function(e) {
var console = document.getElementById('console');
var pasteText = e.dataTransfer.getData("text/plain");
// Check that the content we get is the same content we dragged.
var expectedText = 'drag';
if (pasteText == expectedText)
console.innerHTML += "SUCCESS: Pasted text matched expected text";
else
console.innerHTML += "FAILURE: Expected: " +expectedText + "\nbut was: " + pasteText;
}
var handleDrag = function(e) {
// Cancel the drag, so we get the drop.
e.preventDefault();
}
function runTest() {
var console = document.getElementById('console');
var editDiv = document.getElementById('test');
editDiv.addEventListener('drop', handleDrop, false);
editDiv.addEventListener('dragover', handleDrag, false);
// Select the text to drag.
selection.setPosition(editDiv, 0);
extendSelectionForwardByWordCommand();
if (!window.layoutTestController)
return;
// Now, drag foo.
var drag = document.getElementById('drag');
var x = drag.offsetLeft + drag.offsetWidth / 2;
var y = drag.offsetTop + drag.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.leapForward(400);
// And drop it.
var drop = document.getElementById("drop");
x = drop.offsetLeft + drop.offsetWidth / 2;
y = drop.offsetTop + drop.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseUp();
window.layoutTestController.notifyDone();
}
</script>
<title>Test getData during drag and drop.</title>
</head>
<body onload='runTest();'>
<p>This tests that getData is supported for type text/plain during drop. We select "drag", drag it, and then check that on drop getData returns "drag". To run this test manually, just drag "drag" on to "drop".</p>
<div contentEditable id='test'><div><span id='drag'>drag</span></div><div><span id='drop'>drop</span></div></div>
<div id='console'></div>
</body>
</html>