Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
|
esprehn
2013/11/04 19:28:08
We often omit the html, head and body elements.
pwnall-personal
2013/11/04 23:01:21
Done.
Also did this in the scripts around that I u
| |
| 4 <script src="/js-test-resources/js-test-pre.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script type="text/javascript"> | |
|
esprehn
2013/11/04 19:28:08
remove type attr
pwnall-personal
2013/11/04 23:01:21
Done.
| |
| 8 description("Test verifies that FormData is sent correctly when using " + | |
| 9 "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'> XMLHttpRequest asynchronously.</a>"); | |
| 10 | |
| 11 var xhrFormDataTestUrl = '/xmlhttprequest/resources/multipart-post-echo.php' ; | |
| 12 var xhrFormDataTestCases = [{ | |
| 13 data: { string: 'string value' }, | |
| 14 result: "string=string value" | |
| 15 }, { | |
| 16 data: { bareBlob: new Blob(['blob-value']) }, | |
| 17 result: 'bareBlob=blob:application/octet-stream:blob-value' | |
| 18 }, { | |
| 19 data: { mimeBlob: new Blob(['blob-value'], { type: 'text/html' }) }, | |
| 20 result: 'mimeBlob=blob:text/html:blob-value' | |
| 21 }, { | |
| 22 data: { | |
| 23 namedBlob: { | |
| 24 value: new Blob(['blob-value']), | |
| 25 fileName: 'blob-file.txt' | |
| 26 } | |
| 27 }, | |
| 28 result: 'namedBlob=blob-file.txt:application/octet-stream:blob-value' | |
| 29 }, { | |
| 30 data: { bareFile: new File(['file-value'], 'file-name.txt') }, | |
| 31 result: 'bareFile=file-name.txt:application/octet-stream:file-value' | |
| 32 }, { | |
| 33 data: { | |
| 34 mimeFile: new File(['file-value'], 'file-name.html', { type: 'text/h tml' }) | |
| 35 }, | |
| 36 result: 'mimeFile=file-name.html:text/html:file-value' | |
| 37 }, { | |
| 38 data: { | |
| 39 renamedFile: { | |
| 40 value: new File(['file-value'], 'file-name.html', { type: 'text/ html' }), | |
| 41 fileName: 'file-name-override.html' | |
| 42 } | |
| 43 }, | |
| 44 result: 'bareFile=file-name-override.html:text/html:file-value' | |
| 45 }]; | |
| 46 | |
| 47 var xhr; | |
| 48 var expectedMimeType; | |
| 49 window.jsTestIsAsync = true; | |
| 50 var asyncTestCase = 0; | |
| 51 | |
| 52 function runNextAsyncTest() { | |
| 53 asyncTestCase++; | |
| 54 runAsyncTests(); | |
| 55 } | |
| 56 | |
| 57 function reportResult(e) { | |
| 58 var testCase = xhrFormDataTestCases[asyncTestCase]; | |
| 59 if (xhr.status === 200) { | |
| 60 echoResult = xhr.response; | |
| 61 shouldBeEqualToString("echoResult", testCase.result); | |
| 62 } else { | |
| 63 testFailed("Unknown error"); | |
| 64 } | |
| 65 | |
| 66 runNextAsyncTest(); | |
| 67 } | |
| 68 | |
| 69 function runAsyncTests() { | |
| 70 if (asyncTestCase >= xhrFormDataTestCases.length) { | |
| 71 finishJSTest(); | |
| 72 return; | |
| 73 } else { | |
| 74 var testCase = xhrFormDataTestCases[asyncTestCase]; | |
| 75 var formData = new FormData(); | |
| 76 for (var fieldName in testCase.data) { | |
| 77 fieldValue = testCase.data[fieldName]; | |
| 78 if (fieldValue.constructor === Object) { | |
| 79 formData.append(fieldName, fieldValue.value, fieldValue.file Name); | |
| 80 } else { | |
| 81 formData.append(fieldName, fieldValue); | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 xhr = new XMLHttpRequest(); | |
| 86 xhr.onloadend = reportResult; | |
| 87 xhr.open("POST", xhrFormDataTestUrl, true); | |
| 88 xhr.send(formData); | |
| 89 } | |
| 90 } | |
| 91 | |
| 92 runAsyncTests(); | |
| 93 | |
| 94 </script> | |
| 95 </body> | |
| 96 </html> | |
| OLD | NEW |