OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <body onload="runTest()"> | |
4 <script src="../../../../resources/js-test.js"></script> | |
5 <script> | |
6 description("Test that we can send empty name in Formdata."); | |
7 | |
8 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.
| |
9 var formDataString = new FormData(); | |
10 formDataString.append('', 'empty'); | |
11 formDataString.append('hello', 'world'); | |
12 var xhrString = new XMLHttpRequest(); | |
13 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/
| |
14 xhrString.send(formDataString); | |
15 if (xhrString.readyState !== 4 || xhrString.status !== 200) { | |
16 testFailed('xhrString.readyState = ' + xhrString.readyState + ', xhrStri ng.status = ' + xhrString.status); | |
17 return; | |
18 } | |
19 | |
20 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
| |
21 testPassed('the formdata of string type containing a empty name is echoe d correctly.'); | |
22 } else { | |
23 testFailed('the formdata of string type containing a empty name is not e choed correctly.'); | |
24 } | |
25 | |
26 if (xhrString.response.indexOf('name="hello"\r\n\r\nworld') >= 0) { | |
27 testPassed('the formdata of string type containing a name is echoed corr ectly.'); | |
28 } else { | |
29 testFailed('the formdata of string type containing a name is not echoed correctly.'); | |
30 } | |
31 | |
32 var formDataFile = new FormData(); | |
33 formDataFile.append('', new Blob(), 'empty-name.txt'); | |
34 formDataFile.append('testFile', new Blob(), 'custom-name.txt'); | |
35 var xhrFile = new XMLHttpRequest(); | |
36 xhrFile.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-ec ho.cgi', false); | |
37 xhrFile.send(formDataFile); | |
38 if (xhrFile.readyState !== 4 || xhrFile.status !== 200) { | |
39 testFailed('xhrFile.readyState = ' + xhrFile.readyState + ', xhrFile.sta tus = ' + xhrFile.status); | |
40 return; | |
41 } | |
42 | |
43 if (xhrFile.response.indexOf('name=""; filename="empty-name.txt"') >= 0) { | |
44 testPassed('the formdata of file type containing a empty name is echoed correctly.'); | |
45 } else { | |
46 testFailed('the formdata of file type containing a empty name is not ech oed correctly.'); | |
47 } | |
48 | |
49 if (xhrFile.response.indexOf('name="testFile"; filename="custom-name.txt"') >= 0) { | |
50 testPassed('the formdata of file type containing a name is echoed correc tly.'); | |
51 } else { | |
52 testFailed('the formdata of file type containing a name is not echoed co rrectly.'); | |
53 } | |
54 } | |
55 </script> | |
56 </body> | |
57 </html> | |
OLD | NEW |