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

Unified Diff: LayoutTests/fast/forms/file/selected-file-survives-navigation.html

Issue 428733008: Failing test for http://crbug.com/398366. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tweaked. 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
« no previous file with comments | « no previous file | LayoutTests/fast/forms/file/selected-file-survives-navigation-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/forms/file/selected-file-survives-navigation.html
diff --git a/LayoutTests/fast/forms/file/selected-file-survives-navigation.html b/LayoutTests/fast/forms/file/selected-file-survives-navigation.html
new file mode 100644
index 0000000000000000000000000000000000000000..c98e27ccd271fcff122c1be6ec1db1d9fdfa345a
--- /dev/null
+++ b/LayoutTests/fast/forms/file/selected-file-survives-navigation.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="resources/file-drag-common.js"></script>
+</head>
+<body>
+<p id="dropTarget" style="width: 200px; padding: 20px; border: 1px solid black;">
+To run this test manually, drag a file named "foo.txt" onto this box.
+</p>
+
+<input type="file" name="file" id="fileInput">
+
+<script>
+description('Check that the value of an &lt;input type="file"> sourced from a drag-and-drop operation survives navigation');
+
+var jsTestIsAsync = true;
+
+var dropTarget = document.getElementById("dropTarget");
+var fileInput = document.getElementById("fileInput");
+
+window.addEventListener("popstate", function() {
+ // This runs after the simulated Back button press.
+ shouldBe("fileInput.files.length", "1");
+ shouldBeEqualToString("fileInput.files.item(0).name", "foo.txt");
+ finishJSTest();
+});
+
+dropTarget.addEventListener('dragenter', function (event) {
+ event.preventDefault();
+});
+dropTarget.addEventListener('dragover', function (event) {
+ event.preventDefault();
+});
+dropTarget.addEventListener("drop", function(event) {
+ fileInput.files = event.dataTransfer.files;
+ event.preventDefault();
+
+ // This causes popstate to fire when history.back() is used.
+ history.pushState({}, "selected-file-survives.navigation.html");
+
+ // Simulate the user going to a different page and pressing the Back button.
+ var goBackPage = "<script>history.back();<" + "/script>;";
+ window.location.href = "data:text/html;charset=UTF-8," + encodeURIComponent(goBackPage);
+});
+
+window.addEventListener("load", function() {
+ if (window.testRunner) {
+ dragFilesOntoElement(dropTarget, ["foo.txt"]);
+ }
+});
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/forms/file/selected-file-survives-navigation-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698