 Chromium Code Reviews
 Chromium Code Reviews Issue 609733004:
  FormData allow empty names to append  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 609733004:
  FormData allow empty names to append  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| 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..7fc71e04bea4965c66b0fcbe8c751d7bd679aebb | 
| --- /dev/null | 
| +++ b/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html | 
| @@ -0,0 +1,57 @@ | 
| +<!DOCTYPE html> | 
| +<html> | 
| +<body onload="runTest()"> | 
| +<script src="../../../../resources/js-test.js"></script> | 
| +<script> | 
| +description("Test that we can send empty name in Formdata."); | 
| + | 
| +function runTest() { | 
| 
jsbell
2014/09/26 16:19:19
Since this all runs synchronously I don't think it
 
prashant.hiremath
2014/09/26 18:08:11
Done.
 | 
| + var formDataString = new FormData(); | 
| + formDataString.append('', 'empty'); | 
| + formDataString.append('hello', 'world'); | 
| + var xhrString = new XMLHttpRequest(); | 
| + xhrString.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi', false); | 
| 
sof
2014/10/06 09:12:34
Could you make this be async instead (here and bel
 
prashant.hiremath
2014/10/06 12:31:59
Actually initially itself I tried making it async,
 
sof
2014/10/06 14:46:48
Sure, fast and stable tests are definitely to be p
 
prashant.hiremath
2014/10/09 10:58:45
I tried giving directly /xmlhttprequest/resources/
 | 
| + xhrString.send(formDataString); | 
| + if (xhrString.readyState !== 4 || xhrString.status !== 200) { | 
| + testFailed('xhrString.readyState = ' + xhrString.readyState + ', xhrString.status = ' + xhrString.status); | 
| + return; | 
| + } | 
| + | 
| + if (xhrString.response.indexOf('name=""\r\n\r\nempty') >= 0) { | 
| 
jsbell
2014/09/26 16:19:18
Can you extract this if (s.indexOf(ss)) { testPass
 
prashant.hiremath
2014/09/26 18:08:11
One samall doubt, Do you mean to write helper fn f
 | 
| + testPassed('the formdata of string type containing a empty name is echoed correctly.'); | 
| + } else { | 
| + testFailed('the formdata of string type containing a empty name is not echoed correctly.'); | 
| + } | 
| + | 
| + if (xhrString.response.indexOf('name="hello"\r\n\r\nworld') >= 0) { | 
| + testPassed('the formdata of string type containing a name is echoed correctly.'); | 
| + } else { | 
| + testFailed('the formdata of string type containing a name is not echoed correctly.'); | 
| + } | 
| + | 
| + var formDataFile = new FormData(); | 
| + formDataFile.append('', new Blob(), 'empty-name.txt'); | 
| + formDataFile.append('testFile', new Blob(), 'custom-name.txt'); | 
| + var xhrFile = new XMLHttpRequest(); | 
| + xhrFile.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi', false); | 
| + xhrFile.send(formDataFile); | 
| + if (xhrFile.readyState !== 4 || xhrFile.status !== 200) { | 
| + testFailed('xhrFile.readyState = ' + xhrFile.readyState + ', xhrFile.status = ' + xhrFile.status); | 
| + return; | 
| + } | 
| + | 
| + if (xhrFile.response.indexOf('name=""; filename="empty-name.txt"') >= 0) { | 
| + testPassed('the formdata of file type containing a empty name is echoed correctly.'); | 
| + } else { | 
| + testFailed('the formdata of file type containing a empty name is not echoed correctly.'); | 
| + } | 
| + | 
| + if (xhrFile.response.indexOf('name="testFile"; filename="custom-name.txt"') >= 0) { | 
| + testPassed('the formdata of file type containing a name is echoed correctly.'); | 
| + } else { | 
| + testFailed('the formdata of file type containing a name is not echoed correctly.'); | 
| + } | 
| +} | 
| +</script> | 
| +</body> | 
| +</html> |