Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / pasteboard / can-read-in-dragstart-event.html
blob961e5e8ff78677c054657062ac68bd0b1141949b
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
5 function log(text) {
6 var log = document.getElementById('log');
7 log.appendChild(document.createTextNode(text));
8 log.appendChild(document.createElement('br'));
11 function dragStartTest(e) {
12 e.dataTransfer.setData('text/plain', 'dragstart test');
13 if (event.dataTransfer.types.indexOf('text/plain') < 0 ||
14 event.dataTransfer.getData('text/plain') != 'dragstart test')
15 log('dragstart: FAILED');
16 else
17 log('dragstart: SUCCESS');
20 function runTest() {
21 if (!window.testRunner)
22 return;
23 testRunner.dumpAsText();
25 var draggedElement = document.getElementById('draggedElement');
26 var x = draggedElement.offsetLeft + draggedElement.offsetWidth / 2;
27 var y = draggedElement.offsetTop + draggedElement.offsetHeight / 2;
29 eventSender.mouseMoveTo(x, y);
30 eventSender.mouseDown();
31 eventSender.leapForward(100);
32 eventSender.mouseMoveTo(x + 100, y + 100);
33 eventSender.mouseUp();
35 </script>
36 </head>
37 <body onload="runTest()">
38 <p>Simple test that data set during a dragstart event can be read back. To run
39 the test manually, simply start dragging the 'Drag Me' element below.
40 <div id="draggedElement" draggable="true" ondragstart="dragStartTest(event)">Drag Me</div>
41 <div id="log"></div>
42 </html>