Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html

Issue 609733004: FormData allow empty names to append (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added issue title in description Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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()");
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");
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');
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' );
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>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698