| 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 03d9d065af5be512cef1d6473a5d8c03d9274009..91603cb645f992f0efe1804cfbff102d2f7e9c2c 100644
|
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| @@ -709,6 +709,7 @@ TEST_F(NavigationControllerTest, LoadURL_Discarded) {
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| EXPECT_EQ(0U, notifications.size());
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -747,13 +748,14 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) {
|
| const GURL kExistingURL1("http://eh");
|
| controller.LoadURL(
|
| kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(0, kExistingURL1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| // Do a new navigation without making a pending one.
|
| const GURL kNewURL("http://see");
|
| - main_test_rfh()->SendNavigate(99, kNewURL);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(99, kNewURL);
|
|
|
| // There should no longer be any pending entry, and the third navigation we
|
| // just made should be committed.
|
| @@ -1062,6 +1064,7 @@ TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) {
|
| const GURL kExistingURL("http://foo/eh");
|
| controller.LoadURL(kExistingURL, content::Referrer(),
|
| ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(1, kExistingURL);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1270,6 +1273,7 @@ TEST_F(NavigationControllerTest, ReloadWithGuest) {
|
| const GURL url1("http://foo1");
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(0, url1);
|
| ASSERT_TRUE(controller.GetVisibleEntry());
|
|
|
| @@ -1364,6 +1368,7 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
|
| const GURL url0("http://foo/0");
|
| controller.LoadURL(
|
| url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(0, url0);
|
|
|
| // Set up the pending entry.
|
| @@ -1394,6 +1399,7 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
|
| EXPECT_TRUE(pending_entry->should_clear_history_list());
|
|
|
| // Fake a commit response.
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(1, url1);
|
|
|
| // Certain values that are only used for pending entries get reset after
|
| @@ -1411,24 +1417,26 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
|
| TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
|
| NavigationControllerImpl& controller = controller_impl();
|
| const GURL url1("http://foo1");
|
| + const GURL url2("http://foo2");
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
|
|
| // Set up some redirect values.
|
| std::vector<GURL> redirects;
|
| - redirects.push_back(GURL("http://foo2"));
|
| + redirects.push_back(url2);
|
|
|
| // Set redirects on the pending entry.
|
| NavigationEntryImpl* pending_entry = controller.GetPendingEntry();
|
| pending_entry->SetRedirectChain(redirects);
|
| EXPECT_EQ(1U, pending_entry->GetRedirectChain().size());
|
| - EXPECT_EQ(GURL("http://foo2"), pending_entry->GetRedirectChain()[0]);
|
| + EXPECT_EQ(url2, pending_entry->GetRedirectChain()[0]);
|
|
|
| // Normal navigation will preserve redirects in the committed entry.
|
| + main_test_rfh()->PrepareForCommitWithServerRedirect(url2);
|
| main_test_rfh()->SendNavigateWithRedirects(0, url1, redirects);
|
| NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry();
|
| ASSERT_EQ(1U, committed_entry->GetRedirectChain().size());
|
| - EXPECT_EQ(GURL("http://foo2"), committed_entry->GetRedirectChain()[0]);
|
| + EXPECT_EQ(url2, committed_entry->GetRedirectChain()[0]);
|
| }
|
|
|
| // Tests what happens when we navigate back successfully
|
| @@ -1438,12 +1446,12 @@ TEST_F(NavigationControllerTest, Back) {
|
| RegisterForAllNavNotifications(¬ifications, &controller);
|
|
|
| const GURL url1("http://foo1");
|
| - main_test_rfh()->SendNavigate(0, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| const GURL url2("http://foo2");
|
| - main_test_rfh()->SendNavigate(1, url2);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, url2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -1467,7 +1475,7 @@ TEST_F(NavigationControllerTest, Back) {
|
| EXPECT_GE(controller.GetEntryAtIndex(1)->GetTimestamp(),
|
| controller.GetEntryAtIndex(0)->GetTimestamp());
|
|
|
| - main_test_rfh()->SendNavigate(0, url2);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -1552,12 +1560,12 @@ TEST_F(NavigationControllerTest, Back_NewPending) {
|
| const GURL kUrl3("http://foo3");
|
|
|
| // First navigate two places so we have some back history.
|
| - main_test_rfh()->SendNavigate(0, kUrl1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, kUrl1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| // controller.LoadURL(kUrl2, ui::PAGE_TRANSITION_TYPED);
|
| - main_test_rfh()->SendNavigate(1, kUrl2);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, kUrl2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -1938,7 +1946,7 @@ TEST_F(NavigationControllerTest, NewSubframe) {
|
| RegisterForAllNavNotifications(¬ifications, &controller);
|
|
|
| const GURL url1("http://foo1");
|
| - main_test_rfh()->SendNavigate(0, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -1980,7 +1988,7 @@ TEST_F(NavigationControllerTest, AutoSubframe) {
|
| RegisterForAllNavNotifications(¬ifications, &controller);
|
|
|
| const GURL url1("http://foo/1");
|
| - main_test_rfh()->SendNavigate(1, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -2079,7 +2087,7 @@ TEST_F(NavigationControllerTest, BackSubframe) {
|
|
|
| // Main page.
|
| const GURL url1("http://foo1");
|
| - main_test_rfh()->SendNavigate(0, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -2151,11 +2159,11 @@ TEST_F(NavigationControllerTest, LinkClick) {
|
| const GURL url1("http://foo1");
|
| const GURL url2("http://foo2");
|
|
|
| - main_test_rfh()->SendNavigate(0, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| - main_test_rfh()->SendNavigate(1, url2);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, url2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -2176,7 +2184,7 @@ TEST_F(NavigationControllerTest, InPage) {
|
|
|
| // Main page.
|
| const GURL url1("http://foo");
|
| - main_test_rfh()->SendNavigate(0, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -2285,7 +2293,7 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
|
|
|
| // Main page.
|
| const GURL url1("http://foo");
|
| - main_test_rfh()->SendNavigate(0, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -2326,7 +2334,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
|
| // Load an initial page.
|
| {
|
| const GURL url("http://foo/");
|
| - main_test_rfh()->SendNavigate(0, url);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| }
|
| @@ -2334,7 +2342,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
|
| // Navigate to a new page.
|
| {
|
| const GURL url("http://foo2/");
|
| - main_test_rfh()->SendNavigate(1, url);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, url);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| }
|
| @@ -2392,6 +2400,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
|
| {
|
| const GURL url("http://foo2/");
|
| controller.GoBack();
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(1, url);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -2408,6 +2417,8 @@ TEST_F(NavigationControllerTest, PushStateWithoutPreviousEntry)
|
| params.url = url;
|
| params.page_state = PageState::CreateFromURL(url);
|
| params.was_within_same_page = true;
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false);
|
| + main_test_rfh()->PrepareForCommit();
|
| contents()->GetMainFrame()->SendNavigateWithParams(¶ms);
|
| // We pass if we don't crash.
|
| }
|
| @@ -3010,6 +3021,8 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
|
| EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated());
|
|
|
| // If the user clicks another link, we should replace the pending entry.
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false);
|
| + main_test_rfh()->PrepareForCommit();
|
| navigator->DidStartProvisionalLoad(main_test_rfh(), url2, false);
|
| EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL());
|
| EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL());
|
| @@ -3030,11 +3043,11 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
|
| // http://crbug.com/308444.
|
| navigator->DidStartProvisionalLoad(main_test_rfh(), url1, false);
|
| controller.GetPendingEntry()->set_should_replace_entry(true);
|
| +
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false);
|
| + main_test_rfh()->PrepareForCommit();
|
| navigator->DidStartProvisionalLoad(main_test_rfh(), url2, false);
|
| EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry());
|
| - // TODO(nasko): Until OnNavigate is moved to RenderFrameHost, we need
|
| - // to go through the RenderViewHost. The TestRenderViewHost routes navigations
|
| - // to the main frame.
|
| main_test_rfh()->SendNavigate(0, url2);
|
| EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
|
| }
|
| @@ -3235,6 +3248,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLInNewTabAfterCommit) {
|
| EXPECT_FALSE(contents()->HasAccessedInitialDocument());
|
|
|
| // Simulate a commit and then starting a new pending navigation.
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigate(0, url1);
|
| NavigationController::LoadURLParams load_url2_params(url2);
|
| load_url2_params.transition_type = ui::PAGE_TRANSITION_LINK;
|
| @@ -3265,12 +3279,12 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
|
| // was the first document in the given frame, but we don't have enough
|
| // information to identify that case currently.
|
| const GURL blank_url(url::kAboutBlankURL);
|
| - main_test_rfh()->SendNavigate(0, blank_url);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, blank_url);
|
| EXPECT_TRUE(controller.IsURLInPageNavigation(url, true,
|
| main_test_rfh()));
|
|
|
| // Navigate to URL with no refs.
|
| - main_test_rfh()->SendNavigate(0, url);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
|
|
|
| // Reloading the page is not an in-page navigation.
|
| EXPECT_FALSE(controller.IsURLInPageNavigation(url, false,
|
| @@ -3283,7 +3297,7 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
|
| main_test_rfh()));
|
|
|
| // Navigate to URL with refs.
|
| - main_test_rfh()->SendNavigate(1, url_with_ref);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, url_with_ref);
|
|
|
| // Reloading the page is not an in-page navigation.
|
| EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref, false,
|
| @@ -3322,14 +3336,14 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
|
| EXPECT_TRUE(prefs.allow_universal_access_from_file_urls);
|
| // Allow in page navigation if existing URL is file scheme.
|
| const GURL file_url("file:///foo/index.html");
|
| - main_test_rfh()->SendNavigate(0, file_url);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, file_url);
|
| EXPECT_EQ(0, rph->bad_msg_count());
|
| EXPECT_TRUE(controller.IsURLInPageNavigation(different_origin_url, true,
|
| main_test_rfh()));
|
| EXPECT_EQ(0, rph->bad_msg_count());
|
| // Don't honor allow_universal_access_from_file_urls if existing URL is
|
| // not file scheme.
|
| - main_test_rfh()->SendNavigate(0, url);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
|
| EXPECT_FALSE(controller.IsURLInPageNavigation(different_origin_url, true,
|
| main_test_rfh()));
|
| EXPECT_EQ(1, rph->bad_msg_count());
|
| @@ -3356,7 +3370,7 @@ TEST_F(NavigationControllerTest, SameSubframe) {
|
| NavigationControllerImpl& controller = controller_impl();
|
| // Navigate the main frame.
|
| const GURL url("http://www.google.com/");
|
| - main_test_rfh()->SendNavigate(0, url);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
|
|
|
| // We should be at the first navigation entry.
|
| EXPECT_EQ(controller.GetEntryCount(), 1);
|
| @@ -4247,7 +4261,7 @@ TEST_F(NavigationControllerTest, IsInitialNavigation) {
|
|
|
| // After commit, it stays false.
|
| const GURL url1("http://foo1");
|
| - main_test_rfh()->SendNavigate(0, url1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| EXPECT_FALSE(controller.IsInitialNavigation());
|
| @@ -4270,7 +4284,7 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
|
| TestNotificationTracker notifications;
|
| RegisterForAllNavNotifications(¬ifications, &controller);
|
|
|
| - main_test_rfh()->SendNavigate(0, kPageWithFavicon);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, kPageWithFavicon);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -4285,6 +4299,9 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
|
| favicon_status.valid = true;
|
| EXPECT_FALSE(DoImagesMatch(kDefaultFavicon, entry->GetFavicon().image));
|
|
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kPageWithoutFavicon,
|
| + false);
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigateWithTransition(
|
| 0, // same page ID.
|
| kPageWithoutFavicon,
|
| @@ -4310,7 +4327,7 @@ TEST_F(NavigationControllerTest, BackNavigationDoesNotClearFavicon) {
|
| TestNotificationTracker notifications;
|
| RegisterForAllNavNotifications(¬ifications, &controller);
|
|
|
| - main_test_rfh()->SendNavigate(0, kUrl1);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(0, kUrl1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -4324,9 +4341,11 @@ TEST_F(NavigationControllerTest, BackNavigationDoesNotClearFavicon) {
|
| favicon_status.valid = true;
|
|
|
| // Navigate to another page and go back to the original page.
|
| - main_test_rfh()->SendNavigate(1, kUrl2);
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, kUrl2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, false);
|
| + main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigateWithTransition(
|
| 0,
|
| kUrl1,
|
| @@ -4430,7 +4449,7 @@ TEST_F(NavigationControllerTest, MAYBE_PurgeScreenshot) {
|
|
|
| TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) {
|
| // Navigate.
|
| - contents()->GetMainFrame()->SendNavigate(1, GURL("http://foo"));
|
| + main_test_rfh()->NavigateAndCommitRendererInitiated(1, GURL("http://foo"));
|
|
|
| // Set title and favicon.
|
| base::string16 title(base::ASCIIToUTF16("Title"));
|
| @@ -4442,12 +4461,14 @@ TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) {
|
|
|
| // history.pushState() is called.
|
| FrameHostMsg_DidCommitProvisionalLoad_Params params;
|
| - GURL url("http://foo#foo");
|
| + GURL kUrl2("http://foo#foo");
|
| params.page_id = 2;
|
| - params.url = url;
|
| - params.page_state = PageState::CreateFromURL(url);
|
| + params.url = kUrl2;
|
| + params.page_state = PageState::CreateFromURL(kUrl2);
|
| params.was_within_same_page = true;
|
| - contents()->GetMainFrame()->SendNavigateWithParams(¶ms);
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
|
| + main_test_rfh()->PrepareForCommit();
|
| + main_test_rfh()->SendNavigateWithParams(¶ms);
|
|
|
| // The title should immediately be visible on the new NavigationEntry.
|
| base::string16 new_title =
|
| @@ -4527,6 +4548,8 @@ TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
|
| params.was_within_same_page = false;
|
| params.is_post = true;
|
| params.post_id = 2;
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false);
|
| + main_test_rfh()->PrepareForCommit();
|
| contents()->GetMainFrame()->SendNavigateWithParams(¶ms);
|
|
|
| // history.replaceState() is called.
|
| @@ -4539,6 +4562,8 @@ TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
|
| params.was_within_same_page = true;
|
| params.is_post = false;
|
| params.post_id = -1;
|
| + main_test_rfh()->SendRendererInitiatedNavigationRequest(replace_url, false);
|
| + main_test_rfh()->PrepareForCommit();
|
| contents()->GetMainFrame()->SendNavigateWithParams(¶ms);
|
|
|
| // Now reload. replaceState overrides the POST, so we should not show a
|
|
|