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

Unified Diff: LayoutTests/http/tests/fetch/script-tests/stream-reader.js

Issue 899653002: Use ExclusiveStreamReader to lock Body. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@exclusive-reader
Patch Set: rebase Created 5 years, 10 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 | « no previous file | Source/core/streams/ReadableStream.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/stream-reader.js
diff --git a/LayoutTests/http/tests/fetch/script-tests/stream-reader.js b/LayoutTests/http/tests/fetch/script-tests/stream-reader.js
index 0e38e4c7966667360a52c106112dedced2303311..a080424788cb60d98659f312836b6f88ab1ab64e 100644
--- a/LayoutTests/http/tests/fetch/script-tests/stream-reader.js
+++ b/LayoutTests/http/tests/fetch/script-tests/stream-reader.js
@@ -88,5 +88,29 @@ sequential_promise_test(function(t) {
});
}, 'read contents with ExclusiveStreamReader');
+sequential_promise_test(function(t) {
+ return fetch('/fetch/resources/progressive.php').then(function(res) {
+ assert_false(res.bodyUsed);
+ var reader = res.body.getReader();
+ assert_true(res.bodyUsed);
+ return res;
+ }).then(function(res) {
+ return res.text();
+ }).then(unreached_rejection(t), function() {
+ // text() should fail because bodyUsed is set.
+ });
+ }, 'acquiring a reader should set bodyUsed.');
+
+sequential_promise_test(function(t) {
+ return fetch('/fetch/resources/progressive.php').then(function(res) {
+ // We need to access body attribute to start the stream.
+ res.body;
+ assert_false(res.bodyUsed);
+ res.text();
+ assert_true(res.bodyUsed);
+ assert_throws({name: 'TypeError'}, function() { res.body.getReader() });
+ });
+ }, 'Setting bodyUsed means the body is locked.');
+
sequential_promise_test_done();
done();
« no previous file with comments | « no previous file | Source/core/streams/ReadableStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698