OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_SIDE_NAVIGATION_TEST_UTILS_H_ |
| 6 #define CONTENT_PUBLIC_TEST_BROWSER_SIDE_NAVIGATION_TEST_UTILS_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 class RenderFrameHost; |
| 15 class StreamHandle; |
| 16 |
| 17 // Initializes the browser side navigation test utils. Following this call, all |
| 18 // NavigationURLLoader objects created will be TestNavigationURLLoaders instead |
| 19 // of NavigationURLloaderImpls. This should be called before any call in the UI |
| 20 // thread unit tests that will start a navigation (eg. |
| 21 // TestWebContents::NavigateAndCommit). |
| 22 void BrowserSideNavigationSetUp(); |
| 23 |
| 24 // Tears down the browser side navigation test utils. |
| 25 void BrowserSideNavigationTearDown(); |
| 26 |
| 27 // Returns an empty stream. Used when faking a navigation commit notification |
| 28 // from the IO thread with a TestNavigationURLLoader. |
| 29 std::unique_ptr<StreamHandle> MakeEmptyStream(); |
| 30 |
| 31 // If a test needs to run with browser side navigation enabled, call this |
| 32 // function before doing any setup. In particular, for tests inheriting from |
| 33 // RenderViewHostTestHarness, call this function before calling |
| 34 // RenderViewHostTestHarness::SetUp. |
| 35 void EnableBrowserSideNavigation(); |
| 36 |
| 37 // If we are doing a cross-site navigation, this simulates the current RFH |
| 38 // notifying that it has unloaded so the pending RFH is resumed and can |
| 39 // navigate. |
| 40 // PlzNavigate: the pending RFH is not created before the navigation commit, |
| 41 // so it is necessary to simulate the IO thread response here to commit in the |
| 42 // proper renderer. It is necessary to call PrepareForCommit before getting |
| 43 // the main and the pending frame because when we are trying to navigate to a |
| 44 // webui from a new tab, a RenderFrameHost is created to display it that is |
| 45 // committed immediately (since it is a new tab). Therefore the main frame is |
| 46 // replaced without a pending frame being created, and we don't get the right |
| 47 // values for the RFH to navigate: we try to use the old one that has been |
| 48 // deleted in the meantime. |
| 49 // Note that for some synchronous navigations (about:blank, javascript |
| 50 // urls, etc.) there will be no NavigationRequest, and no simulation of the |
| 51 // network stack is required. |
| 52 void SimulateCurrentRenderFrameHostUnloading(RenderFrameHost* rfh); |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_PUBLIC_TEST_BROWSER_SIDE_NAVIGATION_TEST_UTILS_H_ |
OLD | NEW |