Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <body> | |
| 4 <script src="../../../../resources/js-test.js"></script> | |
| 5 <script> | |
| 6 description("Test that we can send empty name in Formdata.append()"); | |
|
sof
2014/10/10 12:43:39
Formdata => FormData
| |
| 7 | |
| 8 self.jsTestIsAsync = true; | |
| 9 | |
| 10 function shouldContain(string, substring, message) { | |
| 11 if (string.indexOf(substring) >= 0) | |
| 12 testPassed(message); | |
| 13 else | |
| 14 testFailed("the Formdata containing" + substring + " failed to echo corr ectly"); | |
|
sof
2014/10/10 12:43:39
Formdata => FormData
| |
| 15 } | |
| 16 | |
| 17 function firstTest() { | |
| 18 var formData = new FormData(); | |
| 19 formData.append('', 'empty'); | |
| 20 formData.append('hello', 'world'); | |
| 21 var xhr = new XMLHttpRequest(); | |
| 22 xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.c gi', true); | |
| 23 xhr.onload = function() { | |
| 24 shouldContain(xhr.response, 'name=""\r\n\r\nempty', | |
| 25 'the formdata of string type containing a empty name echoed correctl y'); | |
|
sof
2014/10/10 12:43:38
formdata => FormData (same for later occurrences o
| |
| 26 shouldContain(xhr.response, 'name="hello"\r\n\r\nworld', | |
| 27 'the formdata of string type containing a name echoed correctly'); | |
| 28 secondTest(); | |
| 29 }; | |
| 30 xhr.send(formData); | |
| 31 } | |
| 32 | |
| 33 function secondTest() { | |
| 34 var formData = new FormData(); | |
| 35 formData.append('', new Blob(), 'empty-name.txt'); | |
| 36 formData.append('testFile', new Blob(), 'custom-name.txt'); | |
| 37 var xhr = new XMLHttpRequest(); | |
| 38 xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.c gi', true); | |
| 39 xhr.onload = function() { | |
| 40 shouldContain(xhr.response, 'name=""; filename="empty-name.txt"', | |
| 41 'the formdata of file type containing a empty name echoed correctly. '); | |
|
sof
2014/10/10 12:43:39
Remove final "." for consistency.
| |
| 42 shouldContain(xhr.response, 'name="testFile"; filename="custom-name.txt" ', | |
| 43 'the formdata of file type containing a name echoed correctly.'); | |
| 44 finishJSTest(); | |
| 45 }; | |
| 46 xhr.send(formData); | |
| 47 } | |
| 48 firstTest(); | |
| 49 </script> | |
| 50 </body> | |
| 51 </html> | |
| OLD | NEW |