Chromium Code Reviews| Index: content/browser/frame_host/navigator_impl_unittest.cc |
| diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc |
| index d265010d48eb50848c73d2510a3c7136ee9d891e..b11a0bbcb17c84aebee30c7bf7b87d1303268f53 100644 |
| --- a/content/browser/frame_host/navigator_impl_unittest.cc |
| +++ b/content/browser/frame_host/navigator_impl_unittest.cc |
| @@ -50,12 +50,12 @@ class NavigatorTestWithBrowserSideNavigation |
| return static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); |
| } |
| - void RequestNavigation(FrameTreeNode* node, const GURL& url) { |
| - RequestNavigationWithParameters(node, url, Referrer(), |
| - ui::PAGE_TRANSITION_LINK); |
| + int RequestNavigation(FrameTreeNode* node, const GURL& url) { |
| + return RequestNavigationWithParameters(node, url, Referrer(), |
| + ui::PAGE_TRANSITION_LINK); |
| } |
| - void RequestNavigationWithParameters( |
| + int RequestNavigationWithParameters( |
|
Charlie Reis
2015/04/22 05:27:25
Let's put comments on these saying what they're re
Avi (use Gerrit)
2015/04/22 18:31:50
Done.
|
| FrameTreeNode* node, |
| const GURL& url, |
| const Referrer& referrer, |
| @@ -66,6 +66,7 @@ class NavigatorTestWithBrowserSideNavigation |
| load_params.transition_type = transition_type; |
| controller().LoadURLWithParams(load_params); |
| + return controller().GetPendingEntry()->GetUniqueID(); |
| } |
| TestRenderFrameHost* GetSpeculativeRenderFrameHost(FrameTreeNode* node) { |
| @@ -105,7 +106,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| // Start a browser-initiated navigation. |
| int32 site_instance_id = main_test_rfh()->GetSiteInstance()->GetId(); |
| FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| - RequestNavigation(node, kUrl); |
| + int entry_id = RequestNavigation(node, kUrl); |
| NavigationRequest* request = node->navigation_request(); |
| ASSERT_TRUE(request); |
| EXPECT_EQ(kUrl, request->common_params().url); |
| @@ -126,7 +127,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state()); |
| // Commit the navigation. |
| - main_test_rfh()->SendNavigate(0, kUrl); |
| + main_test_rfh()->SendNavigate(0, entry_id, true, kUrl); |
| EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); |
| EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), |
| main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
| @@ -179,7 +180,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state()); |
| // Commit the navigation. |
| - main_test_rfh()->SendNavigate(0, kUrl2); |
| + main_test_rfh()->SendNavigate(1, 0, true, kUrl2); |
| EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); |
| EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl2), |
| main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
| @@ -224,7 +225,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state()); |
| // Commit the navigation. |
| - main_test_rfh()->SendNavigate(0, kUrl2); |
| + main_test_rfh()->SendNavigate(1, 0, true, kUrl2); |
| EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); |
| EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL()); |
| EXPECT_FALSE(node->navigation_request()); |
| @@ -414,7 +415,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteNavigation) { |
| // Navigate to a different site. |
| process()->sink().ClearMessages(); |
| - RequestNavigation(node, kUrl2); |
| + int entry_id = RequestNavigation(node, kUrl2); |
| NavigationRequest* main_request = node->navigation_request(); |
| ASSERT_TRUE(main_request); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| @@ -433,7 +434,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteNavigation) { |
| EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| EXPECT_TRUE(contents()->CrossProcessNavigationPending()); |
| - speculative_rfh->SendNavigate(0, kUrl2); |
| + speculative_rfh->SendNavigate(0, entry_id, true, kUrl2); |
| RenderFrameHostImpl* final_rfh = main_test_rfh(); |
| EXPECT_EQ(speculative_rfh, final_rfh); |
| @@ -455,7 +456,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, RedirectCrossSite) { |
| // Navigate to a URL on the same site. |
| process()->sink().ClearMessages(); |
| - RequestNavigation(node, kUrl1); |
| + int entry_id = RequestNavigation(node, kUrl1); |
| main_test_rfh()->SendBeforeUnloadACK(true); |
| NavigationRequest* main_request = node->navigation_request(); |
| ASSERT_TRUE(main_request); |
| @@ -478,7 +479,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, RedirectCrossSite) { |
| EXPECT_TRUE(DidRenderFrameHostRequestCommit(final_speculative_rfh)); |
| // Commit the navigation. |
| - final_speculative_rfh->SendNavigate(0, kUrl2); |
| + final_speculative_rfh->SendNavigate(0, entry_id, true, kUrl2); |
| RenderFrameHostImpl* final_rfh = main_test_rfh(); |
| ASSERT_TRUE(final_rfh); |
| EXPECT_NE(rfh, final_rfh); |
| @@ -523,7 +524,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| // Request navigation to the 2nd URL; the NavigationRequest must have been |
| // replaced by a new one with a different URL. |
| - RequestNavigation(node, kUrl2); |
| + int entry_id = RequestNavigation(node, kUrl2); |
| main_test_rfh()->SendBeforeUnloadACK(true); |
| NavigationRequest* request2 = node->navigation_request(); |
| ASSERT_TRUE(request2); |
| @@ -547,7 +548,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| // Commit the navigation. |
| - speculative_rfh->SendNavigate(0, kUrl2); |
| + speculative_rfh->SendNavigate(0, entry_id, true, kUrl2); |
| // Confirm that the commit corresponds to the new request. |
| ASSERT_TRUE(main_test_rfh()); |
| @@ -608,7 +609,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| // Commit the navigation. |
| - main_test_rfh()->SendNavigate(0, kUrl2); |
| + main_test_rfh()->SendNavigate(1, 0, true, kUrl2); |
| // Confirm that the commit corresponds to the new request. |
| ASSERT_TRUE(main_test_rfh()); |
| @@ -656,7 +657,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| // Commit the navigation. |
| - main_test_rfh()->SendNavigate(0, kUrl1); |
| + main_test_rfh()->SendNavigate(1, 0, true, kUrl1); |
| EXPECT_EQ(kUrl1, contents()->GetLastCommittedURL()); |
| } |
| @@ -674,7 +675,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| // Start a browser-initiated navigation to the 1st URL. |
| process()->sink().ClearMessages(); |
| - RequestNavigation(node, kUrl1); |
| + int entry_id = RequestNavigation(node, kUrl1); |
| NavigationRequest* request1 = node->navigation_request(); |
| ASSERT_TRUE(request1); |
| EXPECT_EQ(kUrl1, request1->common_params().url); |
| @@ -704,7 +705,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| // Commit the navigation. |
| - speculative_rfh->SendNavigate(0, kUrl1); |
| + speculative_rfh->SendNavigate(0, entry_id, true, kUrl1); |
| EXPECT_EQ(kUrl1, contents()->GetLastCommittedURL()); |
| } |
| @@ -752,7 +753,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| // Commit the navigation. |
| - main_test_rfh()->SendNavigate(0, kUrl2); |
| + main_test_rfh()->SendNavigate(1, 0, true, kUrl2); |
| EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL()); |
| // The SiteInstance did not change. |
| @@ -768,6 +769,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) { |
| FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| controller().Reload(false); |
| + int entry_id = controller().GetPendingEntry()->GetUniqueID(); |
| // A NavigationRequest should have been generated. |
| NavigationRequest* main_request = node->navigation_request(); |
| ASSERT_TRUE(main_request != NULL); |
| @@ -776,7 +778,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) { |
| main_test_rfh()->PrepareForCommit(); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| - main_test_rfh()->SendNavigate(0, kUrl); |
| + main_test_rfh()->SendNavigate(0, entry_id, false, kUrl); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| // Now do a shift+reload. |
| @@ -802,7 +804,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| // Begin navigating to another site. |
| const GURL kUrl("http://google.com/"); |
| process()->sink().ClearMessages(); |
| - RequestNavigation(node, kUrl); |
| + int entry_id = RequestNavigation(node, kUrl); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| // Receive the beforeUnload ACK. |
| @@ -827,7 +829,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_FALSE(node->render_manager()->pending_frame_host()); |
| // Invoke OnDidCommitProvisionalLoad. |
| - speculative_rfh->SendNavigate(0, kUrl); |
| + speculative_rfh->SendNavigate(0, entry_id, true, kUrl); |
| EXPECT_EQ(site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| EXPECT_FALSE(node->render_manager()->pending_frame_host()); |
| @@ -846,7 +848,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| // Begin navigating to another site. |
| const GURL kUrl("http://google.com/"); |
| process()->sink().ClearMessages(); |
| - RequestNavigation(node, kUrl); |
| + int entry_id = RequestNavigation(node, kUrl); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| // Receive the beforeUnload ACK. |
| @@ -895,7 +897,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_NE(site_instance_id, redirect_site_instance_id); |
| // Invoke OnDidCommitProvisionalLoad. |
| - speculative_rfh->SendNavigate(0, kUrlRedirect); |
| + speculative_rfh->SendNavigate(0, entry_id, true, kUrlRedirect); |
| // Check that the speculative RenderFrameHost was swapped in. |
| EXPECT_EQ(redirect_site_instance_id, |
| @@ -931,7 +933,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| // should be reused. |
| process()->sink().ClearMessages(); |
| rfh1->GetProcess()->sink().ClearMessages(); |
| - RequestNavigation(node, kUrl1); |
| + int entry_id = RequestNavigation(node, kUrl1); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| main_test_rfh()->SendBeforeUnloadACK(true); |
| @@ -948,7 +950,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); |
| EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| - rfh1->SendNavigate(1, kUrl1); |
| + rfh1->SendNavigate(1, entry_id, true, kUrl1); |
| EXPECT_EQ(rfh1, main_test_rfh()); |
| EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); |
| @@ -964,7 +966,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) { |
| FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| // Navigate to a data url. |
| - RequestNavigation(node, kUrl2); |
| + int entry_id = RequestNavigation(node, kUrl2); |
| NavigationRequest* navigation_request = node->navigation_request(); |
| ASSERT_TRUE(navigation_request); |
| EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, |
| @@ -978,7 +980,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) { |
| EXPECT_FALSE(navigation_request->loader_for_testing()); |
| TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| ASSERT_TRUE(speculative_rfh); |
| - speculative_rfh->SendNavigate(0, kUrl2); |
| + speculative_rfh->SendNavigate(0, entry_id, true, kUrl2); |
| EXPECT_EQ(main_test_rfh(), speculative_rfh); |
| // Go back to the initial site. |