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

Side by Side Diff: third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp

Issue 1969333002: [Fetch API] |(new Response(stream)).body| should return |stream| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 ScriptValue errored = evalWithPrintingError("new ReadableStream({start: c => c.error()})"); 394 ScriptValue errored = evalWithPrintingError("new ReadableStream({start: c => c.error()})");
395 ASSERT_FALSE(readable.isEmpty()); 395 ASSERT_FALSE(readable.isEmpty());
396 ASSERT_FALSE(closed.isEmpty()); 396 ASSERT_FALSE(closed.isEmpty());
397 ASSERT_FALSE(errored.isEmpty()); 397 ASSERT_FALSE(errored.isEmpty());
398 398
399 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), readable) ); 399 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), readable) );
400 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), closed)); 400 EXPECT_FALSE(ReadableStreamOperations::isErrored(getScriptState(), closed));
401 EXPECT_TRUE(ReadableStreamOperations::isErrored(getScriptState(), errored)); 401 EXPECT_TRUE(ReadableStreamOperations::isErrored(getScriptState(), errored));
402 } 402 }
403 403
404 TEST_F(ReadableStreamOperationsTest, Tee)
405 {
406 ScriptValue original = evalWithPrintingError(
407 "var controller;"
408 "new ReadableStream({start: c => controller = c})");
409 ASSERT_FALSE(original.isEmpty());
410 ScriptValue new1, new2;
411 ReadableStreamOperations::tee(getScriptState(), original, &new1, &new2);
412
413 NonThrowableExceptionState ec;
414 ScriptValue reader1 = ReadableStreamOperations::getReader(getScriptState(), new1, ec);
415 ScriptValue reader2 = ReadableStreamOperations::getReader(getScriptState(), new2, ec);
416
417 Iteration* it1 = new Iteration();
418 Iteration* it2 = new Iteration();
419 ReadableStreamOperations::defaultReaderRead(getScriptState(), reader1).then(
420 Function::createFunction(getScriptState(), it1),
421 NotReached::createFunction(getScriptState()));
422 ReadableStreamOperations::defaultReaderRead(getScriptState(), reader2).then(
423 Function::createFunction(getScriptState(), it2),
424 NotReached::createFunction(getScriptState()));
425
426 v8::MicrotasksScope::PerformCheckpoint(isolate());
427 EXPECT_FALSE(it1->isSet());
428 EXPECT_FALSE(it2->isSet());
429
430 ASSERT_FALSE(evalWithPrintingError("controller.enqueue('hello')").isEmpty()) ;
431 v8::MicrotasksScope::PerformCheckpoint(isolate());
432
433 EXPECT_TRUE(it1->isSet());
434 EXPECT_TRUE(it1->isValid());
435 EXPECT_FALSE(it1->isDone());
436 EXPECT_EQ("hello", it1->value());
437 EXPECT_TRUE(it2->isSet());
438 EXPECT_TRUE(it2->isValid());
439 EXPECT_FALSE(it2->isDone());
440 EXPECT_EQ("hello", it2->value());
441 }
442
404 } // namespace 443 } // namespace
405 444
406 } // namespace blink 445 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698