| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 'filename="file.dat"\r\n' + | 588 'filename="file.dat"\r\n' + |
| 589 'Content-Type: application/octet-stream\r\n' + | 589 'Content-Type: application/octet-stream\r\n' + |
| 590 '\r\n' + | 590 '\r\n' + |
| 591 'file content\r\n' + | 591 'file content\r\n' + |
| 592 '--' + boundary + '--\r\n'; | 592 '--' + boundary + '--\r\n'; |
| 593 assert_equals( | 593 assert_equals( |
| 594 result, expected_body, | 594 result, expected_body, |
| 595 'Creating a Request with FormData body should success.'); | 595 'Creating a Request with FormData body should success.'); |
| 596 }) | 596 }) |
| 597 .then(function() { | 597 .then(function() { |
| 598 var params = new URLSearchParams(); |
| 599 params.append('sample string', '1234567890'); |
| 600 request = new Request(URL, {method: 'POST', body: params}); |
| 601 return request.text(); |
| 602 }) |
| 603 .then(function(result) { |
| 604 assert_equals(result, "sample+string=1234567890"); |
| 605 }) |
| 606 .then(function() { |
| 598 t.done(); | 607 t.done(); |
| 599 }) | 608 }) |
| 600 .catch(unreached_rejection(t)); | 609 .catch(unreached_rejection(t)); |
| 601 assert_true(request.bodyUsed, | 610 assert_true(request.bodyUsed, |
| 602 'bodyUsed must be true after calling text()'); | 611 'bodyUsed must be true after calling text()'); |
| 603 }, 'Request body test'); | 612 }, 'Request body test'); |
| 604 | 613 |
| 605 test(function() { | 614 test(function() { |
| 606 // https://fetch.spec.whatwg.org/#dom-request | 615 // https://fetch.spec.whatwg.org/#dom-request |
| 607 // Step 20: | 616 // Step 20: |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 var req2 = new Request(req); | 748 var req2 = new Request(req); |
| 740 assert_true(req.bodyUsed); | 749 assert_true(req.bodyUsed); |
| 741 assert_false(req2.bodyUsed); | 750 assert_false(req2.bodyUsed); |
| 742 return req2.text(); | 751 return req2.text(); |
| 743 }).then(function(text) { | 752 }).then(function(text) { |
| 744 assert_equals(text, ''); | 753 assert_equals(text, ''); |
| 745 }); | 754 }); |
| 746 }, 'Consume and pass'); | 755 }, 'Consume and pass'); |
| 747 | 756 |
| 748 done(); | 757 done(); |
| OLD | NEW |