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 var URL = 'https://www.example.com/test.html'; | 5 var URL = 'https://www.example.com/test.html'; |
6 | 6 |
7 test(function() { | 7 test(function() { |
8 var headers = new Headers; | 8 var headers = new Headers; |
9 headers.set('User-Agent', 'Mozilla/5.0'); | 9 headers.set('User-Agent', 'Mozilla/5.0'); |
10 headers.set('Accept', 'text/html'); | 10 headers.set('Accept', 'text/html'); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 242 } |
243 request2 = new Request(request1, init2); | 243 request2 = new Request(request1, init2); |
244 assert_equals(request2.redirect, | 244 assert_equals(request2.redirect, |
245 redirect2 ? redirect2 : request1.redirect, | 245 redirect2 ? redirect2 : request1.redirect, |
246 'Request.redirect should be overridden'); | 246 'Request.redirect should be overridden'); |
247 }); | 247 }); |
248 }); | 248 }); |
249 }, 'Request redirect test'); | 249 }, 'Request redirect test'); |
250 | 250 |
251 test(function() { | 251 test(function() { |
| 252 var request1 = {}; |
| 253 var request2 = {}; |
| 254 var init = {}; |
| 255 request1 = new Request(URL, init); |
| 256 assert_equals(request1.integrity, '', |
| 257 'Request.integrity should be empty on init'); |
| 258 init['integrity'] = 'sha256-deadbeef'; |
| 259 request1 = new Request(URL, init); |
| 260 assert_equals(request1.integrity, 'sha256-deadbeef', |
| 261 'Request.integrity match the integrity of init'); |
| 262 request2 = new Request(request1); |
| 263 assert_equals(request2.integrity, 'sha256-deadbeef', |
| 264 'Request.integrity should match'); |
| 265 init['mode'] = 'no-cors'; |
| 266 assert_throws( |
| 267 {name: 'TypeError'}, |
| 268 function() { |
| 269 var request = new Request(URL, init); |
| 270 }, |
| 271 'new Request with a non-empty integrity and mode of \'no-cors\' should t
hrow'); |
| 272 }, 'Request integrity test'); |
| 273 |
| 274 test(function() { |
252 ['same-origin', 'cors', 'no-cors'].forEach(function(mode) { | 275 ['same-origin', 'cors', 'no-cors'].forEach(function(mode) { |
253 FORBIDDEN_METHODS.forEach(function(method) { | 276 FORBIDDEN_METHODS.forEach(function(method) { |
254 assert_throws( | 277 assert_throws( |
255 {name: 'TypeError'}, | 278 {name: 'TypeError'}, |
256 function() { | 279 function() { |
257 var request = new Request(URL, {mode: mode, method: method}); | 280 var request = new Request(URL, {mode: mode, method: method}); |
258 }, | 281 }, |
259 'new Request with a forbidden method (' + method + ') should ' + | 282 'new Request with a forbidden method (' + method + ') should ' + |
260 'throw'); | 283 'throw'); |
261 }); | 284 }); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 | 661 |
639 // Tests for requests context. | 662 // Tests for requests context. |
640 test(function() { | 663 test(function() { |
641 var request = new Request('http://localhost/', {method: 'POST', body: ''}); | 664 var request = new Request('http://localhost/', {method: 'POST', body: ''}); |
642 assert_equals(request.context, '', | 665 assert_equals(request.context, '', |
643 'Request.context should be empty string ' + | 666 'Request.context should be empty string ' + |
644 'for synthetic Request object'); | 667 'for synthetic Request object'); |
645 }, 'RequestContext of a synthetic Request object'); | 668 }, 'RequestContext of a synthetic Request object'); |
646 | 669 |
647 done(); | 670 done(); |
OLD | NEW |