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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/filesystem/input-display.html
diff --git a/LayoutTests/http/tests/filesystem/input-display.html b/LayoutTests/http/tests/filesystem/input-display.html
new file mode 100644
index 0000000000000000000000000000000000000000..601dbd4bf511aa1ddef603439604f8c19783497d
--- /dev/null
+++ b/LayoutTests/http/tests/filesystem/input-display.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+
+<!--
+Tests the string displayed when a File created using the FileSystem API is used
+in the FileList of a <input type="file"> element. To run this test manually,
+drag the black box over the input field.
+
+Expectation: the file name displayed by the <input> UI should be hello.txt. The
+renderer should not crash after the name shows up.
+-->
+
+<style>
+html {
+ font: 10px Ahem;
+ -webkit-font-smoothing: none;
+}
+#dragSource {
+ border: 1px solid black;
+ width: 100px;
+ height: 100px;
+ color: black;
+ margin-bottom: 50px;
+}
+#inputElement {
+ width: 100px;
+ height: 100px;
+}
+</style>
+
+<div id="dragSource" draggable="true"
+ title="Drag this box onto the file input below">
+</div>
+
+<form action="#">
+ <p>
+ <input id="fileInput" type="file" />
+ </p>
+</form>
+
+<script>
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+// FIXME: dragging will become unnecessary if/when we implement a FileList constructor
+var dragSource = document.getElementById('dragSource');
+var inputElement = document.getElementById('fileInput');
+
+inputElement.disabled = true;
+var testFile = null;
+webkitRequestFileSystem(window.TEMPORARY, 1024 * 1024, function (fs) {
+ fs.root.getFile('hello.txt', {create: true, exclusive: false}, function (entry) {
+ entry.createWriter(function (writer) {
+ writer.onwriteend = function (event) {
+ entry.file(function (file) {
+ testFile = file;
+ inputElement.disabled = false;
+ dragSourceToInput();
+ });
+ };
+ writer.write(new Blob(['Hello world!']));
+ });
+ });
+});
+
+var outputFileList = null;
+dragSource.addEventListener('dragstart', function (event) {
+ event.dataTransfer.items.add(testFile);
+ outputFileList = event.dataTransfer.files;
+});
+
+inputElement.addEventListener('dragenter', function (event) {
+ event.preventDefault();
+});
+inputElement.addEventListener('dragover', function (event) {
+ event.preventDefault();
+});
+inputElement.addEventListener('drop', function (event) {
+ event.target.files = outputFileList;
+ if (window.testRunner)
+ testRunner.notifyDone();
+});
+
+function dragSourceToInput() {
+ var startX = dragSource.offsetLeft + dragSource.offsetWidth / 2;
+ var startY = dragSource.offsetTop + dragSource.offsetHeight / 2;
+ var targetX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
+ var targetY = inputElement.offsetTop + inputElement.offsetHeight / 2;
+
+ if (window.eventSender) {
+ eventSender.dragMode = true;
+ eventSender.mouseMoveTo(startX, startY);
+ eventSender.mouseDown();
+ eventSender.leapForward(250);
+ eventSender.mouseMoveTo(targetX, targetY);
+ eventSender.mouseUp();
+ }
+}
+</script>
+

Powered by Google App Engine
This is Rietveld 408576698