| 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 "platform/testing/URLTestHelpers.h" | 5 #include "platform/testing/URLTestHelpers.h" |
| 6 #include "public/platform/Platform.h" | 6 #include "public/platform/Platform.h" |
| 7 #include "public/platform/WebURLLoaderClient.h" | 7 #include "public/platform/WebURLLoaderClient.h" |
| 8 #include "public/platform/WebURLLoaderMockFactory.h" | 8 #include "public/platform/WebURLLoaderMockFactory.h" |
| 9 #include "public/web/WebCache.h" | 9 #include "public/web/WebCache.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "web/WebLocalFrameImpl.h" | 11 #include "web/WebLocalFrameImpl.h" |
| 12 #include "web/tests/FrameTestHelpers.h" | 12 #include "web/tests/FrameTestHelpers.h" |
| 13 #include "wtf/TemporaryChange.h" | 13 #include "wtf/AutoReset.h" |
| 14 #include <queue> | 14 #include <queue> |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 // TODO(dcheng): Ideally, enough of FrameTestHelpers would be in core/ that | 18 // TODO(dcheng): Ideally, enough of FrameTestHelpers would be in core/ that |
| 19 // placing a test for a core/ class in web/ wouldn't be necessary. | 19 // placing a test for a core/ class in web/ wouldn't be necessary. |
| 20 class DocumentLoaderTest : public ::testing::Test { | 20 class DocumentLoaderTest : public ::testing::Test { |
| 21 protected: | 21 protected: |
| 22 void SetUp() override | 22 void SetUp() override |
| 23 { | 23 { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 m_loaderClient = originalClient; | 102 m_loaderClient = originalClient; |
| 103 m_loader = loader; | 103 m_loader = loader; |
| 104 for (int i = 0; i < dataLength; ++i) | 104 for (int i = 0; i < dataLength; ++i) |
| 105 m_data.push(data[i]); | 105 m_data.push(data[i]); |
| 106 | 106 |
| 107 { | 107 { |
| 108 // Serve the first byte to the real WebURLLoaderCLient, which | 108 // Serve the first byte to the real WebURLLoaderCLient, which |
| 109 // should trigger frameDetach() due to committing a provisional | 109 // should trigger frameDetach() due to committing a provisional |
| 110 // load. | 110 // load. |
| 111 TemporaryChange<bool> dispatching(m_dispatchingDidReceiveData, t
rue); | 111 AutoReset<bool> dispatching(&m_dispatchingDidReceiveData, true); |
| 112 dispatchOneByte(); | 112 dispatchOneByte(); |
| 113 } | 113 } |
| 114 // Serve the remaining bytes to complete the load. | 114 // Serve the remaining bytes to complete the load. |
| 115 EXPECT_FALSE(m_data.empty()); | 115 EXPECT_FALSE(m_data.empty()); |
| 116 while (!m_data.empty()) | 116 while (!m_data.empty()) |
| 117 dispatchOneByte(); | 117 dispatchOneByte(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // WebFrameClient overrides: | 120 // WebFrameClient overrides: |
| 121 void frameDetached(WebLocalFrame* frame, DetachType detachType) override | 121 void frameDetached(WebLocalFrame* frame, DetachType detachType) override |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); | 161 Platform::current()->getURLLoaderMockFactory()->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 |