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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/streams/ReadableStreamOperations.h" 5 #include "core/streams/ReadableStreamOperations.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptFunction.h" 8 #include "bindings/core/v8/ScriptFunction.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/ScriptValue.h" 10 #include "bindings/core/v8/ScriptValue.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 EXPECT_FALSE(it3->isSet()); 327 EXPECT_FALSE(it3->isSet());
328 328
329 underlyingSource->close(); 329 underlyingSource->close();
330 v8::MicrotasksScope::PerformCheckpoint(isolate()); 330 v8::MicrotasksScope::PerformCheckpoint(isolate());
331 331
332 EXPECT_TRUE(it3->isSet()); 332 EXPECT_TRUE(it3->isSet());
333 EXPECT_TRUE(it3->isValid()); 333 EXPECT_TRUE(it3->isValid());
334 EXPECT_TRUE(it3->isDone()); 334 EXPECT_TRUE(it3->isDone());
335 } 335 }
336 336
337 TEST_F(ReadableStreamOperationsTest, UnderlyingSourceShouldHavePendingActivityWh enLockedAndControllerIsActive)
338 {
339 auto underlyingSource = new TestUnderlyingSource(getScriptState());
340
341 ScriptValue strategy = ReadableStreamOperations::createCountQueuingStrategy( getScriptState(), 10);
342 ASSERT_FALSE(strategy.isEmpty());
343
344 ScriptValue stream = ReadableStreamOperations::createReadableStream(getScrip tState(), underlyingSource, strategy);
345 ASSERT_FALSE(stream.isEmpty());
346
347 v8::Local<v8::Object> global = getScriptState()->context()->Global();
348 ASSERT_TRUE(global->Set(getScriptState()->context(), v8String(getScriptState ()->isolate(), "stream"), stream.v8Value()).IsJust());
349
350 EXPECT_FALSE(underlyingSource->hasPendingActivity());
351 evalWithPrintingError("let reader = stream.getReader();");
352 EXPECT_TRUE(underlyingSource->hasPendingActivity());
353 evalWithPrintingError("reader.releaseLock();");
354 EXPECT_FALSE(underlyingSource->hasPendingActivity());
355 evalWithPrintingError("reader = stream.getReader();");
356 EXPECT_TRUE(underlyingSource->hasPendingActivity());
357 underlyingSource->enqueue(ScriptValue(getScriptState(), v8::Undefined(getScr iptState()->isolate())));
358 underlyingSource->close();
359 EXPECT_FALSE(underlyingSource->hasPendingActivity());
360 }
361
337 TEST_F(ReadableStreamOperationsTest, SetDisturbed) 362 TEST_F(ReadableStreamOperationsTest, SetDisturbed)
338 { 363 {
339 ScriptValue stream = evalWithPrintingError("new ReadableStream()"); 364 ScriptValue stream = evalWithPrintingError("new ReadableStream()");
340 ASSERT_FALSE(stream.isEmpty()); 365 ASSERT_FALSE(stream.isEmpty());
341 366
342 EXPECT_FALSE(ReadableStreamOperations::isDisturbed(getScriptState(), stream) ); 367 EXPECT_FALSE(ReadableStreamOperations::isDisturbed(getScriptState(), stream) );
343 ReadableStreamOperations::setDisturbed(getScriptState(), stream); 368 ReadableStreamOperations::setDisturbed(getScriptState(), stream);
344 EXPECT_TRUE(ReadableStreamOperations::isDisturbed(getScriptState(), stream)) ; 369 EXPECT_TRUE(ReadableStreamOperations::isDisturbed(getScriptState(), stream)) ;
345 } 370 }
346 371
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 408
384 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), readable) ); 409 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), readable) );
385 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), closed)); 410 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), closed));
386 EXPECT_TRUE(ReadableStreamOperations::isErrored(getScriptState(), errored)); 411 EXPECT_TRUE(ReadableStreamOperations::isErrored(getScriptState(), errored));
387 } 412 }
388 413
389 } // namespace 414 } // namespace
390 415
391 } // namespace blink 416 } // namespace blink
392 417
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698