blob: d3a0567db1ec3f812886f923bd57df29086619d1 [file] [log] [blame]
<!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-&lt;input type=&quot;file&quot;&gt; 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>