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

Unified Diff: third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp

Issue 1902963003: [Streams] UnderlyingSourceBase should be kept alive only when locked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-stream-operations
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp
diff --git a/third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp b/third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp
index d3b9175e5b7b3c770c1dcb2d33952ec65c2c931c..573ccd1ab0e812cd5e85532c482ffc2be7ba585a 100644
--- a/third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp
+++ b/third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp
@@ -334,6 +334,31 @@ TEST_F(ReadableStreamOperationsTest, CreateReadableStreamWithCustomUnderlyingSou
EXPECT_TRUE(it3->isDone());
}
+TEST_F(ReadableStreamOperationsTest, UnderlyingSourceShouldHavePendingActivityWhenLockedAndControllerIsActive)
+{
+ auto underlyingSource = new TestUnderlyingSource(getScriptState());
+
+ ScriptValue strategy = ReadableStreamOperations::createCountQueuingStrategy(getScriptState(), 10);
+ ASSERT_FALSE(strategy.isEmpty());
+
+ ScriptValue stream = ReadableStreamOperations::createReadableStream(getScriptState(), underlyingSource, strategy);
+ ASSERT_FALSE(stream.isEmpty());
+
+ v8::Local<v8::Object> global = getScriptState()->context()->Global();
+ ASSERT_TRUE(global->Set(getScriptState()->context(), v8String(getScriptState()->isolate(), "stream"), stream.v8Value()).IsJust());
+
+ EXPECT_FALSE(underlyingSource->hasPendingActivity());
+ evalWithPrintingError("let reader = stream.getReader();");
+ EXPECT_TRUE(underlyingSource->hasPendingActivity());
+ evalWithPrintingError("reader.releaseLock();");
+ EXPECT_FALSE(underlyingSource->hasPendingActivity());
+ evalWithPrintingError("reader = stream.getReader();");
+ EXPECT_TRUE(underlyingSource->hasPendingActivity());
+ underlyingSource->enqueue(ScriptValue(getScriptState(), v8::Undefined(getScriptState()->isolate())));
+ underlyingSource->close();
+ EXPECT_FALSE(underlyingSource->hasPendingActivity());
+}
+
TEST_F(ReadableStreamOperationsTest, SetDisturbed)
{
ScriptValue stream = evalWithPrintingError("new ReadableStream()");

Powered by Google App Engine
This is Rietveld 408576698