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

Side by Side Diff: LayoutTests/http/tests/xmlhttprequest/post-formdata.html

Issue 157363003: Implement Blob.close(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Avoid warning from PHP's fread() on empty reads Created 6 years, 10 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 2
3 <script src="/js-test-resources/js-test.js"></script> 3 <script src="/js-test-resources/js-test.js"></script>
4 <script> 4 <script>
5 description("Test verifies that FormData is sent correctly when using " + 5 description("Test verifies that FormData is sent correctly when using " +
6 "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLH ttpRequest asynchronously.</a>"); 6 "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLH ttpRequest asynchronously.</a>");
7 7
8 var xhrFormDataTestUrl = '/xmlhttprequest/resources/multipart-post-echo.php'; 8 var xhrFormDataTestUrl = '/xmlhttprequest/resources/multipart-post-echo.php';
9 var xhrFormDataTestCases = [{ 9 var xhrFormDataTestCases = [{
10 data: { string: 'string value' }, 10 data: { string: 'string value' },
11 result: "string=string value" 11 result: "string=string value"
12 }, { 12 }, {
13 data: { bareBlob: new Blob(['blob-value']) }, 13 data: { bareBlob: new Blob(['blob-value']) },
14 result: 'bareBlob=blob:application/octet-stream:blob-value' 14 result: 'bareBlob=blob:application/octet-stream:blob-value'
15 }, { 15 }, {
16 data: { bareBlob: new Blob(['blob-value']) },
17 beforeConstruct: function (t) { t.data.bareBlob.close(); },
18 result: 'bareBlob=blob:application/octet-stream:'
19 }, {
20 data: { bareBlob: new Blob(['blob-value']) },
21 beforeSend: function (t) { t.data.bareBlob.close(); },
22 result: 'bareBlob=blob:application/octet-stream:'
23 }, {
16 data: { mimeBlob: new Blob(['blob-value'], { type: 'text/html' }) }, 24 data: { mimeBlob: new Blob(['blob-value'], { type: 'text/html' }) },
17 result: 'mimeBlob=blob:text/html:blob-value' 25 result: 'mimeBlob=blob:text/html:blob-value'
18 }, { 26 }, {
19 data: { 27 data: {
20 namedBlob: { 28 namedBlob: {
21 value: new Blob(['blob-value']), 29 value: new Blob(['blob-value']),
22 fileName: 'blob-file.txt' 30 fileName: 'blob-file.txt'
23 } 31 }
24 }, 32 },
25 result: 'namedBlob=blob-file.txt:application/octet-stream:blob-value' 33 result: 'namedBlob=blob-file.txt:application/octet-stream:blob-value'
26 }, { 34 }, {
27 data: { bareFile: new File(['file-value'], 'file-name.txt') }, 35 data: { bareFile: new File(['file-value'], 'file-name.txt') },
28 result: 'bareFile=file-name.txt:application/octet-stream:file-value' 36 result: 'bareFile=file-name.txt:application/octet-stream:file-value'
29 }, { 37 }, {
38 data: { bareFile: new File(['file-value'], 'file-name.txt') },
39 beforeConstruct: function (t) { t.data.bareFile.close(); },
40 result: 'bareFile=file-name.txt:application/octet-stream:'
41 }, {
42 data: { bareFile: new File(['file-value'], 'file-name.txt') },
43 beforeSend: function (t) { t.data.bareFile.close(); },
44 result: 'bareFile=file-name.txt:application/octet-stream:'
45 }, {
30 data: { 46 data: {
31 mimeFile: new File(['file-value'], 'file-name.html', { type: 'text/html' }) 47 mimeFile: new File(['file-value'], 'file-name.html', { type: 'text/html' })
32 }, 48 },
33 result: 'mimeFile=file-name.html:text/html:file-value' 49 result: 'mimeFile=file-name.html:text/html:file-value'
34 }, { 50 }, {
35 data: { 51 data: {
36 renamedFile: { 52 renamedFile: {
37 value: new File(['file-value'], 'file-name.html', { type: 'text/html ' }), 53 value: new File(['file-value'], 'file-name.html', { type: 'text/html ' }),
38 fileName: 'file-name-override.html' 54 fileName: 'file-name-override.html'
39 } 55 }
(...skipping 24 matching lines...) Expand all
64 } 80 }
65 81
66 function runAsyncTests() { 82 function runAsyncTests() {
67 if (asyncTestCase >= xhrFormDataTestCases.length) { 83 if (asyncTestCase >= xhrFormDataTestCases.length) {
68 finishJSTest(); 84 finishJSTest();
69 return; 85 return;
70 } 86 }
71 87
72 var testCase = xhrFormDataTestCases[asyncTestCase]; 88 var testCase = xhrFormDataTestCases[asyncTestCase];
73 var formData = new FormData(); 89 var formData = new FormData();
90 if (testCase.beforeConstruct)
91 testCase.beforeConstruct(testCase);
74 for (var fieldName in testCase.data) { 92 for (var fieldName in testCase.data) {
75 fieldValue = testCase.data[fieldName]; 93 fieldValue = testCase.data[fieldName];
76 if (fieldValue.constructor === Object) 94 if (fieldValue.constructor === Object)
77 formData.append(fieldName, fieldValue.value, fieldValue.fileName); 95 formData.append(fieldName, fieldValue.value, fieldValue.fileName);
78 else 96 else
79 formData.append(fieldName, fieldValue); 97 formData.append(fieldName, fieldValue);
80 } 98 }
81 99
82 xhr = new XMLHttpRequest(); 100 xhr = new XMLHttpRequest();
83 xhr.onloadend = reportResult; 101 xhr.onloadend = reportResult;
84 xhr.open("POST", xhrFormDataTestUrl, true); 102 xhr.open("POST", xhrFormDataTestUrl, true);
103 if (testCase.beforeSend)
104 testCase.beforeSend(testCase);
85 xhr.send(formData); 105 xhr.send(formData);
86 } 106 }
87 107
88 runAsyncTests(); 108 runAsyncTests();
89 </script> 109 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698