Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / post-with-boundary.html
blobdc80c8566956663b3743b95bc165882c9fe46c32
1 <body>
2 <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=40947">bug 40947</a>:
3 REGRESSION (r57544): XMLHttpRequest POSTed multipart/form-data wrongfully gets a charset appended.</p>
4 <p>There should be no charset added, and most importantly, it shouldn't be appended to the end.</p>
5 <script>
6 if (window.testRunner)
7 testRunner.dumpAsText();
9 var boundary = "----MISFormBoundaryMTCcH1pthhYPYEpV";
10 var contentType = "multipart/form-data; boundary=" + boundary;
11 var body = '';
12 body += '--' + boundary + '\r\n' + 'Content-Disposition: form-data; name="';
13 body += "data";
14 body += '"\r\n\r\n';
15 body += "foobar";
16 body += '\r\n'
17 body += '--' + boundary + '--';
19 var r = new XMLHttpRequest;
20 r.open("POST", "print-content-type.cgi", false);
21 r.setRequestHeader("Content-Type", contentType);
22 r.send(body);
23 var result = r.responseText.replace(/[\r\n]/g, "");
25 if (result == contentType)
26 document.write("PASS");
27 else
28 document.write("FAIL, Content-Type has been modified. Expected '" + contentType + "', got '" + result + "'.");
29 </script>