OLD | NEW |
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/ReadableStreamReader.h" | 5 #include "core/streams/ReadableStreamReader.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/ToV8.h" | 9 #include "bindings/core/v8/ToV8.h" |
10 #include "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
12 #include "core/dom/Document.h" | 12 #include "core/dom/Document.h" |
13 #include "core/dom/ExceptionCode.h" | 13 #include "core/dom/ExceptionCode.h" |
14 #include "core/streams/ReadableStream.h" | 14 #include "core/streams/ReadableStream.h" |
15 #include "core/streams/ReadableStreamImpl.h" | 15 #include "core/streams/ReadableStreamImpl.h" |
16 #include "core/streams/UnderlyingSource.h" | 16 #include "core/streams/UnderlyingSource.h" |
17 #include "core/testing/DummyPageHolder.h" | 17 #include "core/testing/DummyPageHolder.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include <memory> | |
20 | 19 |
21 namespace blink { | 20 namespace blink { |
22 | 21 |
23 using StringStream = ReadableStreamImpl<ReadableStreamChunkTypeTraits<String>>; | 22 using StringStream = ReadableStreamImpl<ReadableStreamChunkTypeTraits<String>>; |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 struct ReadResult { | 26 struct ReadResult { |
28 ReadResult() : isDone(false), isSet(false) { } | 27 ReadResult() : isDone(false), isSet(false) { } |
29 | 28 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 v8::Local<v8::Function> createCaptor(String* value) | 143 v8::Local<v8::Function> createCaptor(String* value) |
145 { | 144 { |
146 return StringCapturingFunction::createFunction(getScriptState(), value); | 145 return StringCapturingFunction::createFunction(getScriptState(), value); |
147 } | 146 } |
148 | 147 |
149 v8::Local<v8::Function> createResultCaptor(ReadResult* value) | 148 v8::Local<v8::Function> createResultCaptor(ReadResult* value) |
150 { | 149 { |
151 return ReadResultCapturingFunction::createFunction(getScriptState(), val
ue); | 150 return ReadResultCapturingFunction::createFunction(getScriptState(), val
ue); |
152 } | 151 } |
153 | 152 |
154 std::unique_ptr<DummyPageHolder> m_page; | 153 OwnPtr<DummyPageHolder> m_page; |
155 Persistent<StringStream> m_stream; | 154 Persistent<StringStream> m_stream; |
156 }; | 155 }; |
157 | 156 |
158 TEST_F(ReadableStreamReaderTest, Construct) | 157 TEST_F(ReadableStreamReaderTest, Construct) |
159 { | 158 { |
160 ScriptState::Scope scope(getScriptState()); | 159 ScriptState::Scope scope(getScriptState()); |
161 ExceptionState exceptionState(ExceptionState::ConstructionContext, "property
", "interface", getScriptState()->context()->Global(), isolate()); | 160 ExceptionState exceptionState(ExceptionState::ConstructionContext, "property
", "interface", getScriptState()->context()->Global(), isolate()); |
162 ReadableStreamReader* reader = new ReadableStreamReader(getExecutionContext(
), m_stream); | 161 ReadableStreamReader* reader = new ReadableStreamReader(getExecutionContext(
), m_stream); |
163 EXPECT_TRUE(reader->isActive()); | 162 EXPECT_TRUE(reader->isActive()); |
164 EXPECT_FALSE(exceptionState.hadException()); | 163 EXPECT_FALSE(exceptionState.hadException()); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 576 |
578 v8::MicrotasksScope::PerformCheckpoint(isolate()); | 577 v8::MicrotasksScope::PerformCheckpoint(isolate()); |
579 EXPECT_TRUE(onFulfilled.isNull()); | 578 EXPECT_TRUE(onFulfilled.isNull()); |
580 EXPECT_EQ("SyntaxError: some error", onRejected); | 579 EXPECT_EQ("SyntaxError: some error", onRejected); |
581 EXPECT_FALSE(exceptionState.hadException()); | 580 EXPECT_FALSE(exceptionState.hadException()); |
582 } | 581 } |
583 | 582 |
584 } // namespace | 583 } // namespace |
585 | 584 |
586 } // namespace blink | 585 } // namespace blink |
OLD | NEW |