OLD | NEW |
---|---|
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 Loading... | |
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 // new valid Headers values | |
180 headers = new Headers(); | |
181 headers.set('a', '\xd0\xa1'); | |
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 | |
188 // test for removing leading and trailing white spaces | |
hiroshige
2015/09/09 07:01:48
nit: How about "Tests for normalizing header value
shiva.jm
2015/09/10 10:10:26
Done.
| |
189 headers.append('d', ' t'); | |
190 assert_equals(headers.get('d'), 't'); | |
191 headers.set('e', 't '); | |
192 assert_equals(headers.get('d'), 't'); | |
193 headers.append('f', ' t '); | |
194 assert_equals(headers.get('f'), 't'); | |
195 headers.append('g', 'test\r'); | |
196 assert_equals(headers.get('g'), 'test'); | |
197 headers.set('h', 'test\n'); | |
198 assert_equals(headers.get('h'), 'test'); | |
199 headers.append('i', 'test\r\n'); | |
200 assert_equals(headers.get('i'), 'test'); | |
201 headers.append('j', 'test\t'); | |
202 assert_equals(headers.get('j'), 'test'); | |
203 | |
179 // Throw errors | 204 // Throw errors |
180 INVALID_HEADER_NAMES.forEach(function(name) { | 205 INVALID_HEADER_NAMES.forEach(function(name) { |
181 assert_throws({name: 'TypeError'}, | 206 assert_throws({name: 'TypeError'}, |
182 function() { | 207 function() { |
183 var obj = {}; | 208 var obj = {}; |
184 obj[name] = 'a'; | 209 obj[name] = 'a'; |
185 var headers = new Headers(obj); | 210 var headers = new Headers(obj); |
186 }, | 211 }, |
187 'new Headers with an invalid name (' + name + | 212 'new Headers with an invalid name (' + name + |
188 ') should throw'); | 213 ') should throw'); |
(...skipping 26 matching lines...) Expand all Loading... | |
215 'new Headers with a sequence with less than two strings ' + | 240 'new Headers with a sequence with less than two strings ' + |
216 'should throw'); | 241 'should throw'); |
217 assert_throws({name: 'TypeError'}, | 242 assert_throws({name: 'TypeError'}, |
218 function() { var headers = new Headers([['a', 'b'], | 243 function() { var headers = new Headers([['a', 'b'], |
219 ['x', 'y', 'z']]); }, | 244 ['x', 'y', 'z']]); }, |
220 'new Headers with a sequence with more than two strings ' + | 245 'new Headers with a sequence with more than two strings ' + |
221 'should throw'); | 246 'should throw'); |
222 }, 'Headers'); | 247 }, 'Headers'); |
223 | 248 |
224 done(); | 249 done(); |
OLD | NEW |