Chromium Code Reviews| Index: content/browser/frame_host/navigation_controller_impl_unittest.cc |
| diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
| index 3492196c00e5244c60c2b447af7a74f9e8abece7..b14362e05bbb0ac7e49458ada2ba887b6d1dc2ef 100644 |
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc |
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
| @@ -35,6 +35,7 @@ |
| #include "content/public/test/mock_render_process_host.h" |
| #include "content/public/test/test_notification_tracker.h" |
| #include "content/public/test/test_utils.h" |
| +#include "content/test/test_navigation_url_loader.h" |
| #include "content/test/test_render_frame_host.h" |
| #include "content/test/test_render_view_host.h" |
| #include "content/test/test_web_contents.h" |
| @@ -245,6 +246,31 @@ class NavigationControllerTest |
| return get<0>(nav_params).common_params.url; |
| } |
| + // PlzNavigate |
| + void SimulateServerRedirect(TestRenderFrameHost* test_rfh, |
|
clamy
2015/02/24 13:05:33
Now that I look at it, this code is very similar t
carlosk
2015/02/24 16:38:56
Done. This does looks better.
|
| + const GURL& redirect_url) { |
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableBrowserSideNavigation)) { |
| + return; |
| + } |
| + |
| + NavigatorImpl* navigator_impl = |
| + static_cast<NavigatorImpl*>(test_rfh->frame_tree_node()->navigator()); |
| + NavigationRequest* request = |
| + navigator_impl->GetNavigationRequestForNodeForTesting( |
| + test_rfh->frame_tree_node()); |
| + CHECK(request); |
| + |
| + if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) |
| + test_rfh->SendBeforeUnloadACK(true); |
| + CHECK(NavigationRequest::STARTED); |
| + |
| + TestNavigationURLLoader* loader = |
| + static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); |
| + CHECK(loader); |
| + loader->SimulateServerRedirect(redirect_url); |
| + } |
| + |
| protected: |
| GURL navigated_url_; |
| size_t navigation_entry_committed_counter_; |
| @@ -316,7 +342,8 @@ TEST_F(NavigationControllerTest, GoToOffset) { |
| urls[i] = GURL(base::StringPrintf("http://www.a.com/%d", i)); |
| } |
| - main_test_rfh()->PrepareForCommit(urls[0]); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[0], true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, urls[0]); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -326,7 +353,8 @@ TEST_F(NavigationControllerTest, GoToOffset) { |
| EXPECT_FALSE(controller.CanGoToOffset(1)); |
| for (int i = 1; i <= 4; ++i) { |
| - main_test_rfh()->PrepareForCommit(urls[i]); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[i], true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(i, urls[i]); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -362,7 +390,7 @@ TEST_F(NavigationControllerTest, GoToOffset) { |
| url_index += offset; |
| // Check that the GoToOffset will land on the expected page. |
| EXPECT_EQ(urls[url_index], controller.GetPendingEntry()->GetVirtualURL()); |
| - main_test_rfh()->PrepareForCommit(urls[url_index]); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(url_index, urls[url_index]); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -407,7 +435,7 @@ TEST_F(NavigationControllerTest, LoadURL) { |
| // We should have gotten no notifications from the preceeding checks. |
| EXPECT_EQ(0U, notifications.size()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -447,7 +475,7 @@ TEST_F(NavigationControllerTest, LoadURL) { |
| // Simulate the beforeunload ack for the cross-site transition, and then the |
| // commit. |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| contents()->GetPendingMainFrame()->SendNavigate(1, url2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -489,7 +517,7 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -500,7 +528,7 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) { |
| // Simulate the beforeunload ack for the cross-site transition, and then the |
| // commit. |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| contents()->GetPendingMainFrame()->SendNavigate(1, url2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -619,7 +647,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| EXPECT_EQ(0U, notifications.size()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -631,7 +659,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| EXPECT_EQ(0U, notifications.size()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -671,7 +699,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) { |
| params.is_post = true; |
| params.post_id = 123; |
| params.page_state = PageState::CreateForTesting(url1, false, 0, 0); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigateWithParams(¶ms); |
| // The post data should be visible. |
| @@ -682,7 +710,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| // We should not have produced a new session history entry. |
| @@ -773,7 +801,7 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) { |
| const GURL kExistingURL1("http://eh"); |
| controller.LoadURL( |
| kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(kExistingURL1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, kExistingURL1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -785,9 +813,9 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) { |
| EXPECT_EQ(0U, notifications.size()); |
| // After the beforeunload but before it commits, do a new navigation. |
| - main_test_rfh()->PrepareForCommit(kExistingURL2); |
| + main_test_rfh()->PrepareForCommit(); |
| const GURL kNewURL("http://see"); |
| - main_test_rfh()->PrepareForCommit(kNewURL); |
| + main_test_rfh()->PrepareForCommit(); |
| contents()->GetMainFrame()->SendNavigate(3, kNewURL); |
| // There should no longer be any pending entry, and the third navigation we |
| @@ -811,7 +839,7 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
| const GURL kExistingURL1("http://foo/eh"); |
| controller.LoadURL( |
| kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(kExistingURL1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, kExistingURL1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -819,7 +847,7 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
| const GURL kExistingURL2("http://foo/bee"); |
| controller.LoadURL( |
| kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(kExistingURL2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, kExistingURL2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -833,7 +861,8 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { |
| // Before that commits, do a new navigation. |
| const GURL kNewURL("http://foo/see"); |
| - main_test_rfh()->PrepareForCommit(kNewURL); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kNewURL, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(3, kNewURL); |
| // There should no longer be any pending entry, and the third navigation we |
| @@ -859,7 +888,7 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { |
| kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| // Pretend it has bindings so we can tell if we incorrectly copy it. |
| main_test_rfh()->GetRenderViewHost()->AllowBindings(2); |
| - main_test_rfh()->PrepareForCommit(kExistingURL1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, kExistingURL1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -868,7 +897,7 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { |
| const GURL kExistingURL2("http://foo/eh"); |
| controller.LoadURL( |
| kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(kExistingURL2); |
| + main_test_rfh()->PrepareForCommit(); |
| TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); |
| foo_rfh->SendNavigate(1, kExistingURL2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| @@ -885,7 +914,8 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { |
| // Before that commits, do a new navigation. |
| const GURL kNewURL("http://foo/bee"); |
| - foo_rfh->PrepareForCommit(kNewURL); |
| + foo_rfh->SendRendererInitiatedNavigationRequest(kNewURL, true); |
| + foo_rfh->PrepareForCommit(); |
| foo_rfh->SendNavigate(3, kNewURL); |
| // There should no longer be any pending entry, and the third navigation we |
| @@ -910,7 +940,7 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
| const GURL kExistingURL1("http://foo/eh"); |
| controller.LoadURL( |
| kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(kExistingURL1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, kExistingURL1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -918,7 +948,7 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
| const GURL kExistingURL2("http://foo/bee"); |
| controller.LoadURL( |
| kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(kExistingURL2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, kExistingURL2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -932,7 +962,8 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) { |
| EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| // Before that commits, a back navigation from the renderer commits. |
| - main_test_rfh()->PrepareForCommit(kExistingURL1); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kExistingURL1, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, kExistingURL1); |
| // There should no longer be any pending entry, and the back navigation we |
| @@ -972,7 +1003,8 @@ TEST_F(NavigationControllerTest, LoadURL_IgnorePreemptsPending) { |
| // Before that commits, a document.write and location.reload can cause the |
| // renderer to send a FrameNavigate with page_id -1. |
| - main_test_rfh()->PrepareForCommit(kExistingURL); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kExistingURL, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(-1, kExistingURL); |
| // This should clear the pending entry and notify of a navigation state |
| @@ -1123,7 +1155,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) { |
| // Commit. |
| TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
| - orig_rfh->PrepareForCommit(url1); |
| + orig_rfh->PrepareForCommit(); |
| orig_rfh->SendNavigate(0, url1); |
| EXPECT_EQ(controller.GetEntryCount(), 1); |
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| @@ -1140,7 +1172,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) { |
| // privileged url. |
| controller.LoadURL( |
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - orig_rfh->PrepareForCommit(url2); |
| + orig_rfh->PrepareForCommit(); |
| TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); |
| new_rfh->GetRenderViewHost()->AllowBindings(1); |
| new_rfh->SendNavigate(1, url2); |
| @@ -1153,7 +1185,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) { |
| // Going back, the first entry should still appear unprivileged. |
| controller.GoBack(); |
| - new_rfh->PrepareForCommit(url1); |
| + new_rfh->PrepareForCommit(); |
| orig_rfh->SendNavigate(0, url1); |
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings()); |
| @@ -1169,7 +1201,7 @@ TEST_F(NavigationControllerTest, Reload) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| EXPECT_EQ(0U, notifications.size()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1194,7 +1226,7 @@ TEST_F(NavigationControllerTest, Reload) { |
| // See http://crbug.com/96041. |
| EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1224,7 +1256,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1232,7 +1264,8 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { |
| controller.Reload(true); |
| EXPECT_EQ(0U, notifications.size()); |
| - main_test_rfh()->PrepareForCommit(url2); |
| + SimulateServerRedirect(main_test_rfh(), url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1290,7 +1323,8 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) { |
| controller.LoadURL( |
| original_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| EXPECT_EQ(0U, notifications.size()); |
| - main_test_rfh()->PrepareForCommit(final_url); |
| + SimulateServerRedirect(main_test_rfh(), final_url); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigateWithOriginalRequestURL( |
| 0, final_url, original_url); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| @@ -1323,7 +1357,8 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) { |
| EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty()); |
| // Send that the navigation has proceeded; say it got redirected again. |
| - main_test_rfh()->PrepareForCommit(final_url); |
| + SimulateServerRedirect(main_test_rfh(), final_url); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, final_url); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1487,14 +1522,14 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| controller.LoadURL( |
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1511,7 +1546,8 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { |
| EXPECT_FALSE(controller.CanGoBack()); |
| EXPECT_TRUE(controller.CanGoForward()); |
| - main_test_rfh()->PrepareForCommit(url3); |
| + SimulateServerRedirect(main_test_rfh(), url3); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, url3); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1569,15 +1605,19 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { |
| const GURL kUrl3("http://foo/3"); |
| // First navigate three places so we have some back history. |
| - main_test_rfh()->PrepareForCommit(kUrl1); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, kUrl1); |
| - main_test_rfh()->PrepareForCommit(kUrl2); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, kUrl2); |
| - main_test_rfh()->PrepareForCommit(kUrl3); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl3, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, kUrl3); |
| // With nothing pending, say we get a navigation to the second entry. |
| - main_test_rfh()->PrepareForCommit(kUrl2); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, kUrl2); |
| // We know all the entries have the same site instance, so we can just grab |
| @@ -1593,7 +1633,7 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { |
| // Now go forward to the last item again and say it was committed. |
| controller.GoForward(); |
| - main_test_rfh()->PrepareForCommit(kUrl3); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, kUrl3); |
| // Now start going back one to the second page. It will be pending. |
| @@ -1601,9 +1641,10 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { |
| EXPECT_EQ(1, controller.GetPendingEntryIndex()); |
| EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| - // Not synthesize a totally new back event to the first page. This will not |
| + // Now synthesize a totally new back event to the first page. This will not |
| // match the pending one. |
| - main_test_rfh()->PrepareForCommit(kUrl1); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, kUrl1); |
| // The committed navigation should clear the pending entry. |
| @@ -1623,18 +1664,18 @@ TEST_F(NavigationControllerTest, Forward) { |
| const GURL url1("http://foo1"); |
| const GURL url2("http://foo2"); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| controller.GoBack(); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1659,7 +1700,7 @@ TEST_F(NavigationControllerTest, Forward) { |
| EXPECT_GE(controller.GetEntryAtIndex(0)->GetTimestamp(), |
| controller.GetEntryAtIndex(1)->GetTimestamp()); |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1692,17 +1733,17 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { |
| const GURL url2("http://foo2"); |
| const GURL url3("http://foo3"); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| controller.GoBack(); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -1719,7 +1760,7 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { |
| EXPECT_TRUE(controller.CanGoBack()); |
| EXPECT_FALSE(controller.CanGoForward()); |
| - main_test_rfh()->PrepareForCommit(url3); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, url3); |
| EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| navigation_entry_committed_counter_ = 0; |
| @@ -2384,7 +2425,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { |
| GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
| controller.LoadURL( |
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(url_index, url); |
| } |
| @@ -2397,7 +2438,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { |
| GURL url(base::StringPrintf("http://www.a.com/%d", url_index)); |
| controller.LoadURL( |
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(url_index, url); |
| url_index++; |
| @@ -2416,7 +2457,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { |
| url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index)); |
| controller.LoadURL( |
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(url_index, url); |
| url_index++; |
| } |
| @@ -2581,18 +2622,18 @@ TEST_F(NavigationControllerTest, Interstitial) { |
| const GURL url1("http://foo"); |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| // Now navigate somewhere with an interstitial. |
| const GURL url2("http://bar"); |
| - controller.LoadURL( |
| - url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| + controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED, |
|
carlosk
2015/02/23 16:42:02
Replaced this at it seemed the test was not using
|
| + std::string()); |
| controller.GetPendingEntry()->set_page_type(PAGE_TYPE_INTERSTITIAL); |
| // At this point the interstitial will be displayed and the load will still |
| // be pending. If the user continues, the load will commit. |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| // The page should be a normal page again. |
| @@ -2613,23 +2654,23 @@ TEST_F(NavigationControllerTest, RemoveEntry) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| controller.LoadURL( |
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| controller.LoadURL( |
| url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url3); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, url3); |
| controller.LoadURL( |
| url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url4); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(3, url4); |
| controller.LoadURL( |
| url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url5); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(4, url5); |
| // Try to remove the last entry. Will fail because it is the current entry. |
| @@ -2644,7 +2685,7 @@ TEST_F(NavigationControllerTest, RemoveEntry) { |
| EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2)); |
| // Now commit and delete the last entry. |
| - main_test_rfh()->PrepareForCommit(url4); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(3, url4); |
| EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1)); |
| EXPECT_EQ(4, controller.GetEntryCount()); |
| @@ -2675,15 +2716,15 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) { |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url1); |
| controller.LoadURL( |
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| controller.LoadURL( |
| url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url3); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, url3); |
| // Go back, but don't commit yet. Check that we can't delete the current |
| @@ -2702,7 +2743,7 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) { |
| EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| // Now commit and ensure we land on the right entry. |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url2); |
| EXPECT_EQ(2, controller.GetEntryCount()); |
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| @@ -2725,11 +2766,11 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| controller.LoadURL( |
| url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url0); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url0); |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url1); |
| notifications.Reset(); |
| @@ -2756,7 +2797,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| // Navigate. |
| controller.LoadURL( |
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, url2); |
| // We should have navigated, transient entry should be gone. |
| @@ -2768,7 +2809,8 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| transient_entry->SetURL(transient_url); |
| controller.SetTransientEntry(transient_entry); |
| EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| - main_test_rfh()->PrepareForCommit(url3); |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, true); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(3, url3); |
| // Transient entry should be gone. |
| EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| @@ -2781,7 +2823,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| transient_entry->SetURL(transient_url); |
| controller.SetTransientEntry(transient_entry); |
| EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| - main_test_rfh()->PrepareForCommit(url4); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(4, url4); |
| EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); |
| EXPECT_EQ(controller.GetEntryCount(), 5); |
| @@ -2797,7 +2839,9 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| // Transient entry should be gone. |
| EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); |
| EXPECT_EQ(controller.GetEntryCount(), 5); |
| - main_test_rfh()->PrepareForCommit(url3); |
| + |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, false); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(3, url3); |
| // Add a transient and go to an entry before the current one. |
| @@ -2811,7 +2855,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
| // Visible entry does not update for history navigations until commit. |
| EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url1); |
| EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| @@ -2826,7 +2870,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| // land on url2 (which is visible after the commit). |
| EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); |
| EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| - main_test_rfh()->PrepareForCommit(url2); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, url2); |
| EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| @@ -2841,7 +2885,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| EXPECT_FALSE(controller.GetTransientEntry()); |
| EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL()); |
| EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| - main_test_rfh()->PrepareForCommit(url3); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(3, url3); |
| EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| @@ -2850,7 +2894,9 @@ TEST_F(NavigationControllerTest, TransientEntry) { |
| transient_entry->SetURL(transient_url); |
| controller.SetTransientEntry(transient_entry); |
| EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| - main_test_rfh()->PrepareForCommit(url3_ref); |
| + |
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(3, url3_ref); |
| // Transient entry should be gone. |
| EXPECT_FALSE(controller.GetTransientEntry()); |
| @@ -2875,7 +2921,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) { |
| // Load |url0|, and start a pending navigation to |url1|. |
| controller.LoadURL( |
| url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| - main_test_rfh()->PrepareForCommit(url0); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url0); |
| controller.LoadURL( |
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| @@ -2898,7 +2944,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) { |
| EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| // Load of |transient_url| completes. |
| - main_test_rfh()->PrepareForCommit(transient_url); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, transient_url); |
| ASSERT_EQ(controller.GetEntryCount(), 2); |
| EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
| @@ -2977,7 +3023,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { |
| url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL()); |
| EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL()); |
| - main_test_rfh()->PrepareForCommit(url0); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(0, url0); |
| // For link clicks (renderer-initiated navigations), the pending entry should |
| @@ -2991,7 +3037,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { |
| // After commit, both visible should be updated, there should be no pending |
| // entry, and we should no longer treat the entry as renderer-initiated. |
| - main_test_rfh()->PrepareForCommit(url1); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(1, url1); |
| EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| EXPECT_FALSE(controller.GetPendingEntry()); |
| @@ -4125,7 +4171,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) { |
| EXPECT_EQ(1, controller.GetEntryCount()); |
| // Try to commit the pending entry. |
| - main_test_rfh()->PrepareForCommit(url3); |
| + main_test_rfh()->PrepareForCommit(); |
| main_test_rfh()->SendNavigate(2, url3); |
| EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| EXPECT_FALSE(controller.GetPendingEntry()); |
| @@ -4414,7 +4460,7 @@ TEST_F(NavigationControllerTest, ClearHistoryList) { |
| // Assume that the RF correctly cleared its history and commit the navigation. |
| if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kEnableBrowserSideNavigation)) { |
| - contents()->GetMainFrame()->PrepareForCommit(entry->GetURL()); |
| + contents()->GetMainFrame()->PrepareForCommit(); |
| } |
| contents()->GetPendingMainFrame()-> |
| set_simulate_history_list_was_cleared(true); |