Chromium Code Reviews| 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..ae67eab991f4ef82175ce05ed4bb7d5c7d982fc2 |
| --- /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()"); |
|
sof
2014/10/10 12:43:39
Formdata => FormData
|
| + |
| +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"); |
|
sof
2014/10/10 12:43:39
Formdata => FormData
|
| +} |
| + |
| +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'); |
|
sof
2014/10/10 12:43:38
formdata => FormData (same for later occurrences o
|
| + 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.'); |
|
sof
2014/10/10 12:43:39
Remove final "." for consistency.
|
| + 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> |