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