| 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 7820fca49c13015f0c0b07860a8779ebb10d6126..aa16932bab178ec822425b8e2f2a3f3cd1fb7c1e 100644
|
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| @@ -15,7 +15,9 @@
|
| #include "content/browser/frame_host/navigation_controller_impl.h"
|
| #include "content/browser/frame_host/navigation_entry_impl.h"
|
| #include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
|
| +#include "content/browser/frame_host/navigation_request.h"
|
| #include "content/browser/frame_host/navigator.h"
|
| +#include "content/browser/frame_host/navigator_impl.h"
|
| #include "content/browser/site_instance_impl.h"
|
| #include "content/browser/web_contents/web_contents_impl.h"
|
| #include "content/common/frame_messages.h"
|
| @@ -213,22 +215,30 @@ class NavigationControllerTest
|
| return static_cast<NavigationControllerImpl&>(controller());
|
| }
|
|
|
| - const IPC::Message* GetLastNavigationRequest() {
|
| + bool HasNavigationRequest() {
|
| if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kEnableBrowserSideNavigation)) {
|
| - return process()->sink().GetFirstMessageMatching(
|
| - FrameMsg_RequestNavigation::ID);
|
| + FrameTreeNode* root = contents()->GetFrameTree()->root();
|
| + NavigationRequest* navigation_request = static_cast<NavigatorImpl*>(
|
| + root->navigator())->GetNavigationRequestForNodeForTesting(root);
|
| + return navigation_request != nullptr;
|
| }
|
| - return process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
|
| + return process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID)
|
| + != nullptr;
|
| }
|
|
|
| - const GURL GetNavigationURLFromIPC(const IPC::Message* message) {
|
| + const GURL GetLastNavigationURL() {
|
| if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kEnableBrowserSideNavigation)) {
|
| - Tuple<CommonNavigationParams, RequestNavigationParams> nav_params;
|
| - FrameMsg_RequestNavigation::Read(message, &nav_params);
|
| - return get<0>(nav_params).url;
|
| + FrameTreeNode* root = contents()->GetFrameTree()->root();
|
| + NavigationRequest* navigation_request = static_cast<NavigatorImpl*>(
|
| + root->navigator())->GetNavigationRequestForNodeForTesting(root);
|
| + CHECK(navigation_request);
|
| + return navigation_request->common_params().url;
|
| }
|
| + const IPC::Message* message =
|
| + process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
|
| + CHECK(message);
|
| Tuple<FrameMsg_Navigate_Params> nav_params;
|
| FrameMsg_Navigate::Read(message, &nav_params);
|
| return get<0>(nav_params).common_params.url;
|
| @@ -309,6 +319,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
|
| urls[i] = GURL(base::StringPrintf("http://www.a.com/%d", i));
|
| }
|
|
|
| + main_test_rfh()->PrepareForCommit(urls[0]);
|
| main_test_rfh()->SendNavigate(0, urls[0]);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -318,6 +329,7 @@ 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()->SendNavigate(i, urls[i]);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -353,6 +365,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()->SendNavigate(url_index, urls[url_index]);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -480,6 +493,7 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
|
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| main_test_rfh()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -490,8 +504,8 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
|
|
|
| // Simulate the beforeunload ack for the cross-site transition, and then the
|
| // commit.
|
| - main_test_rfh()->SendBeforeUnloadACK(true);
|
| - main_test_rfh()->SendNavigate(1, url2);
|
| + main_test_rfh()->PrepareForCommit(url2);
|
| + contents()->GetPendingMainFrame()->SendNavigate(1, url2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| @@ -615,6 +629,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()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -626,6 +641,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()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -665,6 +681,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()->SendNavigateWithParams(¶ms);
|
|
|
| // The post data should be visible.
|
| @@ -675,6 +692,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()->SendNavigate(0, url1);
|
|
|
| // We should not have produced a new session history entry.
|
| @@ -765,6 +783,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()->SendNavigate(0, kExistingURL1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -778,6 +797,7 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
|
| // After the beforeunload but before it commits, do a new navigation.
|
| main_test_rfh()->PrepareForCommit(kExistingURL2);
|
| const GURL kNewURL("http://see");
|
| + main_test_rfh()->PrepareForCommit(kNewURL);
|
| contents()->GetMainFrame()->SendNavigate(3, kNewURL);
|
|
|
| // There should no longer be any pending entry, and the third navigation we
|
| @@ -801,6 +821,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()->SendNavigate(0, kExistingURL1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -808,6 +829,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()->SendNavigate(1, kExistingURL2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -821,6 +843,7 @@ 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()->SendNavigate(3, kNewURL);
|
|
|
| // There should no longer be any pending entry, and the third navigation we
|
| @@ -873,6 +896,7 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
|
|
|
| // Before that commits, do a new navigation.
|
| const GURL kNewURL("http://foo/bee");
|
| + foo_rfh->PrepareForCommit(kNewURL);
|
| foo_rfh->SendNavigate(3, kNewURL);
|
|
|
| // There should no longer be any pending entry, and the third navigation we
|
| @@ -898,6 +922,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()->SendNavigate(0, kExistingURL1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -905,6 +930,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()->SendNavigate(1, kExistingURL2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -918,6 +944,7 @@ 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()->SendNavigate(0, kExistingURL1);
|
|
|
| // There should no longer be any pending entry, and the back navigation we
|
| @@ -957,6 +984,7 @@ 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()->SendNavigate(-1, kExistingURL);
|
|
|
| // This should clear the pending entry and notify of a navigation state
|
| @@ -1140,7 +1168,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
|
|
|
| // Going back, the first entry should still appear unprivileged.
|
| controller.GoBack();
|
| - new_rfh->SendBeforeUnloadACK(true);
|
| + new_rfh->PrepareForCommit(url1);
|
| orig_rfh->SendNavigate(0, url1);
|
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
|
| EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry(
|
| @@ -1157,6 +1185,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()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1181,6 +1210,7 @@ TEST_F(NavigationControllerTest, Reload) {
|
| // See http://crbug.com/96041.
|
| EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty());
|
|
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| main_test_rfh()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1210,6 +1240,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
|
|
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| main_test_rfh()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1217,6 +1248,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
|
| controller.Reload(true);
|
| EXPECT_EQ(0U, notifications.size());
|
|
|
| + main_test_rfh()->PrepareForCommit(url2);
|
| main_test_rfh()->SendNavigate(1, url2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1276,6 +1308,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()->SendNavigateWithOriginalRequestURL(
|
| 0, final_url, original_url);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| @@ -1308,6 +1341,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()->SendNavigate(0, final_url);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1469,12 +1503,14 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
|
|
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| 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()->SendNavigate(1, url2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1491,6 +1527,7 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
|
| EXPECT_FALSE(controller.CanGoBack());
|
| EXPECT_TRUE(controller.CanGoForward());
|
|
|
| + main_test_rfh()->PrepareForCommit(url3);
|
| main_test_rfh()->SendNavigate(2, url3);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1548,11 +1585,15 @@ 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()->SendNavigate(0, kUrl1);
|
| + main_test_rfh()->PrepareForCommit(kUrl2);
|
| main_test_rfh()->SendNavigate(1, kUrl2);
|
| + main_test_rfh()->PrepareForCommit(kUrl3);
|
| 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()->SendNavigate(1, kUrl2);
|
|
|
| // We know all the entries have the same site instance, so we can just grab
|
| @@ -1569,6 +1610,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()->SendNavigate(2, kUrl3);
|
|
|
| // Now start going back one to the second page. It will be pending.
|
| @@ -1578,6 +1620,7 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
|
|
|
| // Not 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()->SendNavigate(0, kUrl1);
|
|
|
| // The committed navigation should clear the pending entry.
|
| @@ -1597,15 +1640,18 @@ TEST_F(NavigationControllerTest, Forward) {
|
| const GURL url1("http://foo1");
|
| const GURL url2("http://foo2");
|
|
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| 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()->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()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1630,6 +1676,7 @@ TEST_F(NavigationControllerTest, Forward) {
|
| EXPECT_GE(controller.GetEntryAtIndex(0)->GetTimestamp(),
|
| controller.GetEntryAtIndex(1)->GetTimestamp());
|
|
|
| + main_test_rfh()->PrepareForCommit(url2);
|
| main_test_rfh()->SendNavigate(1, url2);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1662,14 +1709,17 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
|
| const GURL url2("http://foo2");
|
| const GURL url3("http://foo3");
|
|
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| 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()->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()->SendNavigate(0, url1);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -1686,6 +1736,7 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
|
| EXPECT_TRUE(controller.CanGoBack());
|
| EXPECT_FALSE(controller.CanGoForward());
|
|
|
| + main_test_rfh()->PrepareForCommit(url3);
|
| main_test_rfh()->SendNavigate(2, url3);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| @@ -2347,6 +2398,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()->SendNavigate(url_index, url);
|
| }
|
|
|
| @@ -2359,6 +2411,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()->SendNavigate(url_index, url);
|
| url_index++;
|
|
|
| @@ -2377,6 +2430,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()->SendNavigate(url_index, url);
|
| url_index++;
|
| }
|
| @@ -2553,6 +2607,7 @@ 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()->SendNavigate(0, url1);
|
|
|
| // Now navigate somewhere with an interstitial.
|
| @@ -2564,6 +2619,7 @@ TEST_F(NavigationControllerTest, 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()->SendNavigate(1, url2);
|
|
|
| // The page should be a normal page again.
|
| @@ -2584,18 +2640,23 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
|
|
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| main_test_rfh()->SendNavigate(0, url1);
|
| controller.LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url2);
|
| main_test_rfh()->SendNavigate(1, url2);
|
| controller.LoadURL(
|
| url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url3);
|
| main_test_rfh()->SendNavigate(2, url3);
|
| controller.LoadURL(
|
| url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url4);
|
| main_test_rfh()->SendNavigate(3, url4);
|
| controller.LoadURL(
|
| url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url5);
|
| main_test_rfh()->SendNavigate(4, url5);
|
|
|
| // Try to remove the last entry. Will fail because it is the current entry.
|
| @@ -2610,6 +2671,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()->SendNavigate(3, url4);
|
| EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
|
| EXPECT_EQ(4, controller.GetEntryCount());
|
| @@ -2640,12 +2702,15 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
|
|
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| main_test_rfh()->SendNavigate(0, url1);
|
| controller.LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url2);
|
| main_test_rfh()->SendNavigate(1, url2);
|
| controller.LoadURL(
|
| url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url3);
|
| main_test_rfh()->SendNavigate(2, url3);
|
|
|
| // Go back, but don't commit yet. Check that we can't delete the current
|
| @@ -2664,6 +2729,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()->SendNavigate(1, url2);
|
| EXPECT_EQ(2, controller.GetEntryCount());
|
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
|
| @@ -2686,9 +2752,11 @@ TEST_F(NavigationControllerTest, TransientEntry) {
|
|
|
| controller.LoadURL(
|
| url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url0);
|
| main_test_rfh()->SendNavigate(0, url0);
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url1);
|
| main_test_rfh()->SendNavigate(1, url1);
|
|
|
| notifications.Reset();
|
| @@ -2715,6 +2783,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
|
| // Navigate.
|
| controller.LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->PrepareForCommit(url2);
|
| main_test_rfh()->SendNavigate(2, url2);
|
|
|
| // We should have navigated, transient entry should be gone.
|
| @@ -2726,6 +2795,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(url3);
|
| main_test_rfh()->SendNavigate(3, url3);
|
| // Transient entry should be gone.
|
| EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
|
| @@ -2738,6 +2808,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()->SendNavigate(4, url4);
|
| EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
|
| EXPECT_EQ(controller.GetEntryCount(), 5);
|
| @@ -2753,6 +2824,7 @@ 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()->SendNavigate(3, url3);
|
|
|
| // Add a transient and go to an entry before the current one.
|
| @@ -2766,6 +2838,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()->SendNavigate(1, url1);
|
| EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
|
|
|
| @@ -2780,6 +2853,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()->SendNavigate(2, url2);
|
| EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
|
|
|
| @@ -2794,6 +2868,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()->SendNavigate(3, url3);
|
| EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
|
|
|
| @@ -2802,6 +2877,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(url3_ref);
|
| main_test_rfh()->SendNavigate(3, url3_ref);
|
| // Transient entry should be gone.
|
| EXPECT_FALSE(controller.GetTransientEntry());
|
| @@ -2826,6 +2902,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()->SendNavigate(0, url0);
|
| controller.LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| @@ -2848,6 +2925,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()->SendNavigate(1, transient_url);
|
| ASSERT_EQ(controller.GetEntryCount(), 2);
|
| EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
|
| @@ -2931,6 +3009,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()->SendNavigate(0, url0);
|
|
|
| // For link clicks (renderer-initiated navigations), the pending entry should
|
| @@ -2946,6 +3025,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()->SendNavigate(1, url1);
|
| EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
|
| EXPECT_FALSE(controller.GetPendingEntry());
|
| @@ -3983,10 +4063,9 @@ TEST_F(NavigationControllerTest, HistoryNavigate) {
|
| // it unloaded, simulate that.
|
| contents()->ProceedWithCrossSiteNavigation();
|
| // Also make sure we told the page to navigate.
|
| - const IPC::Message* message = GetLastNavigationRequest();
|
| - ASSERT_TRUE(message != NULL);
|
| - GURL nav_url = GetNavigationURLFromIPC(message);
|
| + GURL nav_url = GetLastNavigationURL();
|
| EXPECT_EQ(url1, nav_url);
|
| + contents()->CommitPendingNavigation();
|
| process()->sink().ClearMessages();
|
|
|
| // Now test history.forward()
|
| @@ -3995,10 +4074,9 @@ TEST_F(NavigationControllerTest, HistoryNavigate) {
|
| // The actual cross-navigation is suspended until the current RVH tells us
|
| // it unloaded, simulate that.
|
| contents()->ProceedWithCrossSiteNavigation();
|
| - message = GetLastNavigationRequest();
|
| - ASSERT_TRUE(message != NULL);
|
| - nav_url = GetNavigationURLFromIPC(message);
|
| + nav_url = GetLastNavigationURL();
|
| EXPECT_EQ(url3, nav_url);
|
| + contents()->CommitPendingNavigation();
|
| process()->sink().ClearMessages();
|
|
|
| controller.DiscardNonCommittedEntries();
|
| @@ -4006,8 +4084,7 @@ TEST_F(NavigationControllerTest, HistoryNavigate) {
|
| // Make sure an extravagant history.go() doesn't break.
|
| contents()->OnGoToEntryAtOffset(120); // Out of bounds.
|
| EXPECT_EQ(-1, controller.GetPendingEntryIndex());
|
| - message = GetLastNavigationRequest();
|
| - EXPECT_TRUE(message == NULL);
|
| + EXPECT_FALSE(HasNavigationRequest());
|
| }
|
|
|
| // Test call to PruneAllButLastCommitted for the only entry.
|
| @@ -4096,6 +4173,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) {
|
| EXPECT_EQ(1, controller.GetEntryCount());
|
|
|
| // Try to commit the pending entry.
|
| + main_test_rfh()->PrepareForCommit(url3);
|
| main_test_rfh()->SendNavigate(2, url3);
|
| EXPECT_EQ(-1, controller.GetPendingEntryIndex());
|
| EXPECT_FALSE(controller.GetPendingEntry());
|
|
|