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

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

Issue 1049983003: [Fetch] Body consume function should not set bodyUsed flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@stream-clone
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
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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 headers: headers, 466 headers: headers,
467 body: new Blob(['Test Blob'], {type: 'test/type'}) 467 body: new Blob(['Test Blob'], {type: 'test/type'})
468 }); 468 });
469 var req2 = req.clone(); 469 var req2 = req.clone();
470 // Change headers and of original request. 470 // Change headers and of original request.
471 req.headers.set('Content-Language', 'en'); 471 req.headers.set('Content-Language', 'en');
472 assert_equals(req2.headers.get('Content-Language'), 'ja', 472 assert_equals(req2.headers.get('Content-Language'), 'ja',
473 'Headers of cloned request should not change when ' + 473 'Headers of cloned request should not change when ' +
474 'original request headers are changed.'); 474 'original request headers are changed.');
475 475
476 return req.text() 476 return req.text().then(function(text) {
477 .then(function(text) { 477 assert_equals(text, 'Test Blob', 'Body of request should match.');
478 assert_equals(text, 'Test Blob', 'Body of request should match.'); 478 return req2.text();
479 return req2.text(); 479 }).then(function(text) {
480 }) 480 assert_equals(text, 'Test Blob', 'Cloned request body should match.');
481 .then(function(text) { 481 return Promise.all([req.text(), req2.text()]);
482 assert_equals(text, 'Test Blob', 'Cloned request body should match.'); 482 }).then(function(texts) {
483 }); 483 assert_equals(texts[0], '', 'The body is consumed.');
484 assert_equals(texts[1], '', 'The body is consumed.');
485 });
484 }, 'Test clone behavior with loading content from Request.'); 486 }, 'Test clone behavior with loading content from Request.');
485 487
486 async_test(function(t) { 488 async_test(function(t) {
487 var request = 489 var request =
488 new Request(URL, 490 new Request(URL,
489 { 491 {
490 method: 'POST', 492 method: 'POST',
491 body: new Blob(['Test Blob'], {type: 'test/type'}) 493 body: new Blob(['Test Blob'], {type: 'test/type'})
492 }); 494 });
493 assert_equals( 495 assert_equals(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 body: new Blob([''], {type: 'Text/Plain'}), 699 body: new Blob([''], {type: 'Text/Plain'}),
698 headers: [['Content-Type', 'Text/Html']]}); 700 headers: [['Content-Type', 'Text/Html']]});
699 return req.blob() 701 return req.blob()
700 .then(function(blob) { 702 .then(function(blob) {
701 assert_equals(blob.type, 'text/html'); 703 assert_equals(blob.type, 'text/html');
702 assert_equals(req.headers.get('Content-Type'), 'Text/Html'); 704 assert_equals(req.headers.get('Content-Type'), 'Text/Html');
703 }); 705 });
704 }, 'Extract a MIME type (1)'); 706 }, 'Extract a MIME type (1)');
705 707
706 done(); 708 done();
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/cachestorage/script-tests/cache-put.js ('k') | LayoutTests/http/tests/fetch/script-tests/response.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698