6 border:
1px solid black;
11 border:
1px solid black;
19 var result
= document
.getElementById('result');
20 result
.appendChild(document
.createTextNode(str
));
21 result
.appendChild(document
.createElement('br'));
23 function dragstart(event
) {
24 event
.dataTransfer
.setData('text', 'sample');
25 event
.dataTransfer
.setData('custom-data', 'hello world');
27 function dragenter(event
) {
28 event
.preventDefault();
30 function dragover(event
) {
31 event
.preventDefault();
33 function drop(event
) {
35 if (event
.dataTransfer
.types
.indexOf('text/plain') < 0
36 || event
.dataTransfer
.types
.indexOf('custom-data') < 0)
38 if (event
.dataTransfer
.getData('text') != 'sample'
39 || event
.dataTransfer
.getData('custom-data') != 'hello world')
41 log(failed
? 'FAILURE' : 'SUCCESS');
42 if (window
.testRunner
)
43 testRunner
.notifyDone();
45 window
.onload = function()
47 if (!window
.testRunner
)
49 testRunner
.dumpAsText();
50 testRunner
.waitUntilDone();
52 var dragElement
= document
.getElementById('drag');
53 eventSender
.mouseMoveTo(dragElement
.offsetLeft
+ dragElement
.offsetWidth
/ 2,
54 dragElement
.offsetTop
+ dragElement
.offsetHeight
/ 2);
55 eventSender
.mouseDown();
56 eventSender
.leapForward(100);
57 var dropElement
= document
.getElementById('drop');
58 eventSender
.mouseMoveTo(dropElement
.offsetLeft
+ dropElement
.offsetWidth
/ 2,
59 dropElement
.offsetTop
+ dropElement
.offsetHeight
/ 2);
60 eventSender
.mouseUp();
65 <p>To manually test, drag 'Drag Me' to 'Drop Here' and drop. The word 'SUCCESS' should appear.
66 <div draggable=
"true" id=
"drag" ondragstart=
"dragstart(event)">Drag Me
</div>
67 <div id=
"drop" ondragenter=
"dragenter(event)" ondragover=
"dragover(event)" ondrop=
"drop(event)">Drop Here
</div>
69 <div id=
"result"></div>