| Index: LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html
|
| diff --git a/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html b/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8d5203d192d222cc3c8f1594e587f5ddc62625e6
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html
|
| @@ -0,0 +1,51 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<body>
|
| +<script src="../../../../resources/js-test.js"></script>
|
| +<script>
|
| +description("Test that we can send empty name in FormData.append()");
|
| +
|
| +self.jsTestIsAsync = true;
|
| +
|
| +function shouldContain(string, substring, message) {
|
| + if (string.indexOf(substring) >= 0)
|
| + testPassed(message);
|
| + else
|
| + testFailed("the FormData containing" + substring + " failed to echo correctly");
|
| +}
|
| +
|
| +function firstTest() {
|
| + var formData = new FormData();
|
| + formData.append('', 'empty');
|
| + formData.append('hello', 'world');
|
| + var xhr = new XMLHttpRequest();
|
| + xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi', true);
|
| + xhr.onload = function() {
|
| + shouldContain(xhr.response, 'name=""\r\n\r\nempty',
|
| + 'the FormData of string type containing a empty name echoed correctly');
|
| + shouldContain(xhr.response, 'name="hello"\r\n\r\nworld',
|
| + 'the FormData of string type containing a name echoed correctly');
|
| + secondTest();
|
| + };
|
| + xhr.send(formData);
|
| +}
|
| +
|
| +function secondTest() {
|
| + var formData = new FormData();
|
| + formData.append('', new Blob(), 'empty-name.txt');
|
| + formData.append('testFile', new Blob(), 'custom-name.txt');
|
| + var xhr = new XMLHttpRequest();
|
| + xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi', true);
|
| + xhr.onload = function() {
|
| + shouldContain(xhr.response, 'name=""; filename="empty-name.txt"',
|
| + 'the FormData of file type containing a empty name echoed correctly');
|
| + shouldContain(xhr.response, 'name="testFile"; filename="custom-name.txt"',
|
| + 'the FormData of file type containing a name echoed correctly');
|
| + finishJSTest();
|
| + };
|
| + xhr.send(formData);
|
| +}
|
| +firstTest();
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|