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

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

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: Created 4 years, 3 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 importScripts('/streams/resources/rs-utils.js'); 3 importScripts('/streams/resources/rs-utils.js');
4 } 4 }
5 5
6 function decode(chunks) { 6 function decode(chunks) {
7 var decoder = new TextDecoder(); 7 var decoder = new TextDecoder();
8 var result = ''; 8 var result = '';
9 for (var chunk of chunks) { 9 for (var chunk of chunks) {
10 result += decoder.decode(chunk, {stream: true}); 10 result += decoder.decode(chunk, {stream: true});
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 promise_test(function(t) { 264 promise_test(function(t) {
265 return new Response().blob().then(blob => { 265 return new Response().blob().then(blob => {
266 assert_equals(blob.constructor, Blob); 266 assert_equals(blob.constructor, Blob);
267 assert_equals(blob.size, 0); 267 assert_equals(blob.size, 0);
268 assert_equals(blob.type, ''); 268 assert_equals(blob.type, '');
269 }); 269 });
270 }, 'call blob() on null body response'); 270 }, 'call blob() on null body response');
271 271
272 promise_test(function(t) { 272 promise_test(function(t) {
273 return new Response().json().then(unreached_rejection(t), e => { 273 return new Response().formData().then(unreached_fulfillment(t), e => {
274 assert_equals(e.constructor, TypeError);
275 });
276 }, 'call formData() on null body response');
277
278 promise_test(function(t) {
279 return new Response().json().then(unreached_fulfillment(t), e => {
274 assert_equals(e.constructor, SyntaxError); 280 assert_equals(e.constructor, SyntaxError);
275 }); 281 });
276 }, 'call json() on null body response'); 282 }, 'call json() on null body response');
277 283
278 promise_test(function(t) { 284 promise_test(function(t) {
279 var res = new Response('hello'); 285 var res = new Response('hello');
280 var body = res.body; 286 var body = res.body;
281 var clone = res.clone(); 287 var clone = res.clone();
282 assert_false(res.bodyUsed); 288 assert_false(res.bodyUsed);
283 assert_false(clone.bodyUsed); 289 assert_false(clone.bodyUsed);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 test(function() { 455 test(function() {
450 ['http://ex\x0aample.com', 456 ['http://ex\x0aample.com',
451 'http://ex\x0dample.com'].forEach(function(url) { 457 'http://ex\x0dample.com'].forEach(function(url) {
452 assert_equals(Response.redirect(url).headers.get('Location'), 458 assert_equals(Response.redirect(url).headers.get('Location'),
453 'http://example.com/', 459 'http://example.com/',
454 'Location header value must not contain CR or LF'); 460 'Location header value must not contain CR or LF');
455 }); 461 });
456 }, 'Response.redirect() with URLs with CR or LF'); 462 }, 'Response.redirect() with URLs with CR or LF');
457 463
458 done(); 464 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698