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.
7 Expectation: the file name displayed by the <input> UI should be hello.txt. The
8 renderer should not crash after the name shows up.
14 -webkit-font-smoothing: none;
17 border:
1px solid black;
29 <div id=
"dragSource" draggable=
"true"
30 title=
"Drag this box onto the file input below">
35 <input id=
"fileInput" type=
"file" />
40 if (window
.testRunner
)
41 testRunner
.waitUntilDone();
43 // FIXME: dragging will become unnecessary if/when we implement a FileList constructor
44 var dragSource
= document
.getElementById('dragSource');
45 var inputElement
= document
.getElementById('fileInput');
47 var outputFileList
= null;
48 dragSource
.addEventListener('dragstart', function (event
) {
49 var testFile
= new File(['Hello world!'], 'hello.txt');
50 console
.log(event
.dataTransfer
);
51 event
.dataTransfer
.effectAllowed
= 'copy';
52 event
.dataTransfer
.items
.add(testFile
);
53 outputFileList
= event
.dataTransfer
.files
;
56 inputElement
.addEventListener('dragenter', function (event
) {
57 event
.preventDefault();
59 inputElement
.addEventListener('dragover', function (event
) {
60 event
.preventDefault();
62 inputElement
.addEventListener('drop', function (event
) {
63 event
.target
.files
= outputFileList
;
64 if (window
.testRunner
)
65 testRunner
.notifyDone();
68 function dragSourceToInput() {
69 var startX
= dragSource
.offsetLeft
+ dragSource
.offsetWidth
/ 2;
70 var startY
= dragSource
.offsetTop
+ dragSource
.offsetHeight
/ 2;
71 var targetX
= inputElement
.offsetLeft
+ inputElement
.offsetWidth
/ 2;
72 var targetY
= inputElement
.offsetTop
+ inputElement
.offsetHeight
/ 2;
74 if (window
.eventSender
) {
75 eventSender
.dragMode
= true;
76 eventSender
.mouseMoveTo(startX
, startY
);
77 eventSender
.mouseDown();
78 eventSender
.leapForward(250);
79 eventSender
.mouseMoveTo(targetX
, targetY
);
80 eventSender
.mouseUp();