<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/file-drag-common.js"></script>
</head>
<body>
<input type="file" name="file1" id="file1">
<input type="file" name="file2" id="file2">
<script>
description("This tests the files attribute in file input forms");
if (window.testRunner) {
var file1 = document.getElementById("file1");
var file2 = document.getElementById("file2");
dragFilesOntoInput(file1, ["foo.txt"]);
dragFilesOntoInput(file2, ["bar.txt"]);
shouldBe("file1.files.length", "1");
shouldThrow("file1.files = 'foo'");
file1.files = null;
shouldBe("file1.files.length", "1");
shouldBeEqualToString("file1.files.item(0).name", "foo.txt");
// From current W3C spec, files attribute should be read only,
// but WebKit implement it to be writable intentionally.
// See: https://bugs.webkit.org/show_bug.cgi?id=87154#c15
file1.files = file2.files;
shouldBe("file1.files.length", "1");
shouldBeEqualToString("file1.files.item(0).name", "bar.txt");
}
</script>
</body>
</html>