OLD | NEW |
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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 StringStream* stream = construct(); | 553 StringStream* stream = construct(); |
554 stream->close(); | 554 stream->close(); |
555 ReadableStreamReader* reader = stream->getReader(scriptState()->executionCon
text(), exceptionState); | 555 ReadableStreamReader* reader = stream->getReader(scriptState()->executionCon
text(), exceptionState); |
556 | 556 |
557 ASSERT_TRUE(reader); | 557 ASSERT_TRUE(reader); |
558 EXPECT_FALSE(exceptionState.hadException()); | 558 EXPECT_FALSE(exceptionState.hadException()); |
559 | 559 |
560 String onFulfilled, onRejected; | 560 String onFulfilled, onRejected; |
561 reader->closed(scriptState()).then(createCaptor(&onFulfilled), createCaptor(
&onRejected)); | 561 reader->closed(scriptState()).then(createCaptor(&onFulfilled), createCaptor(
&onRejected)); |
562 | 562 |
563 EXPECT_FALSE(reader->isActive()); | 563 EXPECT_TRUE(reader->isActive()); |
564 EXPECT_TRUE(onFulfilled.isNull()); | 564 EXPECT_TRUE(onFulfilled.isNull()); |
565 EXPECT_TRUE(onRejected.isNull()); | 565 EXPECT_TRUE(onRejected.isNull()); |
566 | 566 |
567 isolate()->RunMicrotasks(); | 567 isolate()->RunMicrotasks(); |
568 EXPECT_EQ("undefined", onFulfilled); | 568 EXPECT_EQ("undefined", onFulfilled); |
569 EXPECT_TRUE(onRejected.isNull()); | 569 EXPECT_TRUE(onRejected.isNull()); |
570 } | 570 } |
571 | 571 |
572 TEST_F(ReadableStreamTest, GetErroredReader) | 572 TEST_F(ReadableStreamTest, GetErroredReader) |
573 { | 573 { |
574 ScriptState::Scope scope(scriptState()); | 574 ScriptState::Scope scope(scriptState()); |
575 ExceptionState exceptionState(ExceptionState::ConstructionContext, "property
", "interface", scriptState()->context()->Global(), isolate()); | 575 ExceptionState exceptionState(ExceptionState::ConstructionContext, "property
", "interface", scriptState()->context()->Global(), isolate()); |
576 StringStream* stream = construct(); | 576 StringStream* stream = construct(); |
577 stream->error(DOMException::create(SyntaxError, "some error")); | 577 stream->error(DOMException::create(SyntaxError, "some error")); |
578 ReadableStreamReader* reader = stream->getReader(scriptState()->executionCon
text(), exceptionState); | 578 ReadableStreamReader* reader = stream->getReader(scriptState()->executionCon
text(), exceptionState); |
579 | 579 |
580 ASSERT_TRUE(reader); | 580 ASSERT_TRUE(reader); |
581 EXPECT_FALSE(exceptionState.hadException()); | 581 EXPECT_FALSE(exceptionState.hadException()); |
582 | 582 |
583 String onFulfilled, onRejected; | 583 String onFulfilled, onRejected; |
584 reader->closed(scriptState()).then(createCaptor(&onFulfilled), createCaptor(
&onRejected)); | 584 reader->closed(scriptState()).then(createCaptor(&onFulfilled), createCaptor(
&onRejected)); |
585 | 585 |
586 EXPECT_FALSE(reader->isActive()); | 586 EXPECT_TRUE(reader->isActive()); |
587 EXPECT_TRUE(onFulfilled.isNull()); | 587 EXPECT_TRUE(onFulfilled.isNull()); |
588 EXPECT_TRUE(onRejected.isNull()); | 588 EXPECT_TRUE(onRejected.isNull()); |
589 | 589 |
590 isolate()->RunMicrotasks(); | 590 isolate()->RunMicrotasks(); |
591 EXPECT_TRUE(onFulfilled.isNull()); | 591 EXPECT_TRUE(onFulfilled.isNull()); |
592 EXPECT_EQ("SyntaxError: some error", onRejected); | 592 EXPECT_EQ("SyntaxError: some error", onRejected); |
593 } | 593 } |
594 | 594 |
595 TEST_F(ReadableStreamTest, StrictStrategy) | 595 TEST_F(ReadableStreamTest, StrictStrategy) |
596 { | 596 { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 reader->read(scriptState()); | 645 reader->read(scriptState()); |
646 EXPECT_FALSE(stream->isPulling()); | 646 EXPECT_FALSE(stream->isPulling()); |
647 checkpoint.Call(9); | 647 checkpoint.Call(9); |
648 reader->read(scriptState()); | 648 reader->read(scriptState()); |
649 EXPECT_TRUE(stream->isPulling()); | 649 EXPECT_TRUE(stream->isPulling()); |
650 | 650 |
651 stream->error(DOMException::create(AbortError, "done")); | 651 stream->error(DOMException::create(AbortError, "done")); |
652 } | 652 } |
653 | 653 |
654 } // namespace blink | 654 } // namespace blink |
OLD | NEW |