| 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 function size(headers) { | 7 function size(headers) { |
| 8 var count = 0; | 8 var count = 0; |
| 9 for (var header of headers) { | 9 for (var header of headers) { |
| 10 ++count; | 10 ++count; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 'Request should not be flagged as used if it has not been ' + | 377 'Request should not be flagged as used if it has not been ' + |
| 378 'consumed.'); | 378 'consumed.'); |
| 379 assert_throws(new TypeError(), function() { new Request(req); }, | 379 assert_throws(new TypeError(), function() { new Request(req); }, |
| 380 'Request cannot be constructed with a request that has ' + | 380 'Request cannot be constructed with a request that has ' + |
| 381 'been flagged as used.'); | 381 'been flagged as used.'); |
| 382 assert_throws(new TypeError(), function() { req.clone(); }, | 382 assert_throws(new TypeError(), function() { req.clone(); }, |
| 383 'Request.clone: If used flag is set, throw a TypeError.'); | 383 'Request.clone: If used flag is set, throw a TypeError.'); |
| 384 }, | 384 }, |
| 385 'Request construction behavior regarding "used" body flag and exceptions.'); | 385 'Request construction behavior regarding "used" body flag and exceptions.'); |
| 386 | 386 |
| 387 |
| 388 // Spec: https://fetch.spec.whatwg.org/#dom-request |
| 389 // Step 21: |
| 390 // If request's method is `GET` or `HEAD`, throw a TypeError. |
| 391 promise_test(function() { |
| 392 var headers = new Headers; |
| 393 headers.set('Content-Language', 'ja'); |
| 394 ['GET', 'HEAD'].forEach(function(method) { |
| 395 assert_throws( |
| 396 {name: 'TypeError'}, |
| 397 function() { |
| 398 new Request(URL, |
| 399 {method: method, |
| 400 body: new Blob(['Test Blob'], {type: 'test/type'}) |
| 401 }); |
| 402 }, |
| 403 'Request of GET/HEAD method cannot have RequestInit body.'); |
| 404 }); |
| 405 }, 'Request of GET/HEAD method cannot have RequestInit body.'); |
| 406 |
| 387 promise_test(function() { | 407 promise_test(function() { |
| 388 var headers = new Headers; | 408 var headers = new Headers; |
| 389 headers.set('Content-Language', 'ja'); | 409 headers.set('Content-Language', 'ja'); |
| 390 var req = new Request(URL, { | 410 var req = new Request(URL, { |
| 391 method: 'GET', | 411 method: 'POST', |
| 392 headers: headers, | 412 headers: headers, |
| 393 body: new Blob(['Test Blob'], {type: 'test/type'}) | 413 body: new Blob(['Test Blob'], {type: 'test/type'}) |
| 394 }); | 414 }); |
| 395 var req2 = req.clone(); | 415 var req2 = req.clone(); |
| 396 // Change headers and of original request. | 416 // Change headers and of original request. |
| 397 req.headers.set('Content-Language', 'en'); | 417 req.headers.set('Content-Language', 'en'); |
| 398 assert_equals(req2.headers.get('Content-Language'), 'ja', | 418 assert_equals(req2.headers.get('Content-Language'), 'ja', |
| 399 'Headers of cloned request should not change when ' + | 419 'Headers of cloned request should not change when ' + |
| 400 'original request headers are changed.'); | 420 'original request headers are changed.'); |
| 401 | 421 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 {name: 'TypeError'}, | 568 {name: 'TypeError'}, |
| 549 function() { | 569 function() { |
| 550 new Request('http://localhost/', | 570 new Request('http://localhost/', |
| 551 {headers: [['X-Fetch-Test', value]]}); | 571 {headers: [['X-Fetch-Test', value]]}); |
| 552 }, | 572 }, |
| 553 'new Request with headers with an invalid value should throw'); | 573 'new Request with headers with an invalid value should throw'); |
| 554 }); | 574 }); |
| 555 }, 'Request throw error test'); | 575 }, 'Request throw error test'); |
| 556 | 576 |
| 557 done(); | 577 done(); |
| OLD | NEW |