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..cb14e671d543d1c87251ababcc7d03d01e5e2e3b 100644 |
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc |
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
@@ -316,7 +316,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 +327,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 +364,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 +409,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 +449,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 +491,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 +502,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 +621,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 +633,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 +673,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 +684,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 +775,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 +787,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 +813,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 +821,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 +835,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 +862,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 +871,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 +888,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 +914,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 +922,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 +936,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 +977,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 +1129,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 +1146,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 +1159,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 +1175,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 +1200,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 +1230,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 +1238,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { |
controller.Reload(true); |
EXPECT_EQ(0U, notifications.size()); |
- main_test_rfh()->PrepareForCommit(url2); |
+ main_test_rfh()->PrepareForCommitWithServerRedirect(url2); |
main_test_rfh()->SendNavigate(1, url2); |
EXPECT_EQ(1U, navigation_entry_committed_counter_); |
navigation_entry_committed_counter_ = 0; |
@@ -1290,7 +1296,7 @@ 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); |
+ main_test_rfh()->PrepareForCommitWithServerRedirect(final_url); |
main_test_rfh()->SendNavigateWithOriginalRequestURL( |
0, final_url, original_url); |
EXPECT_EQ(1U, navigation_entry_committed_counter_); |
@@ -1323,7 +1329,7 @@ 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); |
+ main_test_rfh()->PrepareForCommitWithServerRedirect(final_url); |
main_test_rfh()->SendNavigate(0, final_url); |
EXPECT_EQ(1U, navigation_entry_committed_counter_); |
navigation_entry_committed_counter_ = 0; |
@@ -1487,14 +1493,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 +1517,7 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { |
EXPECT_FALSE(controller.CanGoBack()); |
EXPECT_TRUE(controller.CanGoForward()); |
- main_test_rfh()->PrepareForCommit(url3); |
+ main_test_rfh()->PrepareForCommitWithServerRedirect(url3); |
main_test_rfh()->SendNavigate(2, url3); |
EXPECT_EQ(1U, navigation_entry_committed_counter_); |
navigation_entry_committed_counter_ = 0; |
@@ -1569,15 +1575,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 +1603,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 +1611,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 +1634,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 +1670,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 +1703,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 +1730,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 +2395,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 +2408,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 +2427,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 +2592,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, |
+ 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 +2624,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 +2655,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 +2686,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 +2713,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 +2736,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 +2767,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 +2779,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 +2793,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 +2809,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 +2825,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 +2840,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 +2855,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 +2864,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 +2891,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 +2914,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 +2993,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 +3007,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 +4141,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()); |
@@ -4411,10 +4427,11 @@ TEST_F(NavigationControllerTest, ClearHistoryList) { |
ASSERT_TRUE(entry); |
EXPECT_TRUE(entry->should_clear_history_list()); |
- // Assume that the RF correctly cleared its history and commit the navigation. |
+ // Assume that the RenderFrame correctly cleared its history and commit the |
+ // navigation. |
if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kEnableBrowserSideNavigation)) { |
nasko
2015/03/03 16:38:34
I would've expected this CL to remove those condit
carlosk
2015/03/04 09:46:55
Acknowledged. The fix for that would add a lot mor
|
- contents()->GetMainFrame()->PrepareForCommit(entry->GetURL()); |
+ contents()->GetMainFrame()->SendBeforeUnloadACK(true); |
} |
contents()->GetPendingMainFrame()-> |
set_simulate_history_list_was_cleared(true); |