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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 .then(function() { | 675 .then(function() { |
676 t.done(); | 676 t.done(); |
677 }) | 677 }) |
678 .catch(unreached_rejection(t)); | 678 .catch(unreached_rejection(t)); |
679 assert_true(request.bodyUsed, | 679 assert_true(request.bodyUsed, |
680 'bodyUsed must be true after calling text()'); | 680 'bodyUsed must be true after calling text()'); |
681 }, 'Request body test'); | 681 }, 'Request body test'); |
682 | 682 |
683 test(function() { | 683 test(function() { |
684 // https://fetch.spec.whatwg.org/#dom-request | 684 // https://fetch.spec.whatwg.org/#dom-request |
685 // Step 20: | 685 // Step 32: |
686 // Fill r's Headers object with headers. Rethrow any exceptions. | 686 // Fill r's Headers object with headers. Rethrow any exceptions. |
687 INVALID_HEADER_NAMES.forEach(function(name) { | 687 INVALID_HEADER_NAMES.forEach(function(name) { |
688 assert_throws( | 688 assert_throws( |
689 {name: 'TypeError'}, | 689 {name: 'TypeError'}, |
690 function() { | 690 function() { |
691 var obj = {}; | 691 var obj = {}; |
692 obj[name] = 'a'; | 692 obj[name] = 'a'; |
693 new Request('http://localhost/', {headers: obj}); | 693 new Request('http://localhost/', {headers: obj}); |
694 }, | 694 }, |
695 'new Request with headers with an invalid name (' + name + | 695 'new Request with headers with an invalid name (' + name + |
(...skipping 117 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 |