blob: ec7663941a3b20093093cb3069e626d4c55c2375 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../../resources/js-test-pre.js"></script>
<script src="../../../../resources/ui-helper.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 onChange(event)
{
var formData = new FormData;
formData.append("file", event.target.files[0], "");
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://127.0.0.1:8000/xmlhttprequest/resources/multipart-post-echo-filenames.py", true);
xhr.onload = function() {
filename = xhr.responseText;
shouldBe("filename", "''");
formDataTestingCleanup();
finishJSTest();
}
xhr.send(formData);
}
function runTest()
{
debug("Sending FormData containing one file with custom empty filename:");
var input = document.getElementsByTagName("input")[0];
input.onchange = onChange;
if (window.testRunner) {
testRunner.setOpenPanelFiles(['../resources/file-for-drag-to-send.txt']);
var centerX = input.offsetLeft + input.offsetWidth / 2;
var centerY = input.offsetTop + input.offsetHeight / 2;
UIHelper.activateAt(centerX, centerY);
}
}
if (window.testRunner)
runTest();
else {
debug("To run this test manually, please drag a file onto file input above");
document.getElementsByTagName("input")[0].onchange = onChange;
}
var successfullyParsed = true;
</script>
<script src="../../../../resources/js-test-post.js"></script>
</body>
</html>