| <!DOCTYPE html> |
| <html> |
| <body> |
| <form id="form"> |
| <input id="singleFileUpload" type="file"> |
| <input id="multipleFileUpload" type="file" multiple> |
| </form> |
| <p>This tests the value of stringValue for a single file- and multiple files-<input type="file"> control.</p> |
| <pre id="console"></pre> |
| <script> |
| if (window.testRunner && window.accessibilityController) { |
| testRunner.dumpAsText(); |
| runTest(); |
| } else |
| log("This test must be run with DumpRenderTree and an implemented AccessibilityController."); |
| |
| function runTest() |
| { |
| var elementIds = ["singleFileUpload", "multipleFileUpload"]; |
| var form = document.getElementById("form"); |
| |
| form.reset(); |
| log(""); // Add an empty line; make the expected results pretty. |
| log("Default value (no files selected):"); |
| for (var i = 0; i < elementIds.length; ++i) |
| logAccessibilityStringValueForElement(elementIds[i]); |
| |
| form.reset(); |
| log(""); // Add an empty line; make the expected results pretty. |
| log("Drag and drop a single file:"); |
| for (var i = 0; i < elementIds.length; ++i) { |
| dragAndDropFauxFilesOnElement(["file1.txt"], elementIds[i]); |
| logAccessibilityStringValueForElement(elementIds[i]); |
| } |
| |
| form.reset(); |
| log(""); // Add an empty line; make the expected results pretty. |
| log("Drag and drop two files:"); |
| for (var i = 0; i < elementIds.length; ++i) { |
| dragAndDropFauxFilesOnElement(["file1.txt", "file2.txt"], elementIds[i]); |
| logAccessibilityStringValueForElement(elementIds[i]); |
| } |
| } |
| |
| function log(message) |
| { |
| document.getElementById("console").appendChild(document.createTextNode(message + "\n")); |
| } |
| |
| function logAccessibilityStringValueForElement(elementId) |
| { |
| log('accessibilityController.accessibleElementById("' + elementId + '").stringValue: ' + accessibilityController.accessibleElementById(elementId).stringValue); |
| } |
| |
| function dragAndDropFauxFilesOnElement(files, elementId) |
| { |
| if (!window.eventSender || !eventSender.beginDragWithFiles) |
| return; |
| var element = document.getElementById(elementId); |
| eventSender.beginDragWithFiles(files); |
| eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop); |
| eventSender.mouseUp(); |
| } |
| </script> |
| </body> |
| </html> |