6 border: 1px solid black;
11 border: 1px solid black;
17 function assertEq(left, right)
20 log('PASS: ' + left + " === " + right);
22 log('FAIL: ' + left + " (of type " + (typeof left) + ") !== " + right + " (of type " + (typeof right) + ")");
26 var result = document.getElementById('result');
27 result.appendChild(document.createTextNode(str));
28 result.appendChild(document.createElement('br'));
32 function dragstart(event)
34 event.dataTransfer.items.add(testFile);
37 function dragenter(event)
39 event.preventDefault();
42 function dragover(event)
44 event.preventDefault();
49 assertEq(1, event.dataTransfer.items.length);
50 assertEq('file', event.dataTransfer.items[0].kind);
51 assertEq('text/plain', event.dataTransfer.items[0].type);
52 testRunner.notifyDone();
57 // First, we need to generate a File object to use for our tests.
58 eventSender.beginDragWithFiles(['test.txt']);
59 var inputElement = document.getElementsByTagName('input')[0];
60 eventSender.mouseMoveTo(inputElement.offsetLeft + inputElement.offsetWidth / 2,
61 inputElement.offsetTop + inputElement.offsetHeight / 2);
62 eventSender.mouseUp();
63 testFile = inputElement.files[0];
65 // Now run the actual test.
66 var dragElement = document.getElementById('drag');
67 eventSender.mouseMoveTo(dragElement.offsetLeft + dragElement.offsetWidth / 2,
68 dragElement.offsetTop + dragElement.offsetHeight / 2);
69 eventSender.mouseDown();
70 eventSender.leapForward(100);
71 var dropElement = document.getElementById('drop');
72 eventSender.mouseMoveTo(dropElement.offsetLeft + dropElement.offsetWidth / 2,
73 dropElement.offsetTop + dropElement.offsetHeight / 2);
74 eventSender.mouseUp();
77 window.onload = function()
79 if (!window.testRunner)
81 testRunner.dumpAsText();
82 testRunner.waitUntilDone();
89 <p>To manually test, select a text file for the file input element, and then drag 'Drag Me' to 'Drop Here' and drop. Several lines that say 'PASS' should appear below.
90 <input type="file"></input>
91 <div draggable="true" id="drag" ondragstart="dragstart(event)">Drag Me</div>
92 <div id="drop" ondragenter="dragenter(event)" ondragover="dragover(event)" ondrop="drop(event)">Drop Here</div>
94 <div id="result"></div>