Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/dnd/drop-file-on-webkitdropzone.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/dnd/drop-file-on-webkitdropzone.html b/third_party/WebKit/LayoutTests/http/tests/dnd/drop-file-on-webkitdropzone.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d0b47d8e8bcf57368f1f8eb98f89a661a9001187 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/dnd/drop-file-on-webkitdropzone.html |
| @@ -0,0 +1,50 @@ |
| +<!doctype html> |
| +<meta charset="utf-8"> |
| +<script src="/resources/testharness.js"></script> |
| +<script src="/resources/testharnessreport.js"></script> |
| +<style> |
| +#dropzone { |
| + display: block; |
| + border: 1px solid black; |
| + width: 200px; |
| + height: 200px; |
| +} |
| +</style> |
| + |
| +<p> |
| + Please download <a download href="resources/dragged-file.txt">this file</a>, |
| + and drag it into the box below. |
| +</p> |
| + |
| +<div id="dropzone" webkitdropzone="copy file:text/plain"> |
| + Drop Here |
| +</div> |
| + |
| +<script> |
| + |
| +async_test(t => { |
| + const dropZone = document.querySelector('#dropzone'); |
| + dropZone.ondrop = t.step_func_done((event) => { |
|
jsbell
2016/12/16 21:18:52
nit: no () needed around single argument
pwnall
2016/12/16 21:31:42
Done.
|
| + event.preventDefault(); // Needed to prevent drop navigation. |
| + |
| + const dataTransfer = event.dataTransfer; |
| + assert_equals(dataTransfer.items.length, 1); |
| + const item = dataTransfer.items[0]; |
| + assert_equals(item.kind, 'file'); |
| + assert_equals(item.type, 'text/plain'); // application/x-moz-file in FF |
| + const file = item.getAsFile(); |
| + assert_equals(file.name, 'dragged-file.txt'); |
| + assert_equals(file.type, 'text/plain'); |
| + }); |
| + |
| + const clientRect = dropZone.getBoundingClientRect(); |
| + if (window.eventSender) { |
| + eventSender.beginDragWithFiles(['resources/dragged-file.txt']); |
| + const centerX = (clientRect.left + clientRect.right) / 2; |
| + const centerY = (clientRect.top + clientRect.bottom) / 2; |
| + eventSender.mouseMoveTo(centerX, centerY); |
| + eventSender.mouseUp(); |
| + } |
| +}, 'webkitdropzone element receives file drop on page served from HTTP'); |
| + |
| +</script> |