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

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

Issue 2163273002: [Fetch] Accept URLSearchParams in Response constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 5 months 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
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 promise_test(function() { 5 promise_test(function() {
6 var response = new Response; 6 var response = new Response;
7 return response.text() 7 return response.text()
8 .then(function(text) { 8 .then(function(text) {
9 assert_equals(text, '', 9 assert_equals(text, '',
10 'response.text() must return an empty string' + 10 'response.text() must return an empty string' +
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 '\r\n' + 108 '\r\n' +
109 'file content\r\n' + 109 'file content\r\n' +
110 '--' + boundary + '--\r\n'; 110 '--' + boundary + '--\r\n';
111 assert_equals( 111 assert_equals(
112 result, expected_body, 112 result, expected_body,
113 'Creating a Response with FormData body must succeed.'); 113 'Creating a Response with FormData body must succeed.');
114 }); 114 });
115 }, 'Behavior of Response with FormData content'); 115 }, 'Behavior of Response with FormData content');
116 116
117 promise_test(function() { 117 promise_test(function() {
118 var urlSearchParams = new URLSearchParams();
yhirano 2016/07/21 09:00:27 I prefer const / let for new code whenever possibl
e_hakkinen 2016/07/21 12:02:25 Done.
119 urlSearchParams.append('sample string', '1234567890');
120 urlSearchParams.append('sample string 2', '1234567890 & 2');
121 var response = new Response(urlSearchParams);
122 assert_equals(
123 response.headers.get('Content-Type'),
124 'application/x-www-form-urlencoded;charset=UTF-8',
125 'A Response constructed with an URLSearchParams should have a Content-Type .');
tyoshino (SeeGerritForStatus) 2016/07/21 07:30:28 an URLSearchParams -> a URLSearchParams as it's pr
e_hakkinen 2016/07/21 12:02:25 Done.
126 return response.text()
127 .then(function(result) {
128 assert_equals(
129 result, 'sample+string=1234567890&sample+string+2=1234567890+%26+2',
130 'Creating a Response with URLSearchParams body must succeed.');
131 });
132 }, 'Behavior of Response with URLSearchParams content');
133
134 promise_test(function() {
118 var headers = new Headers; 135 var headers = new Headers;
119 headers.set('Content-Language', 'ja'); 136 headers.set('Content-Language', 'ja');
120 var response = new Response( 137 var response = new Response(
121 'test string', {method: 'GET', headers: headers}); 138 'test string', {method: 'GET', headers: headers});
122 assert_false(response.bodyUsed); 139 assert_false(response.bodyUsed);
123 var response2 = response.clone(); 140 var response2 = response.clone();
124 assert_false(response.bodyUsed, 'bodyUsed is not set by clone().'); 141 assert_false(response.bodyUsed, 'bodyUsed is not set by clone().');
125 assert_false(response2.bodyUsed, 'bodyUsed is not set by clone().'); 142 assert_false(response2.bodyUsed, 'bodyUsed is not set by clone().');
126 response.headers.set('Content-Language', 'en'); 143 response.headers.set('Content-Language', 'en');
127 assert_equals( 144 assert_equals(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 'A Response constructed with no body should have no Content-Type.'); 185 'A Response constructed with no body should have no Content-Type.');
169 return response.text() 186 return response.text()
170 .then(function(text) { 187 .then(function(text) {
171 assert_equals(text, '', 188 assert_equals(text, '',
172 'Response with no body accessed as text should ' + 189 'Response with no body accessed as text should ' +
173 'resolve to the empty string.'); 190 'resolve to the empty string.');
174 }); 191 });
175 }, 'Behavior of Response with no body.'); 192 }, 'Behavior of Response with no body.');
176 193
177 done(); 194 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698