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 f8069f526fb74391a0d02ab6efb8e9ed30a98633..d5d22e03d97d3c828491459690d5f808c388f2c7 100644 |
| --- a/content/browser/frame_host/navigator_impl_unittest.cc |
| +++ b/content/browser/frame_host/navigator_impl_unittest.cc |
| @@ -50,9 +50,10 @@ class NavigatorTestWithBrowserSideNavigation |
| return static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); |
| } |
| - void RequestNavigation(FrameTreeNode* node, const GURL& url) { |
| + int RequestNavigation(FrameTreeNode* node, const GURL& url) { |
| RequestNavigationWithParameters(node, url, Referrer(), |
| ui::PAGE_TRANSITION_LINK); |
| + return controller().GetPendingEntry()->GetUniqueID(); |
|
clamy
2015/04/10 12:05:44
Should the return come from RequestNavigationWithP
Avi (use Gerrit)
2015/04/13 22:42:48
Done.
|
| } |
| void RequestNavigationWithParameters( |
| @@ -113,7 +114,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 = GetNavigationRequestForFrameTreeNode(node); |
| ASSERT_TRUE(request); |
| EXPECT_EQ(kUrl, request->common_params().url); |
| @@ -134,7 +135,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()); |
| @@ -187,7 +188,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()); |
| @@ -232,7 +233,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(GetNavigationRequestForFrameTreeNode(node)); |
| @@ -424,7 +425,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 = GetNavigationRequestForFrameTreeNode(node); |
| ASSERT_TRUE(main_request); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| @@ -441,7 +442,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteNavigation) { |
| EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); |
| EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| - 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); |
| @@ -463,7 +464,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 = GetNavigationRequestForFrameTreeNode(node); |
| ASSERT_TRUE(main_request); |
| @@ -486,7 +487,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); |
| @@ -531,7 +532,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 = GetNavigationRequestForFrameTreeNode(node); |
| ASSERT_TRUE(request2); |
| @@ -555,7 +556,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()); |
| @@ -616,7 +617,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()); |
| @@ -664,7 +665,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()); |
| } |
| @@ -682,7 +683,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 = GetNavigationRequestForFrameTreeNode(node); |
| ASSERT_TRUE(request1); |
| EXPECT_EQ(kUrl1, request1->common_params().url); |
| @@ -712,7 +713,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()); |
| } |
| @@ -760,7 +761,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. |
| @@ -776,6 +777,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 = GetNavigationRequestForFrameTreeNode(node); |
| ASSERT_TRUE(main_request != NULL); |
| @@ -784,7 +786,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. |
| @@ -810,7 +812,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. |
| @@ -835,7 +837,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()); |
| @@ -854,7 +856,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. |
| @@ -903,7 +905,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, |
| @@ -941,7 +943,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, |
| static_cast<MockRenderProcessHost*>(rfh1->GetProcess()) |
| ->sink() |
| .ClearMessages(); |
| - RequestNavigation(node, kUrl1); |
| + int entry_id = RequestNavigation(node, kUrl1); |
| EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| main_test_rfh()->SendBeforeUnloadACK(true); |
| @@ -958,7 +960,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)); |
| @@ -974,7 +976,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 = |
| GetNavigationRequestForFrameTreeNode(node); |
| ASSERT_TRUE(navigation_request); |
| @@ -989,7 +991,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. |