blob: 95b69a26a300d256586ec3a31158c70d0007a5eb [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../../resources/ui-helper.js"></script>
</head>
<body>
<input type="file" name="file" id="file">
<script>
description("This tests the value attribute in file input forms");
if (window.testRunner) {
jsTestIsAsync = true;
var file = document.getElementById("file");
file.addEventListener("change", function() {
shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt");
shouldBe("file.files.length", "1");
shouldThrow("file.value = 'foo'");
shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt");
shouldBe("file.files.length", "1");
file.value = "";
shouldBeEqualToString("file.value", "");
shouldBe("file.files.length", "0");
finishJSTest();
});
openFilesInElement(file, ["foo.txt"]);
}
function openFilesInElement(input, files) {
testRunner.setOpenPanelFiles(files);
var centerX = input.offsetLeft + input.offsetWidth / 2;
var centerY = input.offsetTop + input.offsetHeight / 2;
UIHelper.activateAt(centerX, centerY);
}
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>