Chromium Code Reviews| Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| index 57bbf7c97f2f1f00926f73356940e2b3488a3a1d..358b152abb1bd22baaeafac4634d6b9f505c6566 100644 |
| --- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| +++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| @@ -1025,34 +1025,33 @@ class StallDelegate : public ResourceDispatcherHostDelegate { |
| } |
| }; |
| -} // namespace |
| - |
| -IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| - NavigationTypeClassification_InPageWhilePending) { |
| +// Loads |start_url|, then loads |stalled_url| which stalls. While the page is |
| +// stalled, an in-page navigation happens. Make sure that all the navigations |
| +// are properly classified. |
| +void DoReplaceStateWhilePending(Shell* shell, |
| + const GURL& start_url, |
| + const GURL& stalled_url) { |
| NavigationControllerImpl& controller = |
| static_cast<NavigationControllerImpl&>( |
| - shell()->web_contents()->GetController()); |
| + shell->web_contents()->GetController()); |
| FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| + static_cast<WebContentsImpl*>(shell->web_contents())-> |
| GetFrameTree()->root(); |
| - // Start with a normal page. |
| - GURL url1(embedded_test_server()->GetURL( |
| - "/navigation_controller/simple_page_1.html")); |
| - EXPECT_TRUE(NavigateToURL(shell(), url1)); |
| + // Start with one page. |
| + EXPECT_TRUE(NavigateToURL(shell, start_url)); |
| // Have the user decide to go to a different page which is very slow. |
| StallDelegate stall_delegate; |
| ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); |
| - GURL url2(embedded_test_server()->GetURL( |
| - "/navigation_controller/simple_page_2.html")); |
| - controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| + controller.LoadURL( |
| + stalled_url, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| // That should be the pending entry. |
| NavigationEntryImpl* entry = controller.GetPendingEntry(); |
| ASSERT_NE(nullptr, entry); |
| - EXPECT_EQ(url2, entry->GetURL()); |
| + EXPECT_EQ(stalled_url, entry->GetURL()); |
| { |
| // Now the existing page uses history.replaceState(). |
| @@ -1070,6 +1069,25 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
| } |
| +} // namespace |
| + |
| +IN_PROC_BROWSER_TEST_F( |
| + NavigationControllerBrowserTest, |
| + NavigationTypeClassification_InPageWhileDifferentPending) { |
| + GURL url1(embedded_test_server()->GetURL( |
| + "/navigation_controller/simple_page_1.html")); |
| + GURL url2(embedded_test_server()->GetURL( |
| + "/navigation_controller/simple_page_2.html")); |
| + DoReplaceStateWhilePending(shell(), url1, url2); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| + NavigationTypeClassification_InPageWhileSamePending) { |
| + GURL url(embedded_test_server()->GetURL( |
| + "/navigation_controller/simple_page_1.html")); |
| + DoReplaceStateWhilePending(shell(), url, url); |
|
Charlie Reis
2015/05/01 19:40:48
Nice.
Can we add a test that does a replaceState
Avi (use Gerrit)
2015/05/01 20:30:57
Done.
|
| +} |
| + |
| // Ensure the renderer process does not get confused about the current entry |
| // due to subframes and replaced entries. See https://crbug.com/480201. |
| IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |