| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 assert_equals(request2.method, | 191 assert_equals(request2.method, |
| 192 method2 ? method2 : request1.method, | 192 method2 ? method2 : request1.method, |
| 193 'Request.method should be overridden'); | 193 'Request.method should be overridden'); |
| 194 assert_equals(request2.mode, | 194 assert_equals(request2.mode, |
| 195 mode2 ? mode2 : request1.mode, | 195 mode2 ? mode2 : request1.mode, |
| 196 'Request.mode should be overridden'); | 196 'Request.mode should be overridden'); |
| 197 }); | 197 }); |
| 198 }); | 198 }); |
| 199 }); | 199 }); |
| 200 }); | 200 }); |
| 201 }, 'Request header test'); | 201 }, 'Request method test'); |
| 202 | 202 |
| 203 test(function() { | 203 test(function() { |
| 204 var request1 = {}; | 204 var request1 = {}; |
| 205 var request2 = {}; | 205 var request2 = {}; |
| 206 var CREDENTIALS = ['omit', 'same-origin', 'include', '', undefined]; | 206 var CREDENTIALS = ['omit', 'same-origin', 'include', '', undefined]; |
| 207 CREDENTIALS.forEach(function(credentials1) { | 207 CREDENTIALS.forEach(function(credentials1) { |
| 208 var init1 = {}; | 208 var init1 = {}; |
| 209 if (credentials1 != undefined) { init1['credentials'] = credentials1; } | 209 if (credentials1 != undefined) { init1['credentials'] = credentials1; } |
| 210 request1 = new Request(URL, init1); | 210 request1 = new Request(URL, init1); |
| 211 assert_equals(request1.credentials, credentials1 || 'omit', | 211 assert_equals(request1.credentials, credentials1 || 'omit', |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 assert_true(req.bodyUsed, | 364 assert_true(req.bodyUsed, |
| 365 'Request should be flagged as used if it has been consumed.'); | 365 'Request should be flagged as used if it has been consumed.'); |
| 366 assert_false(req2.bodyUsed, | 366 assert_false(req2.bodyUsed, |
| 367 'Request should not be flagged as used if it has not been ' + | 367 'Request should not be flagged as used if it has not been ' + |
| 368 'consumed.'); | 368 'consumed.'); |
| 369 // See https://crbug.com/501195. | 369 // See https://crbug.com/501195. |
| 370 assert_throws( | 370 assert_throws( |
| 371 {name: 'TypeError'}, | 371 {name: 'TypeError'}, |
| 372 function() { new Request(req); }, | 372 function() { new Request(req); }, |
| 373 'Request construction should throw if used.'); | 373 'Request construction should throw if used.'); |
| 374 }, 'Request construction without body behavior regardning "bodyUsed"'); | 374 }, 'POST Request construction without body behavior regardning "bodyUsed"'); |
| 375 | 375 |
| 376 test(function() { | 376 test(function() { |
| 377 var req = new Request(URL, {method: 'POST', body: 'hello'}); | 377 var req = new Request(URL, {method: 'POST', body: 'hello'}); |
| 378 assert_false(req.bodyUsed, | 378 assert_false(req.bodyUsed, |
| 379 'Request should not be flagged as used if it has not been ' + | 379 'Request should not be flagged as used if it has not been ' + |
| 380 'consumed.'); | 380 'consumed.'); |
| 381 assert_throws( | 381 assert_throws( |
| 382 {name: 'TypeError'}, | 382 {name: 'TypeError'}, |
| 383 function() { new Request(req, {method: 'GET'}); }, | 383 function() { new Request(req, {method: 'GET'}); }, |
| 384 'A get request may not have body.'); | 384 'A get request may not have body.'); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 credentials: 'include', | 813 credentials: 'include', |
| 814 body: 'this is a body'}); | 814 body: 'this is a body'}); |
| 815 | 815 |
| 816 return req.text() | 816 return req.text() |
| 817 .then(t => { | 817 .then(t => { |
| 818 assert_equals(t, 'this is a body'); | 818 assert_equals(t, 'this is a body'); |
| 819 }); | 819 }); |
| 820 }, 'Credentials and body can both be set.'); | 820 }, 'Credentials and body can both be set.'); |
| 821 | 821 |
| 822 done(); | 822 done(); |
| OLD | NEW |