1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../editing.js" type=
"text/javascript"></script>
5 <script type=
"text/javascript">
6 if (window
.testRunner
) {
7 window
.testRunner
.waitUntilDone();
8 testRunner
.dumpAsText();
11 var handleDrop = function(e
) {
12 var console
= document
.getElementById('console');
13 var pasteText
= e
.dataTransfer
.getData("text/plain");
14 // Check that the content we get is the same content we dragged.
15 var expectedText
= 'drag';
16 if (pasteText
== expectedText
)
17 console
.innerHTML
+= "SUCCESS: Pasted text matched expected text";
19 console
.innerHTML
+= "FAILURE: Expected: " +expectedText
+ "\nbut was: " + pasteText
;
22 var handleDrag = function(e
) {
23 e
.dataTransfer
.dropEffect
= "copy";
24 // Cancel the drag, so we get the drop.
30 internals
.settings
.setEditingBehavior('mac');
31 var console
= document
.getElementById('console');
32 var editDiv
= document
.getElementById('test');
33 editDiv
.addEventListener('drop', handleDrop
, false);
34 editDiv
.addEventListener('dragover', handleDrag
, false);
36 // Select the text to drag.
37 selection
.collapse(editDiv
, 0);
38 extendSelectionForwardByWordCommand();
40 if (!window
.testRunner
)
44 var drag
= document
.getElementById('drag');
45 var x
= drag
.offsetLeft
+ drag
.offsetWidth
/ 2;
46 var y
= drag
.offsetTop
+ drag
.offsetHeight
/ 2;
47 eventSender
.mouseMoveTo(x
, y
);
48 eventSender
.mouseDown();
49 eventSender
.leapForward(400);
52 var drop
= document
.getElementById("drop");
53 x
= drop
.offsetLeft
+ drop
.offsetWidth
/ 2;
54 y
= drop
.offsetTop
+ drop
.offsetHeight
/ 2;
55 eventSender
.mouseMoveTo(x
, y
);
56 eventSender
.mouseUp();
57 window
.testRunner
.notifyDone();
61 <title>Test getData during drag and drop.
</title>
63 <body onload='runTest();'
>
64 <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>
65 <div contentEditable id='test'
><div><span id='drag'
>drag
</span></div><div><span id='drop'
>drop
</span></div></div>
66 <div id='console'
></div>