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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "platform/testing/URLTestHelpers.h" | 7 #include "platform/testing/URLTestHelpers.h" |
8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
9 #include "public/platform/WebURLLoaderClient.h" | 9 #include "public/platform/WebURLLoaderClient.h" |
10 #include "public/platform/WebUnitTestSupport.h" | 10 #include "public/platform/WebUnitTestSupport.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 Platform::current()->unitTestSupport()->setLoaderDelegate(&delegate); | 78 Platform::current()->unitTestSupport()->setLoaderDelegate(&delegate); |
79 FrameTestHelpers::loadFrame(mainFrame(), "https://example.com/foo.html"); | 79 FrameTestHelpers::loadFrame(mainFrame(), "https://example.com/foo.html"); |
80 Platform::current()->unitTestSupport()->setLoaderDelegate(nullptr); | 80 Platform::current()->unitTestSupport()->setLoaderDelegate(nullptr); |
81 } | 81 } |
82 | 82 |
83 // Finally, test reentrant callbacks to DocumentLoader::dataReceived(). | 83 // Finally, test reentrant callbacks to DocumentLoader::dataReceived(). |
84 TEST_F(DocumentLoaderTest, MultiChunkWithReentrancy) | 84 TEST_F(DocumentLoaderTest, MultiChunkWithReentrancy) |
85 { | 85 { |
86 // This test delegate chunks the response stage into three distinct stages: | 86 // This test delegate chunks the response stage into three distinct stages: |
87 // 1. The first dataReceived() callback, which triggers frame detach due to | 87 // 1. The first dataReceived() callback, which triggers frame detach due to |
88 // commiting a provisional load. | 88 // committing a provisional load. |
89 // 2. The middle part of the response, which is dispatched to | 89 // 2. The middle part of the response, which is dispatched to |
90 // dataReceived() reentrantly. | 90 // dataReceived() reentrantly. |
91 // 3. The final chunk, which is dispatched normally at the top-level. | 91 // 3. The final chunk, which is dispatched normally at the top-level. |
92 class TestDelegate | 92 class TestDelegate |
93 : public WebURLLoaderTestDelegate, public FrameTestHelpers::TestWebFrame
Client { | 93 : public WebURLLoaderTestDelegate, public FrameTestHelpers::TestWebFrame
Client { |
94 public: | 94 public: |
95 TestDelegate() : m_loaderClient(nullptr), m_loader(nullptr), m_dispatchi
ngDidReceiveData(false), m_servedReentrantly(false) { } | 95 TestDelegate() : m_loaderClient(nullptr), m_loader(nullptr), m_dispatchi
ngDidReceiveData(false), m_servedReentrantly(false) { } |
96 | 96 |
97 // WebURLLoaderTestDelegate overrides: | 97 // WebURLLoaderTestDelegate overrides: |
98 void didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader* lo
ader, const char* data, int dataLength, int encodedDataLength) override | 98 void didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader* lo
ader, const char* data, int dataLength, int encodedDataLength) override |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 Platform::current()->unitTestSupport()->setLoaderDelegate(nullptr); | 161 Platform::current()->unitTestSupport()->setLoaderDelegate(nullptr); |
162 | 162 |
163 EXPECT_TRUE(delegate.servedReentrantly()); | 163 EXPECT_TRUE(delegate.servedReentrantly()); |
164 | 164 |
165 // delegate is a WebFrameClient and stack-allocated, so manually reset() the | 165 // delegate is a WebFrameClient and stack-allocated, so manually reset() the |
166 // WebViewHelper here. | 166 // WebViewHelper here. |
167 m_webViewHelper.reset(); | 167 m_webViewHelper.reset(); |
168 } | 168 } |
169 | 169 |
170 } // namespace blink | 170 } // namespace blink |
OLD | NEW |