| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> |
| 5 <script src="resources/file-drag-common.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <p id="dropTarget" style="width: 200px; padding: 20px; border: 1px solid black;"
> |
| 9 To run this test manually, drag a file named "foo.txt" onto this box. |
| 10 </p> |
| 11 |
| 12 <input type="file" name="file" id="fileInput"> |
| 13 |
| 14 <script> |
| 15 description('Check that the value of an <input type="file"> sourced from a dr
ag-and-drop operation survives navigation'); |
| 16 |
| 17 var jsTestIsAsync = true; |
| 18 |
| 19 var dropTarget = document.getElementById("dropTarget"); |
| 20 var fileInput = document.getElementById("fileInput"); |
| 21 |
| 22 window.addEventListener("popstate", function() { |
| 23 // This runs after the simulated Back button press. |
| 24 shouldBe("fileInput.files.length", "1"); |
| 25 shouldBeEqualToString("fileInput.files.item(0).name", "foo.txt"); |
| 26 finishJSTest(); |
| 27 }); |
| 28 |
| 29 dropTarget.addEventListener('dragenter', function (event) { |
| 30 event.preventDefault(); |
| 31 }); |
| 32 dropTarget.addEventListener('dragover', function (event) { |
| 33 event.preventDefault(); |
| 34 }); |
| 35 dropTarget.addEventListener("drop", function(event) { |
| 36 fileInput.files = event.dataTransfer.files; |
| 37 event.preventDefault(); |
| 38 |
| 39 // This causes popstate to fire when history.back() is used. |
| 40 history.pushState({}, "selected-file-survives.navigation.html"); |
| 41 |
| 42 // Simulate the user going to a different page and pressing the Back button. |
| 43 var goBackPage = "<script>history.back();<" + "/script>;"; |
| 44 window.location.href = "data:text/html;charset=UTF-8," + encodeURIComponent(
goBackPage); |
| 45 }); |
| 46 |
| 47 window.addEventListener("load", function() { |
| 48 if (window.testRunner) { |
| 49 dragFilesOntoElement(dropTarget, ["foo.txt"]); |
| 50 } |
| 51 }); |
| 52 </script> |
| 53 </body> |
| 54 </html> |
| OLD | NEW |