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

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

Issue 2542073005: Sort headers for iteration (Closed)
Patch Set: No WPTServe = these two still fail 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
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 function() { var headers = new Headers([['a', 'b'], []]); }, 214 function() { var headers = new Headers([['a', 'b'], []]); },
215 'new Headers with a sequence with less than two strings ' + 215 'new Headers with a sequence with less than two strings ' +
216 'should throw'); 216 'should throw');
217 assert_throws({name: 'TypeError'}, 217 assert_throws({name: 'TypeError'},
218 function() { var headers = new Headers([['a', 'b'], 218 function() { var headers = new Headers([['a', 'b'],
219 ['x', 'y', 'z']]); }, 219 ['x', 'y', 'z']]); },
220 'new Headers with a sequence with more than two strings ' + 220 'new Headers with a sequence with more than two strings ' +
221 'should throw'); 221 'should throw');
222 }, 'Headers'); 222 }, 'Headers');
223 223
224 test(function(t) {
225 var headers = new Headers;
yhirano 2016/12/02 01:57:07 [optional] I prefer |const| / |let| to |var|.
jsbell 2016/12/02 17:03:49 Done.
226 headers.set('b', '1');
227 headers.set('c', '2');
228 headers.set('a', '3');
229
230 var keys = [];
231 for (var [key, value] of headers)
232 keys.push(key);
233 assert_array_equals(keys, ['a', 'b', 'c'],
234 'The pairs to iterate over should be sorted.');
235 }, 'Iteration order');
236
237 test(function(t) {
238 var headers = new Headers;
239 headers.set('a', '1');
240 headers.set('b', '2');
241 headers.set('c', '3');
242
243 var iterator = headers.entries();
244
245 headers.delete('a');
246 headers.set('d', '4');
247
248 var keys = [];
249 for (var [key, value] of iterator)
250 keys.push(key);
251 assert_array_equals(keys, ['a', 'b', 'c'],
252 'The pairs to iterate over should be the return ' +
253 'value of an algorithm that implicitly makes a copy.');
254 }, 'Iteration mutation');
255
224 done(); 256 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698