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

Unified Diff: LayoutTests/http/tests/fetch/script-tests/response-content.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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/fetch/script-tests/response.js ('k') | Source/modules/fetch/Body.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/fetch/script-tests/response-content.js
diff --git a/LayoutTests/http/tests/fetch/script-tests/response-content.js b/LayoutTests/http/tests/fetch/script-tests/response-content.js
index 8a211e316eaa6fed070df86fb891134b7db4ca55..25321cf8912fadadb28be6804321f4c25add6679 100644
--- a/LayoutTests/http/tests/fetch/script-tests/response-content.js
+++ b/LayoutTests/http/tests/fetch/script-tests/response-content.js
@@ -119,35 +119,39 @@ promise_test(function() {
headers.set('Content-Language', 'ja');
var response = new Response(
'test string', {method: 'GET', headers: headers});
- assert_false(response.bodyUsed,
- 'bodyUsed is not set until Response is consumed.');
+ assert_false(response.bodyUsed);
var response2 = response.clone();
+ assert_false(response.bodyUsed, 'bodyUsed is not set by clone().');
+ assert_false(response2.bodyUsed, 'bodyUsed is not set by clone().');
response.headers.set('Content-Language', 'en');
var response3;
- assert_false(response2.bodyUsed,
- 'bodyUsed should be false in clone of non-consumed Response.');
assert_equals(
response2.headers.get('Content-Language'), 'ja', 'Headers of cloned ' +
'response should not change when original response headers are changed.');
- return response.text()
- .then(function(text) {
- assert_true(
- response.bodyUsed,
- 'bodyUsed should be true after a response is consumed.');
- assert_false(
- response2.bodyUsed, 'bodyUsed should be false in Response cloned ' +
- 'before the original response was consumed.');
- assert_throws(
- {name: 'TypeError'},
- function() { response3 = response.clone(); },
- 'Response.clone() should throw if the body was used.');
- return response2.text();
- })
- .then(function(text) {
- assert_equals(text, 'test string',
- 'Response clone response body text should match.');
- });
+ var p = response.text();
+ assert_true(response.bodyUsed, 'bodyUsed should be true when locked.');
+ assert_false(response2.bodyUsed,
+ 'Cloned bodies should not share bodyUsed.');
+ assert_throws({name: 'TypeError'},
+ function() { response3 = response.clone(); },
+ 'Response.clone() should throw if the body was used.');
+ return p.then(function(text) {
+ assert_false(response.bodyUsed,
+ 'bodyUsed becomes false when text() is done.');
+ assert_false(response2.bodyUsed);
+ response3 = response.clone();
+ return response2.text();
+ }).then(function(text) {
+ assert_equals(text, 'test string',
+ 'Response clone response body text should match.');
+ return Promise.all([response.text(), response2.text(),
+ response3.text()]);
+ }).then(function(texts) {
+ assert_equals(texts[0], '', 'Cloned after consumed.');
+ assert_equals(texts[1], '', 'Already consumed.');
+ assert_equals(texts[2], '', 'Cloned after consumed.');
+ });
}, 'Behavior of bodyUsed in Response and clone behavior.');
promise_test(function() {
« no previous file with comments | « LayoutTests/http/tests/fetch/script-tests/response.js ('k') | Source/modules/fetch/Body.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698