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

Side by Side Diff: Source/core/streams/ReadableStreamTest.cpp

Issue 456233002: Use ScriptPromiseProperty::reset in ReadableStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « Source/core/streams/ReadableStream.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/streams/ReadableStream.h" 6 #include "core/streams/ReadableStream.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 EXPECT_TRUE(onFulfilled.isNull()); 378 EXPECT_TRUE(onFulfilled.isNull());
379 EXPECT_TRUE(onRejected.isNull()); 379 EXPECT_TRUE(onRejected.isNull());
380 380
381 isolate()->RunMicrotasks(); 381 isolate()->RunMicrotasks();
382 EXPECT_EQ("undefined", onFulfilled); 382 EXPECT_EQ("undefined", onFulfilled);
383 EXPECT_TRUE(onRejected.isNull()); 383 EXPECT_TRUE(onRejected.isNull());
384 384
385 stream->error(DOMException::create(NotFoundError, "error")); 385 stream->error(DOMException::create(NotFoundError, "error"));
386 EXPECT_EQ(ReadableStream::Errored, stream->state()); 386 EXPECT_EQ(ReadableStream::Errored, stream->state());
387 387
388 // FIXME: This expectation should hold but doesn't because of 388 EXPECT_NE(promise, stream->wait(scriptState()));
389 // a ScriptPromiseProperty bug. Enable it when the defect is fixed.
390 // EXPECT_NE(promise, stream->wait(scriptState()));
391 } 389 }
392 390
393 TEST_F(ReadableStreamTest, CloseWhenWaiting) 391 TEST_F(ReadableStreamTest, CloseWhenWaiting)
394 { 392 {
395 String onWaitFulfilled, onWaitRejected; 393 String onWaitFulfilled, onWaitRejected;
396 String onClosedFulfilled, onClosedRejected; 394 String onClosedFulfilled, onClosedRejected;
397 395
398 StringStream* stream = construct(); 396 StringStream* stream = construct();
399 397
400 { 398 {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 checkpoint.Call(1); 506 checkpoint.Call(1);
509 EXPECT_FALSE(m_exceptionState.hadException()); 507 EXPECT_FALSE(m_exceptionState.hadException());
510 EXPECT_EQ("hello", chunk); 508 EXPECT_EQ("hello", chunk);
511 EXPECT_EQ(ReadableStream::Waiting, stream->state()); 509 EXPECT_EQ(ReadableStream::Waiting, stream->state());
512 EXPECT_TRUE(stream->isPulling()); 510 EXPECT_TRUE(stream->isPulling());
513 EXPECT_FALSE(stream->isDraining()); 511 EXPECT_FALSE(stream->isDraining());
514 512
515 ScriptPromise newPromise = stream->wait(scriptState()); 513 ScriptPromise newPromise = stream->wait(scriptState());
516 newPromise.then(createCaptor(&onFulfilled), createCaptor(&onRejected)); 514 newPromise.then(createCaptor(&onFulfilled), createCaptor(&onRejected));
517 isolate()->RunMicrotasks(); 515 isolate()->RunMicrotasks();
518 // FIXME: Uncomment the following assertions once 516 EXPECT_NE(promise, newPromise);
519 // |ScriptPromiseProperty.reset| is implemented and used. 517 EXPECT_TRUE(onFulfilled.isNull());
520 // EXPECT_NE(promise, newPromise); 518 EXPECT_TRUE(onRejected.isNull());
521 // EXPECT_TRUE(onFulfilled.isNull());
522 // EXPECT_TRUE(onRejected.isNull());
523 } 519 }
524 520
525 TEST_F(ReadableStreamTest, EnqueTwiceAndRead) 521 TEST_F(ReadableStreamTest, EnqueTwiceAndRead)
526 { 522 {
527 StringStream* stream = construct(); 523 StringStream* stream = construct();
528 Checkpoint checkpoint; 524 Checkpoint checkpoint;
529 525
530 { 526 {
531 InSequence s; 527 InSequence s;
532 EXPECT_CALL(checkpoint, Call(0)); 528 EXPECT_CALL(checkpoint, Call(0));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 isolate()->RunMicrotasks(); 574 isolate()->RunMicrotasks();
579 575
580 EXPECT_EQ(ReadableStream::Readable, stream->state()); 576 EXPECT_EQ(ReadableStream::Readable, stream->state());
581 EXPECT_FALSE(stream->isPulling()); 577 EXPECT_FALSE(stream->isPulling());
582 EXPECT_TRUE(stream->isDraining()); 578 EXPECT_TRUE(stream->isDraining());
583 579
584 EXPECT_TRUE(stream->read(scriptState(), &m_exceptionState).toString(chunk)); 580 EXPECT_TRUE(stream->read(scriptState(), &m_exceptionState).toString(chunk));
585 EXPECT_EQ("bye", chunk); 581 EXPECT_EQ("bye", chunk);
586 EXPECT_FALSE(m_exceptionState.hadException()); 582 EXPECT_FALSE(m_exceptionState.hadException());
587 583
588 // FIXME: This assertion should be enabled once 584 EXPECT_NE(promise, stream->wait(scriptState()));
589 // ScriptPromiseProperty.reset is implemented and used.
590 // EXPECT_NE(promise, stream->wait(scriptState()));
591 stream->wait(scriptState()).then(createCaptor(&onWaitFulfilled), createCapto r(&onWaitRejected)); 585 stream->wait(scriptState()).then(createCaptor(&onWaitFulfilled), createCapto r(&onWaitRejected));
592 586
593 EXPECT_EQ(ReadableStream::Closed, stream->state()); 587 EXPECT_EQ(ReadableStream::Closed, stream->state());
594 EXPECT_FALSE(stream->isPulling()); 588 EXPECT_FALSE(stream->isPulling());
595 EXPECT_TRUE(stream->isDraining()); 589 EXPECT_TRUE(stream->isDraining());
596 590
597 EXPECT_TRUE(onWaitFulfilled.isNull()); 591 EXPECT_TRUE(onWaitFulfilled.isNull());
598 EXPECT_TRUE(onWaitRejected.isNull()); 592 EXPECT_TRUE(onWaitRejected.isNull());
599 EXPECT_TRUE(onClosedFulfilled.isNull()); 593 EXPECT_TRUE(onClosedFulfilled.isNull());
600 EXPECT_TRUE(onClosedRejected.isNull()); 594 EXPECT_TRUE(onClosedRejected.isNull());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 InSequence s; 677 InSequence s;
684 EXPECT_CALL(*m_underlyingSource, cancelSource(scriptState(), reason)).Wi llOnce(Return(promise)); 678 EXPECT_CALL(*m_underlyingSource, cancelSource(scriptState(), reason)).Wi llOnce(Return(promise));
685 } 679 }
686 680
687 stream->enqueue("hello"); 681 stream->enqueue("hello");
688 ScriptPromise wait = stream->wait(scriptState()); 682 ScriptPromise wait = stream->wait(scriptState());
689 EXPECT_EQ(ReadableStream::Readable, stream->state()); 683 EXPECT_EQ(ReadableStream::Readable, stream->state());
690 EXPECT_EQ(promise, stream->cancel(scriptState(), reason)); 684 EXPECT_EQ(promise, stream->cancel(scriptState(), reason));
691 EXPECT_EQ(ReadableStream::Closed, stream->state()); 685 EXPECT_EQ(ReadableStream::Closed, stream->state());
692 686
693 // FIXME: Uncomment this once ScriptPromiseProperty::reset is implemented 687 EXPECT_NE(stream->wait(scriptState()), wait);
694 // and used.
695 // EXPECT_NE(stream->wait(scriptState()), wait);
696 688
697 stream->wait(scriptState()).then(createCaptor(&onFulfilled), createCaptor(&o nRejected)); 689 stream->wait(scriptState()).then(createCaptor(&onFulfilled), createCaptor(&o nRejected));
698 EXPECT_TRUE(onFulfilled.isNull()); 690 EXPECT_TRUE(onFulfilled.isNull());
699 EXPECT_TRUE(onRejected.isNull()); 691 EXPECT_TRUE(onRejected.isNull());
700 692
701 isolate()->RunMicrotasks(); 693 isolate()->RunMicrotasks();
702 EXPECT_EQ("undefined", onFulfilled); 694 EXPECT_EQ("undefined", onFulfilled);
703 EXPECT_TRUE(onRejected.isNull()); 695 EXPECT_TRUE(onRejected.isNull());
704 } 696 }
705 697
706 TEST_F(ReadableStreamTest, ReadableArrayBufferCompileTest) 698 TEST_F(ReadableStreamTest, ReadableArrayBufferCompileTest)
707 { 699 {
708 // This test tests if ReadableStreamImpl<ArrayBuffer> can be instantiated. 700 // This test tests if ReadableStreamImpl<ArrayBuffer> can be instantiated.
709 { 701 {
710 InSequence s; 702 InSequence s;
711 EXPECT_CALL(*m_underlyingSource, startSource(&m_exceptionState)).WillOnc e(Return(ScriptPromise())); 703 EXPECT_CALL(*m_underlyingSource, startSource(&m_exceptionState)).WillOnc e(Return(ScriptPromise()));
712 } 704 }
713 705
714 new ReadableStreamImpl<ReadableStreamChunkTypeTraits<ArrayBuffer> >(scriptSt ate(), m_underlyingSource, &m_exceptionState); 706 new ReadableStreamImpl<ReadableStreamChunkTypeTraits<ArrayBuffer> >(scriptSt ate(), m_underlyingSource, &m_exceptionState);
715 } 707 }
716 708
717 } // namespace blink 709 } // namespace blink
718 710
OLDNEW
« no previous file with comments | « Source/core/streams/ReadableStream.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698