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

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: 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 <!--
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
9 <style>
10 html {
11 font: 10px Ahem;
12 -webkit-font-smoothing: none;
13 }
14 #dragSource {
15 border: 1px solid black;
16 width: 100px;
17 height: 100px;
18 color: black;
19 margin-bottom: 50px;
20 }
21 #inputElement {
22 width: 100px;
23 height: 100px;
24 }
25 </style>
26
27 <div id="dragSource" draggable="true"
28 title="Drag this box onto the file input below">
29 </div>
30
31 <form action="#">
32 <p>
33 <input id="fileInput" type="file" />
34 </p>
35 </form>
36
37 <script>
38 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.
39 testRunner.waitUntilDone();
40
41 // FIXME: dragging will become unnecessary if/when we implement a FileList const ructor
42 var dragSource = document.getElementById('dragSource');
43 var inputElement = document.getElementById('fileInput');
44
45 inputElement.disabled = true;
46 var testFile = null;
47 webkitRequestFileSystem(window.TEMPORARY, 1024 * 1024, function (fs) {
48 fs.root.getFile('hello.txt', {create: true, exclusive: false}, function (ent ry) {
49 entry.createWriter(function (writer) {
50 writer.onwriteend = function (event) {
51 entry.file(function (file) {
52 testFile = file;
53 inputElement.disabled = false;
54 dragSourceToInput();
55 });
56 };
57 writer.write(new Blob(['Hello world!']));
58 });
59 });
60 });
61
62 var outputFileList = null;
63 dragSource.addEventListener('dragstart', function (event) {
64 event.dataTransfer.items.add(testFile);
65 outputFileList = event.dataTransfer.files;
66 });
67
68 inputElement.addEventListener('dragenter', function (event) {
69 event.preventDefault();
70 });
71 inputElement.addEventListener('dragover', function (event) {
72 event.preventDefault();
73 });
74 inputElement.addEventListener('drop', function (event) {
75 event.target.files = outputFileList;
76 if (window.testRunner)
77 testRunner.notifyDone();
78 });
79
80 function dragSourceToInput() {
81 var startX = dragSource.offsetLeft + dragSource.offsetWidth / 2;
tkent 2014/07/23 01:19:58 nit: inconsistent indentation.
pwnall-personal 2014/07/23 06:58:21 Done.
82 var startY = dragSource.offsetTop + dragSource.offsetHeight / 2;
83 var targetX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
84 var targetY = inputElement.offsetTop + inputElement.offsetHeight / 2;
85
86 if (window.eventSender) {
87 eventSender.dragMode = true;
88 eventSender.mouseMoveTo(startX, startY);
89 eventSender.mouseDown();
90 eventSender.leapForward(250);
91 eventSender.mouseMoveTo(targetX, targetY);
92 eventSender.mouseUp();
93 // eventSender.leapForward(250);
94 }
95 }
96 </script>
97
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698