blob: 3780d77d0e9132a4d44393519d1a59e4eb477a0f [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/send-form-data-common.js"></script>
<script>
description("Test that filename passed to FormData.append() takes precedence over filename in File, even if empty.");
self.jsTestIsAsync = true;
function runTest()
{
debug("Sending FormData containing one file with custom empty filename:");
var input = document.getElementsByTagName("input")[0];
if (window.eventSender) {
eventSender.beginDragWithFiles(['../resources/file-for-drag-to-send.txt']);
moveMouseToCenterOfElement(input);
eventSender.mouseUp();
}
var formData = new FormData;
formData.append("file", input.files[0], "");
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://127.0.0.1:8000/xmlhttprequest/resources/multipart-post-echo-filenames.php", true);
xhr.onload = function() {
filename = xhr.responseText;
shouldBe("filename", "''");
formDataTestingCleanup();
finishJSTest();
}
xhr.send(formData);
}
if (window.eventSender) {
runTest();
} else {
debug("To run this test manually, please drag a file onto file input above");
document.getElementsByTagName("input")[0].onchange = runTest;
}
var successfullyParsed = true;
</script>
<script src="../../../../resources/js-test-post.js"></script>
</body>
</html>