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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js

Issue 2559273005: [Fetch API] Implement combining of Headers with same keys. (Closed)
Patch Set: webkit layout test fix Created 4 years 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 | third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('../resources/fetch-test-helpers.js'); 2 importScripts('../resources/fetch-test-helpers.js');
3 } 3 }
4 4
5 test(function() { 5 test(function() {
6 var expectedValueMap = { 6 var expectedValueMap = {
7 'content-language': 'ja', 7 'content-language': 'ja',
8 'content-type': 'text/html; charset=UTF-8', 8 'content-type': 'text/html; charset=UTF-8',
9 'x-fetch-test': 'response test field' 9 'x-fetch-test': 'response test field'
10 }; 10 };
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 assert_equals(key, header[0]); 125 assert_equals(key, header[0]);
126 assert_equals(value, header[1]); 126 assert_equals(value, header[1]);
127 assert_equals(thisObject, this); 127 assert_equals(thisObject, this);
128 assert_equals(headersObject, headers); 128 assert_equals(headersObject, headers);
129 }, thisObject); 129 }, thisObject);
130 130
131 // 'append()', 'getAll()' 131 // 'append()', 'getAll()'
132 var allValues = headers.getAll('X-Fetch-Test'); 132 var allValues = headers.getAll('X-Fetch-Test');
133 assert_equals(allValues.length, 1); 133 assert_equals(allValues.length, 1);
134 assert_equals(size(headers), 4); 134 assert_equals(size(headers), 4);
135 headers.append('X-FETCH-TEST', 'response test field - append'); 135 headers.append('X-FETCH-TEST', 'response test field - append');
yhirano 2016/12/13 11:14:54 Can you append one another header (say X-FETCH-TES
136 assert_equals(size(headers), 5, 'headers size should increase by 1.'); 136 assert_equals(size(headers), 4, 'headers size should not increase by 1.');
137 assert_equals(headers.get('X-FETCH-Test'), 137 assert_equals(headers.get('X-FETCH-Test'),
138 'response test field - updated', 138 'response test field - updated',
139 'the value of the first header added should be returned.'); 139 'the value of the first header added should be returned.');
140 allValues = headers.getAll('X-FETch-TEST'); 140 allValues = headers.getAll('X-FETch-TEST');
141 assert_equals(allValues.length, 2); 141 assert_equals(allValues.length, 2);
142 assert_equals(allValues[0], 'response test field - updated'); 142 assert_equals(allValues[0], 'response test field - updated');
143 assert_equals(allValues[1], 'response test field - append'); 143 assert_equals(allValues[1], 'response test field - append');
144 headers.set('X-FETch-Test', 'response test field - set'); 144 headers.set('X-FETch-Test', 'response test field - set');
145 assert_equals(size(headers), 4, 'the second header should be deleted'); 145 assert_equals(size(headers), 4, 'the second header should be deleted');
146 allValues = headers.getAll('X-Fetch-Test'); 146 allValues = headers.getAll('X-Fetch-Test');
147 assert_equals(allValues.length, 1, 'the second header should be deleted'); 147 assert_equals(allValues.length, 1, 'the second header should be deleted');
148 assert_equals(allValues[0], 'response test field - set'); 148 assert_equals(allValues[0], 'response test field - set');
149 headers.append('X-Fetch-TEST', 'response test field - append'); 149 headers.append('X-Fetch-TEST', 'response test field - append');
150 assert_equals(size(headers), 5, 'headers size should increase by 1.'); 150 assert_equals(size(headers), 4, 'headers size should not increase by 1.');
151 headers.delete('X-FeTCH-Test'); 151 headers.delete('X-FeTCH-Test');
152 assert_equals(size(headers), 3, 'two headers should be deleted.'); 152 assert_equals(size(headers), 3, 'two headers should be deleted.');
153 153
154 // new Headers with sequence<sequence<ByteString>> 154 // new Headers with sequence<sequence<ByteString>>
155 headers = new Headers([['a', 'b'], ['c', 'd'], ['c', 'e']]); 155 headers = new Headers([['a', 'b'], ['c', 'd'], ['c', 'e']]);
156 assert_equals(size(headers), 3, 'headers size should match'); 156 assert_equals(size(headers), 2, 'headers size should match');
157 assert_equals(headers.get('a'), 'b'); 157 assert_equals(headers.get('a'), 'b');
158 assert_equals(headers.get('c'), 'd'); 158 assert_equals(headers.get('c'), 'd');
159 assert_equals(headers.getAll('c')[0], 'd'); 159 assert_equals(headers.getAll('c')[0], 'd');
160 assert_equals(headers.getAll('c')[1], 'e'); 160 assert_equals(headers.getAll('c')[1], 'e');
161 161
162 // new Headers with Headers 162 // new Headers with Headers
163 var headers2 = new Headers(headers); 163 var headers2 = new Headers(headers);
164 assert_equals(size(headers2), 3, 'headers size should match'); 164 assert_equals(size(headers2), 2, 'headers size should match');
165 assert_equals(headers2.get('a'), 'b'); 165 assert_equals(headers2.get('a'), 'b');
166 assert_equals(headers2.get('c'), 'd'); 166 assert_equals(headers2.get('c'), 'd');
167 assert_equals(headers2.getAll('c')[0], 'd'); 167 assert_equals(headers2.getAll('c')[0], 'd');
168 assert_equals(headers2.getAll('c')[1], 'e'); 168 assert_equals(headers2.getAll('c')[1], 'e');
169 headers.set('a', 'x'); 169 headers.set('a', 'x');
170 assert_equals(headers.get('a'), 'x'); 170 assert_equals(headers.get('a'), 'x');
171 assert_equals(headers2.get('a'), 'b'); 171 assert_equals(headers2.get('a'), 'b');
172 172
173 // new Headers with Dictionary 173 // new Headers with Dictionary
174 headers = new Headers({'a': 'b', 'c': 'd'}); 174 headers = new Headers({'a': 'b', 'c': 'd'});
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 keys.push(key); 232 keys.push(key);
233 assert_array_equals(keys, ['a', 'b', 'c'], 233 assert_array_equals(keys, ['a', 'b', 'c'],
234 'The pairs to iterate over should be sorted.'); 234 'The pairs to iterate over should be sorted.');
235 }, 'Iteration order'); 235 }, 'Iteration order');
236 236
237 test(function(t) { 237 test(function(t) {
238 const headers = new Headers; 238 const headers = new Headers;
239 headers.set('a', '1'); 239 headers.set('a', '1');
240 headers.set('b', '2'); 240 headers.set('b', '2');
241 headers.set('c', '3'); 241 headers.set('c', '3');
242 headers.append('a', '2');
243 headers.append('a', '3');
242 244
243 const iterator = headers.entries(); 245 const iterator = headers.entries();
244 246
245 headers.delete('a'); 247 headers.delete('a');
246 headers.set('d', '4'); 248 headers.set('d', '4');
247 249
248 const keys = []; 250 const keys = [];
249 for (let [key, value] of iterator) 251 const values = [];
252 for (let [key, value] of iterator) {
250 keys.push(key); 253 keys.push(key);
254 values.push(value);
255 }
251 assert_array_equals(keys, ['a', 'b', 'c'], 256 assert_array_equals(keys, ['a', 'b', 'c'],
252 'The pairs to iterate over should be the return ' + 257 'The pairs to iterate over should be the return ' +
253 'value of an algorithm that implicitly makes a copy.'); 258 'value of an algorithm that implicitly makes a copy.');
259 assert_array_equals(values, ['1,2,3', '2', '3'],
260 "The values should be combined and separated by ','.");
254 }, 'Iteration mutation'); 261 }, 'Iteration mutation');
255 262
256 done(); 263 done();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/fetch/FetchHeaderList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698