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 "modules/fetch/Response.h" | 5 #include "modules/fetch/Response.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
12 #include "core/dom/ExecutionContext.h" | |
13 #include "core/frame/Frame.h" | 12 #include "core/frame/Frame.h" |
14 #include "core/testing/DummyPageHolder.h" | 13 #include "core/testing/DummyPageHolder.h" |
15 #include "modules/fetch/BodyStreamBuffer.h" | 14 #include "modules/fetch/BodyStreamBuffer.h" |
16 #include "modules/fetch/BytesConsumer.h" | 15 #include "modules/fetch/BytesConsumer.h" |
17 #include "modules/fetch/BytesConsumerTestUtil.h" | 16 #include "modules/fetch/BytesConsumerTestUtil.h" |
18 #include "modules/fetch/DataConsumerHandleTestUtil.h" | 17 #include "modules/fetch/DataConsumerHandleTestUtil.h" |
19 #include "modules/fetch/FetchResponseData.h" | 18 #include "modules/fetch/FetchResponseData.h" |
20 #include "platform/blob/BlobData.h" | 19 #include "platform/blob/BlobData.h" |
21 #include "platform/testing/UnitTestHelpers.h" | 20 #include "platform/testing/UnitTestHelpers.h" |
22 #include "platform/wtf/PtrUtil.h" | 21 #include "platform/wtf/PtrUtil.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 FetchDataLoader::CreateLoaderAsString(), client1); | 211 FetchDataLoader::CreateLoaderAsString(), client1); |
213 cloned_response->InternalBodyBuffer()->StartLoading( | 212 cloned_response->InternalBodyBuffer()->StartLoading( |
214 FetchDataLoader::CreateLoaderAsString(), client2); | 213 FetchDataLoader::CreateLoaderAsString(), client2); |
215 blink::testing::RunPendingTasks(); | 214 blink::testing::RunPendingTasks(); |
216 } | 215 } |
217 | 216 |
218 BodyStreamBuffer* CreateHelloWorldBuffer(ScriptState* script_state) { | 217 BodyStreamBuffer* CreateHelloWorldBuffer(ScriptState* script_state) { |
219 using Command = BytesConsumerTestUtil::Command; | 218 using Command = BytesConsumerTestUtil::Command; |
220 BytesConsumerTestUtil::ReplayingBytesConsumer* src = | 219 BytesConsumerTestUtil::ReplayingBytesConsumer* src = |
221 new BytesConsumerTestUtil::ReplayingBytesConsumer( | 220 new BytesConsumerTestUtil::ReplayingBytesConsumer( |
222 ExecutionContext::From(script_state)); | 221 script_state->GetExecutionContext()); |
223 src->Add(Command(Command::kData, "Hello, ")); | 222 src->Add(Command(Command::kData, "Hello, ")); |
224 src->Add(Command(Command::kData, "world")); | 223 src->Add(Command(Command::kData, "world")); |
225 src->Add(Command(Command::kDone)); | 224 src->Add(Command(Command::kDone)); |
226 return new BodyStreamBuffer(script_state, src); | 225 return new BodyStreamBuffer(script_state, src); |
227 } | 226 } |
228 | 227 |
229 TEST(ServiceWorkerResponseTest, BodyStreamBufferCloneDefault) { | 228 TEST(ServiceWorkerResponseTest, BodyStreamBufferCloneDefault) { |
230 V8TestingScope scope; | 229 V8TestingScope scope; |
231 BodyStreamBuffer* buffer = CreateHelloWorldBuffer(scope.GetScriptState()); | 230 BodyStreamBuffer* buffer = CreateHelloWorldBuffer(scope.GetScriptState()); |
232 FetchResponseData* fetch_response_data = | 231 FetchResponseData* fetch_response_data = |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 310 |
312 response->InternalBodyBuffer()->StartLoading( | 311 response->InternalBodyBuffer()->StartLoading( |
313 FetchDataLoader::CreateLoaderAsString(), client1); | 312 FetchDataLoader::CreateLoaderAsString(), client1); |
314 cloned_response->InternalBodyBuffer()->StartLoading( | 313 cloned_response->InternalBodyBuffer()->StartLoading( |
315 FetchDataLoader::CreateLoaderAsString(), client2); | 314 FetchDataLoader::CreateLoaderAsString(), client2); |
316 blink::testing::RunPendingTasks(); | 315 blink::testing::RunPendingTasks(); |
317 } | 316 } |
318 | 317 |
319 } // namespace | 318 } // namespace |
320 } // namespace blink | 319 } // namespace blink |
OLD | NEW |