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

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: More global-interface-listing*-expected.txt, urlencoded-parser-expected.txt Created 3 years, 7 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 promise_test(function(t) { 275 promise_test(function(t) {
276 return new Response().blob().then(blob => { 276 return new Response().blob().then(blob => {
277 assert_equals(blob.constructor, Blob); 277 assert_equals(blob.constructor, Blob);
278 assert_equals(blob.size, 0); 278 assert_equals(blob.size, 0);
279 assert_equals(blob.type, ''); 279 assert_equals(blob.type, '');
280 }); 280 });
281 }, 'call blob() on null body response'); 281 }, 'call blob() on null body response');
282 282
283 promise_test(function(t) { 283 promise_test(function(t) {
284 return new Response().json().then(unreached_rejection(t), e => { 284 return new Response().formData().then(unreached_fulfillment(t), e => {
285 assert_equals(e.constructor, TypeError);
286 });
287 }, 'call formData() on null body response');
288
289 promise_test(function(t) {
290 return new Response().json().then(unreached_fulfillment(t), e => {
285 assert_equals(e.constructor, SyntaxError); 291 assert_equals(e.constructor, SyntaxError);
286 }); 292 });
287 }, 'call json() on null body response'); 293 }, 'call json() on null body response');
288 294
289 promise_test(function(t) { 295 promise_test(function(t) {
290 var res = new Response('hello'); 296 var res = new Response('hello');
291 var body = res.body; 297 var body = res.body;
292 var clone = res.clone(); 298 var clone = res.clone();
293 assert_false(res.bodyUsed); 299 assert_false(res.bodyUsed);
294 assert_false(clone.bodyUsed); 300 assert_false(clone.bodyUsed);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 565
560 promise_test(t => { 566 promise_test(t => {
561 var controller; 567 var controller;
562 var stream = new ReadableStream({start: c => controller = c}); 568 var stream = new ReadableStream({start: c => controller = c});
563 setTimeout(() => controller.enqueue('hello'), 1); 569 setTimeout(() => controller.enqueue('hello'), 1);
564 var response = new Response(stream); 570 var response = new Response(stream);
565 return promise_rejects(t, TypeError(), response.text()); 571 return promise_rejects(t, TypeError(), response.text());
566 }, 'Response constructed stream with a string chunk'); 572 }, 'Response constructed stream with a string chunk');
567 573
568 done(); 574 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698