Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/request.js

Issue 1456553002: Support 'URLSearchParams' as the body of a Request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLSearchParams
Patch Set: Feedback Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698