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('DownloadURL', 'http://google.com/');
26 function dragenter(event
) {
27 event
.preventDefault();
29 function dragover(event
) {
30 event
.preventDefault();
32 function drop(event
) {
34 if (event
.dataTransfer
.types
.indexOf('downloadurl') < 0) {
35 log('types: ' + event
.dataTransfer
.types
);
38 if (event
.dataTransfer
.getData('DownloadURL') != 'http://google.com/') {
39 log('getData: ' + event
.dataTransfer
.getData('DownloadURL'));
42 log(failed
? 'FAILURE' : 'SUCCESS');
43 if (window
.testRunner
)
44 testRunner
.notifyDone();
46 window
.onload = function()
48 if (!window
.testRunner
)
50 testRunner
.dumpAsText();
51 testRunner
.waitUntilDone();
53 var dragElement
= document
.getElementById('drag');
54 eventSender
.mouseMoveTo(dragElement
.offsetLeft
+ dragElement
.offsetWidth
/ 2,
55 dragElement
.offsetTop
+ dragElement
.offsetHeight
/ 2);
56 eventSender
.mouseDown();
57 eventSender
.leapForward(100);
58 var dropElement
= document
.getElementById('drop');
59 eventSender
.mouseMoveTo(dropElement
.offsetLeft
+ dropElement
.offsetWidth
/ 2,
60 dropElement
.offsetTop
+ dropElement
.offsetHeight
/ 2);
61 eventSender
.mouseUp();
66 <p>To manually test, drag 'Drag Me' to 'Drop Here' and drop. The word 'SUCCESS' should appear.
67 <div draggable=
"true" id=
"drag" ondragstart=
"dragstart(event)">Drag Me
</div>
68 <div id=
"drop" ondragenter=
"dragenter(event)" ondragover=
"dragover(event)" ondrop=
"drop(event)">Drop Here
</div>
70 <div id=
"result"></div>