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

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

Issue 1056813002: [Fetch] Request.clone() should reflect body consumption. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@body-used
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/fetch/script-tests/response.js » ('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 function size(headers) { 7 function size(headers) {
8 var count = 0; 8 var count = 0;
9 for (var header of headers) { 9 for (var header of headers) {
10 ++count; 10 ++count;
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 475
476 return req.text().then(function(text) { 476 return req.text().then(function(text) {
477 assert_equals(text, 'Test Blob', 'Body of request should match.'); 477 assert_equals(text, 'Test Blob', 'Body of request should match.');
478 return req2.text(); 478 return req2.text();
479 }).then(function(text) { 479 }).then(function(text) {
480 assert_equals(text, 'Test Blob', 'Cloned request body should match.'); 480 assert_equals(text, 'Test Blob', 'Cloned request body should match.');
481 return Promise.all([req.text(), req2.text()]); 481 return Promise.all([req.text(), req2.text()]);
482 }).then(function(texts) { 482 }).then(function(texts) {
483 assert_equals(texts[0], '', 'The body is consumed.'); 483 assert_equals(texts[0], '', 'The body is consumed.');
484 assert_equals(texts[1], '', 'The body is consumed.'); 484 assert_equals(texts[1], '', 'The body is consumed.');
485 return req.clone().text();
486 }).then(function(text) {
487 assert_equals(text, '', 'The body was consumed before cloned.');
485 }); 488 });
486 }, 'Test clone behavior with loading content from Request.'); 489 }, 'Test clone behavior with loading content from Request.');
487 490
488 async_test(function(t) { 491 async_test(function(t) {
489 var request = 492 var request =
490 new Request(URL, 493 new Request(URL,
491 { 494 {
492 method: 'POST', 495 method: 'POST',
493 body: new Blob(['Test Blob'], {type: 'test/type'}) 496 body: new Blob(['Test Blob'], {type: 'test/type'})
494 }); 497 });
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 body: new Blob([''], {type: 'Text/Plain'}), 702 body: new Blob([''], {type: 'Text/Plain'}),
700 headers: [['Content-Type', 'Text/Html']]}); 703 headers: [['Content-Type', 'Text/Html']]});
701 return req.blob() 704 return req.blob()
702 .then(function(blob) { 705 .then(function(blob) {
703 assert_equals(blob.type, 'text/html'); 706 assert_equals(blob.type, 'text/html');
704 assert_equals(req.headers.get('Content-Type'), 'Text/Html'); 707 assert_equals(req.headers.get('Content-Type'), 'Text/Html');
705 }); 708 });
706 }, 'Extract a MIME type (1)'); 709 }, 'Extract a MIME type (1)');
707 710
708 done(); 711 done();
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/fetch/script-tests/response.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698