| 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 <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>
|
|
|