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

Side by Side Diff: LayoutTests/http/tests/filesystem/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: Fixed visibility bug. 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 <!--
4 Tests the string displayed when a File created using the FileSystem API is used
5 in the FileList of a <input type="file"> element. To run this test manually,
6 drag the black box over the input field.
7
8 Expectation: the file name displayed by the <input> UI should be hello.txt. The
9 renderer should not crash after the name shows up.
10 -->
11
12 <style>
13 html {
14 font: 10px Ahem;
15 -webkit-font-smoothing: none;
16 }
17 #dragSource {
18 border: 1px solid black;
19 width: 100px;
20 height: 100px;
21 color: black;
22 margin-bottom: 50px;
23 }
24 #inputElement {
25 width: 100px;
26 height: 100px;
27 }
28 </style>
29
30 <div id="dragSource" draggable="true"
31 title="Drag this box onto the file input below">
32 </div>
33
34 <form action="#">
35 <p>
36 <input id="fileInput" type="file" />
37 </p>
38 </form>
39
40 <script>
41 if (window.testRunner)
42 testRunner.waitUntilDone();
43
44 // FIXME: dragging will become unnecessary if/when we implement a FileList const ructor
45 var dragSource = document.getElementById('dragSource');
46 var inputElement = document.getElementById('fileInput');
47
48 inputElement.disabled = true;
49 var testFile = null;
50 webkitRequestFileSystem(window.TEMPORARY, 1024 * 1024, function (fs) {
51 fs.root.getFile('hello.txt', {create: true, exclusive: false}, function (ent ry) {
52 entry.createWriter(function (writer) {
53 writer.onwriteend = function (event) {
54 entry.file(function (file) {
55 testFile = file;
56 inputElement.disabled = false;
57 dragSourceToInput();
58 });
59 };
60 writer.write(new Blob(['Hello world!']));
61 });
62 });
63 });
64
65 var outputFileList = null;
66 dragSource.addEventListener('dragstart', function (event) {
67 event.dataTransfer.items.add(testFile);
68 outputFileList = event.dataTransfer.files;
69 });
70
71 inputElement.addEventListener('dragenter', function (event) {
72 event.preventDefault();
73 });
74 inputElement.addEventListener('dragover', function (event) {
75 event.preventDefault();
76 });
77 inputElement.addEventListener('drop', function (event) {
78 event.target.files = outputFileList;
79 if (window.testRunner)
80 testRunner.notifyDone();
81 });
82
83 function dragSourceToInput() {
84 var startX = dragSource.offsetLeft + dragSource.offsetWidth / 2;
85 var startY = dragSource.offsetTop + dragSource.offsetHeight / 2;
86 var targetX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
87 var targetY = inputElement.offsetTop + inputElement.offsetHeight / 2;
88
89 if (window.eventSender) {
90 eventSender.dragMode = true;
91 eventSender.mouseMoveTo(startX, startY);
92 eventSender.mouseDown();
93 eventSender.leapForward(250);
94 eventSender.mouseMoveTo(targetX, targetY);
95 eventSender.mouseUp();
96 }
97 }
98 </script>
99
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698