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

Unified Diff: Source/core/html/forms/FileInputTypeTest.cpp

Issue 720403002: Let input tag filter out non-native files in dropped data. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test. Created 6 years, 1 month 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
« no previous file with comments | « Source/core/html/forms/FileInputType.cpp ('k') | Source/core/page/DragController.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/forms/FileInputTypeTest.cpp
diff --git a/Source/core/html/forms/FileInputTypeTest.cpp b/Source/core/html/forms/FileInputTypeTest.cpp
index 68da534f7c627d7d89da12d9c6fe0e883d7ec499..7bb943d5873b4b1b9f32b582cf5da6f240fa1585 100644
--- a/Source/core/html/forms/FileInputTypeTest.cpp
+++ b/Source/core/html/forms/FileInputTypeTest.cpp
@@ -5,7 +5,11 @@
#include "config.h"
#include "FileInputType.h"
+#include "core/clipboard/DataObject.h"
+#include "core/dom/Document.h"
#include "core/fileapi/FileList.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/page/DragData.h"
#include <gtest/gtest.h>
namespace blink {
@@ -42,4 +46,34 @@ TEST(FileInputTypeTest, createFileList)
EXPECT_EQ(24 * 60 * 60 * 1000 /* ms */, list->item(1)->lastModified());
}
+TEST(FileInputTypeTest, ignoreDroppedNonNativeFiles)
+{
+ const RefPtrWillBeRawPtr<Document> document = Document::create();
+ const RefPtrWillBeRawPtr<HTMLInputElement> input =
+ HTMLInputElement::create(*document, nullptr, /* createdByParser */true);
+ const RefPtrWillBeRawPtr<InputType> fileInput = FileInputType::create(*input);
+
+ const RefPtrWillBeRawPtr<DataObject> nativeFileRawDragData = DataObject::create();
+ const DragData nativeFileDragData(nativeFileRawDragData.get(), IntPoint(), IntPoint(), DragOperationCopy);
+ nativeFileDragData.platformData()->add(File::create("/native/path"));
+ nativeFileDragData.platformData()->setFilesystemId("fileSystemId");
+ fileInput->receiveDroppedFiles(&nativeFileDragData);
+ EXPECT_EQ("fileSystemId", fileInput->droppedFileSystemId());
+ ASSERT_EQ(1u, fileInput->files()->length());
+ EXPECT_EQ(String("/native/path"), fileInput->files()->item(0)->path());
+
+ const RefPtrWillBeRawPtr<DataObject> nonNativeFileRawDragData = DataObject::create();
+ const DragData nonNativeFileDragData(nonNativeFileRawDragData.get(), IntPoint(), IntPoint(), DragOperationCopy);
+ FileMetadata metadata;
+ metadata.length = 1234;
+ const KURL url(ParsedURLStringTag(), "filesystem:http://example.com/isolated/hash/non-native-file");
+ nonNativeFileDragData.platformData()->add(File::createForFileSystemFile(url, metadata, File::IsUserVisible));
+ nonNativeFileDragData.platformData()->setFilesystemId("fileSystemId");
+ fileInput->receiveDroppedFiles(&nonNativeFileDragData);
+ // Dropping non-native files should not change the existing files.
+ EXPECT_EQ("fileSystemId", fileInput->droppedFileSystemId());
+ ASSERT_EQ(1u, fileInput->files()->length());
+ EXPECT_EQ(String("/native/path"), fileInput->files()->item(0)->path());
+}
+
} // namespace blink
« no previous file with comments | « Source/core/html/forms/FileInputType.cpp ('k') | Source/core/page/DragController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698