OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta charset="utf-8"> |
| 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <style> |
| 6 #dropzone { |
| 7 display: block; |
| 8 border: 1px solid black; |
| 9 width: 200px; |
| 10 height: 200px; |
| 11 } |
| 12 </style> |
| 13 |
| 14 <p> |
| 15 Please download <a download href="resources/dragged-file.txt">this file</a>, |
| 16 and drag it into the box below. |
| 17 </p> |
| 18 |
| 19 <div id="dropzone" webkitdropzone="copy file:text/plain"> |
| 20 Drop Here |
| 21 </div> |
| 22 |
| 23 <script> |
| 24 |
| 25 async_test(t => { |
| 26 const dropZone = document.querySelector('#dropzone'); |
| 27 dropZone.ondrop = t.step_func_done(event => { |
| 28 event.preventDefault(); // Needed to prevent drop navigation. |
| 29 |
| 30 const dataTransfer = event.dataTransfer; |
| 31 assert_equals(dataTransfer.items.length, 1); |
| 32 const item = dataTransfer.items[0]; |
| 33 assert_equals(item.kind, 'file'); |
| 34 assert_equals(item.type, 'text/plain'); // application/x-moz-file in FF |
| 35 const file = item.getAsFile(); |
| 36 assert_equals(file.name, 'dragged-file.txt'); |
| 37 assert_equals(file.type, 'text/plain'); |
| 38 }); |
| 39 |
| 40 const clientRect = dropZone.getBoundingClientRect(); |
| 41 if (window.eventSender) { |
| 42 eventSender.beginDragWithFiles(['resources/dragged-file.txt']); |
| 43 const centerX = (clientRect.left + clientRect.right) / 2; |
| 44 const centerY = (clientRect.top + clientRect.bottom) / 2; |
| 45 eventSender.mouseMoveTo(centerX, centerY); |
| 46 eventSender.mouseUp(); |
| 47 } |
| 48 }, 'webkitdropzone element receives file drop on page served from HTTP'); |
| 49 |
| 50 </script> |
OLD | NEW |