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

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

Issue 1358203003: Normalize and update the header value checks to RFC 7230 for Fetch Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
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'});
175 assert_equals(size(headers), 2, 'headers size should match'); 175 assert_equals(size(headers), 2, 'headers size should match');
176 assert_equals(headers.get('a'), 'b'); 176 assert_equals(headers.get('a'), 'b');
177 assert_equals(headers.get('c'), 'd'); 177 assert_equals(headers.get('c'), 'd');
178 178
179 // Tests for new valid Headers values.
tyoshino (SeeGerritForStatus) 2015/09/28 08:11:58 Tests for new Headers with valid values.
shiva.jm 2015/09/28 08:56:44 Done.
180 headers = new Headers();
181 headers.set('a', '\xd0\xa1');
tyoshino (SeeGerritForStatus) 2015/09/28 06:35:39 why is set() used for some of the and is append()
shiva.jm 2015/09/28 07:01:21 Normalizing and updating the header value checks a
tyoshino (SeeGerritForStatus) 2015/09/28 08:11:58 I see. It's good to check both. But when I read th
182 assert_equals(headers.get('a'), '\xd0\xa1');
183 headers.append('b', 't t');
184 assert_equals(headers.get('b'), 't t');
185 headers.append('c', 't\tt');
186 assert_equals(headers.get('c'), 't\tt');
187 headers.set('k', '');
188 assert_equals(headers.get('k'), '');
189 headers.append('l', ' ');
190 assert_equals(headers.get('l'), '');
191 headers.append('m', '\r\n\r\n\r\n');
192 assert_equals(headers.get('m'), '');
193
194 // Tests for normalizing header values.
195 headers.append('d', ' t');
196 assert_equals(headers.get('d'), 't');
197 headers.set('e', 't ');
198 assert_equals(headers.get('d'), 't');
tyoshino (SeeGerritForStatus) 2015/09/28 06:35:39 get('e')
shiva.jm 2015/09/28 07:01:21 Done.
199 headers.append('f', ' t ');
200 assert_equals(headers.get('f'), 't');
201 headers.append('g', 'test\r');
202 assert_equals(headers.get('g'), 'test');
203 headers.set('h', 'test\n');
204 assert_equals(headers.get('h'), 'test');
205 headers.append('i', 'test\r\n');
206 assert_equals(headers.get('i'), 'test');
207 headers.append('j', 'test\t');
208 assert_equals(headers.get('j'), 'test');
209
179 // Throw errors 210 // Throw errors
180 INVALID_HEADER_NAMES.forEach(function(name) { 211 INVALID_HEADER_NAMES.forEach(function(name) {
181 assert_throws({name: 'TypeError'}, 212 assert_throws({name: 'TypeError'},
182 function() { 213 function() {
183 var obj = {}; 214 var obj = {};
184 obj[name] = 'a'; 215 obj[name] = 'a';
185 var headers = new Headers(obj); 216 var headers = new Headers(obj);
186 }, 217 },
187 'new Headers with an invalid name (' + name + 218 'new Headers with an invalid name (' + name +
188 ') should throw'); 219 ') should throw');
(...skipping 26 matching lines...) Expand all
215 'new Headers with a sequence with less than two strings ' + 246 'new Headers with a sequence with less than two strings ' +
216 'should throw'); 247 'should throw');
217 assert_throws({name: 'TypeError'}, 248 assert_throws({name: 'TypeError'},
218 function() { var headers = new Headers([['a', 'b'], 249 function() { var headers = new Headers([['a', 'b'],
219 ['x', 'y', 'z']]); }, 250 ['x', 'y', 'z']]); },
220 'new Headers with a sequence with more than two strings ' + 251 'new Headers with a sequence with more than two strings ' +
221 'should throw'); 252 'should throw');
222 }, 'Headers'); 253 }, 'Headers');
223 254
224 done(); 255 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698