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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 215 } |
216 request2 = new Request(request1, init2); | 216 request2 = new Request(request1, init2); |
217 assert_equals(request2.credentials, | 217 assert_equals(request2.credentials, |
218 credentials2 ? credentials2 : request1.credentials, | 218 credentials2 ? credentials2 : request1.credentials, |
219 'Request.credentials should be overridden'); | 219 'Request.credentials should be overridden'); |
220 }); | 220 }); |
221 }); | 221 }); |
222 }, 'Request credentials test'); | 222 }, 'Request credentials test'); |
223 | 223 |
224 test(function() { | 224 test(function() { |
| 225 var request1 = {}; |
| 226 var request2 = {}; |
| 227 var REDIRECTS = ['follow', 'error', 'manual', '', undefined]; |
| 228 REDIRECTS.forEach(function(redirect1) { |
| 229 var init1 = {}; |
| 230 if (redirect1 != undefined) { init1['redirect'] = redirect1; } |
| 231 request1 = new Request(URL, init1); |
| 232 assert_equals(request1.redirect, redirect1 || 'follow', |
| 233 'Request.redirect should match'); |
| 234 request1 = new Request(request1); |
| 235 assert_equals(request1.redirect, redirect1 || 'follow', |
| 236 'Request.redirect should match'); |
| 237 REDIRECTS.forEach(function(redirect2) { |
| 238 request1 = new Request(URL, init1); |
| 239 var init2 = {}; |
| 240 if (redirect2 != undefined) { |
| 241 init2['redirect'] = redirect2; |
| 242 } |
| 243 request2 = new Request(request1, init2); |
| 244 assert_equals(request2.redirect, |
| 245 redirect2 ? redirect2 : request1.redirect, |
| 246 'Request.redirect should be overridden'); |
| 247 }); |
| 248 }); |
| 249 }, 'Request redirect test'); |
| 250 |
| 251 test(function() { |
225 ['same-origin', 'cors', 'no-cors'].forEach(function(mode) { | 252 ['same-origin', 'cors', 'no-cors'].forEach(function(mode) { |
226 FORBIDDEN_METHODS.forEach(function(method) { | 253 FORBIDDEN_METHODS.forEach(function(method) { |
227 assert_throws( | 254 assert_throws( |
228 {name: 'TypeError'}, | 255 {name: 'TypeError'}, |
229 function() { | 256 function() { |
230 var request = new Request(URL, {mode: mode, method: method}); | 257 var request = new Request(URL, {mode: mode, method: method}); |
231 }, | 258 }, |
232 'new Request with a forbidden method (' + method + ') should ' + | 259 'new Request with a forbidden method (' + method + ') should ' + |
233 'throw'); | 260 'throw'); |
234 }); | 261 }); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 638 |
612 // Tests for requests context. | 639 // Tests for requests context. |
613 test(function() { | 640 test(function() { |
614 var request = new Request('http://localhost/', {method: 'POST', body: ''}); | 641 var request = new Request('http://localhost/', {method: 'POST', body: ''}); |
615 assert_equals(request.context, '', | 642 assert_equals(request.context, '', |
616 'Request.context should be empty string ' + | 643 'Request.context should be empty string ' + |
617 'for synthetic Request object'); | 644 'for synthetic Request object'); |
618 }, 'RequestContext of a synthetic Request object'); | 645 }, 'RequestContext of a synthetic Request object'); |
619 | 646 |
620 done(); | 647 done(); |
OLD | NEW |