Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: LayoutTests/fast/files/file-in-input-display.html

Issue 235373005: Handle JS-created files in <input type="file">. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
3 Tests the string displayed when a File created using the File constructor is
4 used in the FileList of a <input type="file"> element. To run this test
5 manually, drag the black box over the input field.
6 -->
tkent 2014/07/23 01:19:58 Please mention what's the expectation. Maybe "hel
pwnall-personal 2014/07/23 06:58:20 Done.
7
8 <style>
9 html {
10 font: 10px Ahem;
11 -webkit-font-smoothing: none;
12 }
13 #dragSource {
14 border: 1px solid black;
15 width: 100px;
16 height: 100px;
17 color: black;
18 margin-bottom: 50px;
19 }
20 #inputElement {
21 width: 100px;
22 height: 100px;
23 }
24 </style>
25
26 <div id="dragSource" draggable="true"
27 title="Drag this box onto the file input below">
28 </div>
29
30 <form action="#">
31 <p>
32 <input id="fileInput" type="file" />
33 </p>
34 </form>
35
36 <script>
37 if(window.testRunner)
tkent 2014/07/23 01:19:58 nit: Need a space between f and (
pwnall-personal 2014/07/23 06:58:21 Done. Thank you, and sorry! I should know better
38 testRunner.waitUntilDone();
39
40 // FIXME: dragging will become unnecessary if/when we implement a FileList const ructor
41 var dragSource = document.getElementById('dragSource');
42 var inputElement = document.getElementById('fileInput');
43
44 var outputFileList = null;
45 dragSource.addEventListener('dragstart', function (event) {
46 var testFile = new File(['Hello world!'], 'hello.txt');
47 console.log(event.dataTransfer);
48 event.dataTransfer.effectAllowed = 'copy';
49 event.dataTransfer.items.add(testFile);
50 outputFileList = event.dataTransfer.files;
51 });
52
53 inputElement.addEventListener('dragenter', function (event) {
54 event.preventDefault();
55 });
56 inputElement.addEventListener('dragover', function (event) {
57 event.preventDefault();
58 });
59 inputElement.addEventListener('drop', function (event) {
60 event.target.files = outputFileList;
61 if (window.testRunner)
62 testRunner.notifyDone();
63 });
64
65 function dragSourceToInput() {
66 var startX = dragSource.offsetLeft + dragSource.offsetWidth / 2;
tkent 2014/07/23 01:19:58 nit: inconsistent indentation. Other function use
pwnall-personal 2014/07/23 06:58:21 Done.
67 var startY = dragSource.offsetTop + dragSource.offsetHeight / 2;
68 var targetX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
69 var targetY = inputElement.offsetTop + inputElement.offsetHeight / 2;
70
71 if (window.eventSender) {
72 eventSender.dragMode = true;
73 eventSender.mouseMoveTo(startX, startY);
74 eventSender.mouseDown();
75 eventSender.leapForward(250);
76 eventSender.mouseMoveTo(targetX, targetY);
77 eventSender.mouseUp();
78 // eventSender.leapForward(250);
tkent 2014/07/23 01:19:58 commented out code.
pwnall-personal 2014/07/23 06:58:21 Done. Thanks! Too many iterations :(
79 }
80 }
81 dragSourceToInput();
82 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698