Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1427)

Unified Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 1002803002: Classify navigations without page id in parallel to the existing classifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e5ce493262856eb2942f043ec63b5519c65a3894..41e910682093fcf33d4ba78f0924eb8b033f35d6 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -319,7 +319,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[0], true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, urls[0]);
+ main_test_rfh()->SendNavigate(0, 0, true, urls[0]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(urls[0], controller.GetVisibleEntry()->GetVirtualURL());
@@ -330,7 +330,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
for (int i = 1; i <= 4; ++i) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[i], true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(i, urls[i]);
+ main_test_rfh()->SendNavigate(i, 0, true, urls[i]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(urls[i], controller.GetVisibleEntry()->GetVirtualURL());
@@ -362,11 +362,13 @@ TEST_F(NavigationControllerTest, GoToOffset) {
for (int test = 0; test < NUM_TESTS; ++test) {
int offset = test_offsets[test];
controller.GoToOffset(offset);
+ NavigationEntry* entry = controller.GetPendingEntry();
url_index += offset;
// Check that the GoToOffset will land on the expected page.
- EXPECT_EQ(urls[url_index], controller.GetPendingEntry()->GetVirtualURL());
+ EXPECT_EQ(urls[url_index], entry->GetVirtualURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, urls[url_index]);
+ main_test_rfh()->SendNavigate(
+ url_index, entry->GetUniqueID(), false, urls[url_index]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Check that we can go to any valid offset into the history.
@@ -411,7 +413,8 @@ TEST_F(NavigationControllerTest, LoadURL) {
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(
+ 0, controller.GetPendingEntry()->GetUniqueID(), true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -451,7 +454,8 @@ TEST_F(NavigationControllerTest, LoadURL) {
// Simulate the beforeunload ack for the cross-site transition, and then the
// commit.
main_test_rfh()->PrepareForCommit();
- contents()->GetPendingMainFrame()->SendNavigate(1, url2);
+ contents()->GetPendingMainFrame()->SendNavigate(
+ 1, controller.GetPendingEntry()->GetUniqueID(), true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -491,20 +495,23 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Load another...
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
// Simulate the beforeunload ack for the cross-site transition, and then the
// commit.
main_test_rfh()->PrepareForCommit();
- contents()->GetPendingMainFrame()->SendNavigate(1, url2);
+ contents()->GetPendingMainFrame()->SendNavigate(
+ 1, entry->GetUniqueID(), true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -621,9 +628,10 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -633,9 +641,10 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -667,8 +676,11 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry->GetUniqueID();
+ params.did_create_new_entry = true;
params.url = url1;
params.transition = ui::PAGE_TRANSITION_TYPED;
params.is_post = true;
@@ -678,15 +690,16 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
main_test_rfh()->SendNavigateWithParams(&params);
// The post data should be visible.
- NavigationEntry* entry = controller.GetVisibleEntry();
+ entry = controller.GetVisibleEntry();
ASSERT_TRUE(entry);
EXPECT_TRUE(entry->GetHasPostData());
EXPECT_EQ(entry->GetPostID(), 123);
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), false, url1);
// We should not have produced a new session history entry.
ASSERT_EQ(controller.GetVisibleEntry(), entry);
@@ -707,8 +720,9 @@ TEST_F(NavigationControllerTest, LoadURL_Discarded) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -746,15 +760,16 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) {
const GURL kExistingURL1("http://eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ NavigationEntry* entry = controller.GetPendingEntry();
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, 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()->SendNavigate(99, 0, true, kNewURL);
- // There should no longer be any pending entry, and the third navigation we
+ // There should no longer be any pending entry, and the second navigation we
// just made should be committed.
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -776,8 +791,9 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
const GURL kExistingURL1("http://eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -791,7 +807,7 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
main_test_rfh()->PrepareForCommit();
const GURL kNewURL("http://see");
main_test_rfh()->PrepareForCommit();
- contents()->GetMainFrame()->SendNavigate(3, kNewURL);
+ contents()->GetMainFrame()->SendNavigate(3, 0, true, kNewURL);
// There should no longer be any pending entry, and the third navigation we
// just made should be committed.
@@ -814,16 +830,18 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
const GURL kExistingURL1("http://foo/eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL kExistingURL2("http://foo/bee");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kExistingURL2);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -838,9 +856,9 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
const GURL kNewURL("http://foo/see");
main_test_rfh()->SendRendererInitiatedNavigationRequest(kNewURL, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, kNewURL);
+ main_test_rfh()->SendNavigate(3, 0, true, kNewURL);
- // There should no longer be any pending entry, and the third navigation we
+ // There should no longer be any pending entry, and the new navigation we
// just made should be committed.
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -861,10 +879,11 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
const GURL kExistingURL1("http://privileged");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
// Pretend it has bindings so we can tell if we incorrectly copy it.
main_test_rfh()->GetRenderViewHost()->AllowBindings(2);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -872,9 +891,10 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
const GURL kExistingURL2("http://foo/eh");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame();
- foo_rfh->SendNavigate(1, kExistingURL2);
+ foo_rfh->SendNavigate(1, entry->GetUniqueID(), true, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -891,9 +911,9 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
const GURL kNewURL("http://foo/bee");
foo_rfh->SendRendererInitiatedNavigationRequest(kNewURL, true);
foo_rfh->PrepareForCommit();
- foo_rfh->SendNavigate(3, kNewURL);
+ foo_rfh->SendNavigate(3, 0, true, kNewURL);
- // There should no longer be any pending entry, and the third navigation we
+ // There should no longer be any pending entry, and the new navigation we
// just made should be committed.
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -903,52 +923,56 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings());
}
-// Tests navigating to an existing URL when there is a pending new navigation.
-// This will happen if the user enters a URL, but before that commits, the
-// current page fires history.back().
-TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
- NavigationControllerImpl& controller = controller_impl();
- TestNotificationTracker notifications;
- RegisterForAllNavNotifications(&notifications, &controller);
-
- // First make some history.
- const GURL kExistingURL1("http://foo/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;
-
- const GURL kExistingURL2("http://foo/bee");
- controller.LoadURL(
- kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kExistingURL2);
- EXPECT_EQ(1U, navigation_entry_committed_counter_);
- navigation_entry_committed_counter_ = 0;
-
- // Now make a pending new navigation.
- const GURL kNewURL("http://foo/see");
- controller.LoadURL(
- kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- EXPECT_EQ(0U, notifications.size());
- EXPECT_EQ(-1, controller.GetPendingEntryIndex());
- EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
-
- // Before that commits, a back navigation from the renderer commits.
- 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
- // just made should be committed.
- EXPECT_EQ(1U, navigation_entry_committed_counter_);
- navigation_entry_committed_counter_ = 0;
- EXPECT_EQ(-1, controller.GetPendingEntryIndex());
- EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
- EXPECT_EQ(kExistingURL1, controller.GetVisibleEntry()->GetURL());
-}
+// This VVVVVVV should be impossible. All history navigations should be routed
+// through the browser process, so there should be no surprise history
+// navigations from the renderer.
+
+// // Tests navigating to an existing URL when there is a pending new navigation.
+// // This will happen if the user enters a URL, but before that commits, the
+// // current page fires history.back().
+// TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
+// NavigationControllerImpl& controller = controller_impl();
+// TestNotificationTracker notifications;
+// RegisterForAllNavNotifications(&notifications, &controller);
+
+// // First make some history.
+// const GURL kExistingURL1("http://foo/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;
+
+// const GURL kExistingURL2("http://foo/bee");
+// controller.LoadURL(
+// kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+// main_test_rfh()->PrepareForCommit();
+// main_test_rfh()->SendNavigate(1, kExistingURL2);
+// EXPECT_EQ(1U, navigation_entry_committed_counter_);
+// navigation_entry_committed_counter_ = 0;
+
+// // Now make a pending new navigation.
+// const GURL kNewURL("http://foo/see");
+// controller.LoadURL(
+// kNewURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+// EXPECT_EQ(0U, notifications.size());
+// EXPECT_EQ(-1, controller.GetPendingEntryIndex());
+// EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
+
+// // Before that commits, a back navigation from the renderer commits.
+// 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
+// // just made should be committed.
+// EXPECT_EQ(1U, navigation_entry_committed_counter_);
+// navigation_entry_committed_counter_ = 0;
+// EXPECT_EQ(-1, controller.GetPendingEntryIndex());
+// EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
+// EXPECT_EQ(kExistingURL1, controller.GetVisibleEntry()->GetURL());
+// }
// Tests an ignored navigation when there is a pending new navigation.
// This will happen if the user enters a URL, but before that commits, the
@@ -977,10 +1001,10 @@ TEST_F(NavigationControllerTest, LoadURL_IgnorePreemptsPending) {
EXPECT_EQ(1, delegate->navigation_state_change_count());
// Before that commits, a document.write and location.reload can cause the
- // renderer to send a FrameNavigate with page_id -1.
+ // renderer to send a FrameNavigate with page_id -1 and nav_entry_id 0.
main_test_rfh()->SendRendererInitiatedNavigationRequest(kExistingURL, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(-1, kExistingURL);
+ main_test_rfh()->SendNavigate(-1, 0, false, kExistingURL);
// This should clear the pending entry and notify of a navigation state
// change, so that we do not keep displaying kNewURL.
@@ -1055,7 +1079,8 @@ 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()->SendNavigate(1, kExistingURL);
+ NavigationEntry* entry = controller.GetPendingEntry();
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, kExistingURL);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1127,11 +1152,12 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(NavigationEntryImpl::kInvalidBindings,
controller.GetPendingEntry()->bindings());
+ NavigationEntry* entry1 = controller.GetPendingEntry();
// Commit.
TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
orig_rfh->PrepareForCommit();
- orig_rfh->SendNavigate(0, url1);
+ orig_rfh->SendNavigate(0, entry1->GetUniqueID(), true, url1);
EXPECT_EQ(controller.GetEntryCount(), 1);
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings());
@@ -1147,10 +1173,11 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// privileged url.
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry2 = controller.GetPendingEntry();
orig_rfh->PrepareForCommit();
TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame();
new_rfh->GetRenderViewHost()->AllowBindings(1);
- new_rfh->SendNavigate(1, url2);
+ new_rfh->SendNavigate(1, entry2->GetUniqueID(), true, url2);
// The second load should be committed, and bindings should be remembered.
EXPECT_EQ(controller.GetEntryCount(), 2);
@@ -1161,7 +1188,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// Going back, the first entry should still appear unprivileged.
controller.GoBack();
new_rfh->PrepareForCommit();
- orig_rfh->SendNavigate(0, url1);
+ orig_rfh->SendNavigate(0, entry1->GetUniqueID(), false, url1);
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings());
}
@@ -1175,13 +1202,15 @@ TEST_F(NavigationControllerTest, Reload) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
ASSERT_TRUE(controller.GetVisibleEntry());
controller.GetVisibleEntry()->SetTitle(base::ASCIIToUTF16("Title"));
+
controller.Reload(true);
EXPECT_EQ(0U, notifications.size());
@@ -1202,7 +1231,7 @@ TEST_F(NavigationControllerTest, Reload) {
EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1231,8 +1260,9 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1240,7 +1270,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommitWithServerRedirect(url2);
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1263,7 +1293,8 @@ TEST_F(NavigationControllerTest, ReloadWithGuest) {
const GURL url1("http://foo1");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->SendNavigate(0, url1);
+ NavigationEntry* entry = controller.GetPendingEntry();
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
ASSERT_TRUE(controller.GetVisibleEntry());
// Make the entry believe its RenderProcessHost is a guest.
@@ -1296,10 +1327,11 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
// Load up the original URL, but get redirected.
controller.LoadURL(
original_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommitWithServerRedirect(final_url);
main_test_rfh()->SendNavigateWithOriginalRequestURL(
- 0, final_url, original_url);
+ 0, entry->GetUniqueID(), true, final_url, original_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1331,7 +1363,7 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
// Send that the navigation has proceeded; say it got redirected again.
main_test_rfh()->PrepareForCommitWithServerRedirect(final_url);
- main_test_rfh()->SendNavigate(0, final_url);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), false, final_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1357,12 +1389,14 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
const GURL url0("http://foo/0");
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- main_test_rfh()->SendNavigate(0, url0);
+ NavigationEntry* entry = controller.GetPendingEntry();
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url0);
// Set up the pending entry.
const GURL url1("http://foo/1");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
// Set up some sample values.
const unsigned char* raw_data =
@@ -1387,7 +1421,7 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
EXPECT_TRUE(pending_entry->should_clear_history_list());
// Fake a commit response.
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, url1);
// Certain values that are only used for pending entries get reset after
// commit.
@@ -1406,6 +1440,7 @@ TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
const GURL url1("http://foo1");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
// Set up some redirect values.
std::vector<GURL> redirects;
@@ -1418,7 +1453,8 @@ TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
EXPECT_EQ(GURL("http://foo2"), pending_entry->GetRedirectChain()[0]);
// Normal navigation will preserve redirects in the committed entry.
- main_test_rfh()->SendNavigateWithRedirects(0, url1, redirects);
+ main_test_rfh()->SendNavigateWithRedirects(
+ 0, entry->GetUniqueID(), true, url1, redirects);
NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry();
ASSERT_EQ(1U, committed_entry->GetRedirectChain().size());
EXPECT_EQ(GURL("http://foo2"), committed_entry->GetRedirectChain()[0]);
@@ -1431,12 +1467,13 @@ TEST_F(NavigationControllerTest, Back) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
+ NavigationEntry* entry = controller.GetPendingEntry();
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, 0, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1460,7 +1497,7 @@ TEST_F(NavigationControllerTest, Back) {
EXPECT_GE(controller.GetEntryAtIndex(1)->GetTimestamp(),
controller.GetEntryAtIndex(0)->GetTimestamp());
- main_test_rfh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1494,15 +1531,17 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry1 = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry1->GetUniqueID(), true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry2 = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry2->GetUniqueID(), true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1519,7 +1558,7 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
EXPECT_TRUE(controller.CanGoForward());
main_test_rfh()->PrepareForCommitWithServerRedirect(url3);
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry1->GetUniqueID(), true, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1545,12 +1584,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()->SendNavigate(0, 0, true, 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()->SendNavigate(1, 0, true, kUrl2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1567,64 +1606,67 @@ TEST_F(NavigationControllerTest, Back_NewPending) {
EXPECT_EQ(kUrl1, controller.GetPendingEntry()->GetURL());
}
-// Receives a back message when there is a different renavigation already
-// pending.
-TEST_F(NavigationControllerTest, Back_OtherBackPending) {
- NavigationControllerImpl& controller = controller_impl();
- const GURL kUrl1("http://foo/1");
- const GURL kUrl2("http://foo/2");
- const GURL kUrl3("http://foo/3");
-
- // First navigate three places so we have some back history.
- main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
- main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kUrl1);
- main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true);
- main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kUrl2);
- 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()->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
- // a random one for looking up other entries.
- SiteInstance* site_instance =
- controller.GetLastCommittedEntry()->site_instance();
-
- // That second URL should be the last committed and it should have gotten the
- // new title.
- EXPECT_EQ(kUrl2, controller.GetEntryWithPageID(site_instance, 1)->GetURL());
- EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
- EXPECT_EQ(-1, controller.GetPendingEntryIndex());
-
- // Now go forward to the last item again and say it was committed.
- controller.GoForward();
- main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, kUrl3);
-
- // Now start going back one to the second page. It will be pending.
- controller.GoBack();
- EXPECT_EQ(1, controller.GetPendingEntryIndex());
- EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
-
- // Now synthesize a totally new back event to the first page. This will not
- // match the pending one.
- main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
- main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kUrl1);
-
- // The committed navigation should clear the pending entry.
- EXPECT_EQ(-1, controller.GetPendingEntryIndex());
-
- // But the navigated entry should be the last committed.
- EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
- EXPECT_EQ(kUrl1, controller.GetLastCommittedEntry()->GetURL());
-}
+// Again, this VVVV seems impossible: particularly the unsolicited renderer
+// history navigation backwards to kUrl2.
+
+// // Receives a back message when there is a different renavigation already
+// // pending.
+// TEST_F(NavigationControllerTest, Back_OtherBackPending) {
+// NavigationControllerImpl& controller = controller_impl();
+// const GURL kUrl1("http://foo/1");
+// const GURL kUrl2("http://foo/2");
+// const GURL kUrl3("http://foo/3");
+
+// // First navigate three places so we have some back history.
+// main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
+// main_test_rfh()->PrepareForCommit();
+// main_test_rfh()->SendNavigate(0, 0, true, kUrl1);
+// main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true);
+// main_test_rfh()->PrepareForCommit();
+// main_test_rfh()->SendNavigate(1, 0, true, kUrl2);
+// main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl3, true);
+// main_test_rfh()->PrepareForCommit();
+// main_test_rfh()->SendNavigate(2, 0, true, kUrl3);
+
+// // With nothing pending, say we get a navigation to the second entry.
+// 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
+// // a random one for looking up other entries.
+// SiteInstance* site_instance =
+// controller.GetLastCommittedEntry()->site_instance();
+
+// // That second URL should be the last committed and it should have gotten the
+// // new title.
+// EXPECT_EQ(kUrl2, controller.GetEntryWithPageID(site_instance, 1)->GetURL());
+// EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
+// EXPECT_EQ(-1, controller.GetPendingEntryIndex());
+
+// // Now go forward to the last item again and say it was committed.
+// controller.GoForward();
+// main_test_rfh()->PrepareForCommit();
+// main_test_rfh()->SendNavigate(2, kUrl3);
+
+// // Now start going back one to the second page. It will be pending.
+// controller.GoBack();
+// EXPECT_EQ(1, controller.GetPendingEntryIndex());
+// EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
+
+// // Now synthesize a totally new back event to the first page. This will not
+// // match the pending one.
+// main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
+// main_test_rfh()->PrepareForCommit();
+// main_test_rfh()->SendNavigate(0, kUrl1);
+
+// // The committed navigation should clear the pending entry.
+// EXPECT_EQ(-1, controller.GetPendingEntryIndex());
+
+// // But the navigated entry should be the last committed.
+// EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
+// EXPECT_EQ(kUrl1, controller.GetLastCommittedEntry()->GetURL());
+// }
// Tests what happens when we navigate forward successfully.
TEST_F(NavigationControllerTest, Forward) {
@@ -1636,18 +1678,20 @@ TEST_F(NavigationControllerTest, Forward) {
const GURL url2("http://foo2");
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, 0, true, url2);
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.GoBack();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry1->GetUniqueID(), false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1672,7 +1716,7 @@ TEST_F(NavigationControllerTest, Forward) {
controller.GetEntryAtIndex(1)->GetTimestamp());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry2->GetUniqueID(), false, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1705,17 +1749,20 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
const GURL url3("http://foo3");
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
navigation_entry_committed_counter_ = 0;
+
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, 0, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
navigation_entry_committed_counter_ = 0;
controller.GoBack();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry1->GetUniqueID(), false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1732,7 +1779,7 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
EXPECT_FALSE(controller.CanGoForward());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry2->GetUniqueID(), true, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_LIST_PRUNED));
@@ -1746,7 +1793,7 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
EXPECT_FALSE(controller.CanGoForward());
}
-// Two consequent navigation for the same URL entered in should be considered
+// Two consecutive navigations for the same URL entered in should be considered
// as SAME_PAGE navigation even when we are redirected to some other page.
TEST_F(NavigationControllerTest, Redirect) {
NavigationControllerImpl& controller = controller_impl();
@@ -1759,15 +1806,17 @@ TEST_F(NavigationControllerTest, Redirect) {
// First request
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Second request
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
@@ -1775,6 +1824,8 @@ TEST_F(NavigationControllerTest, Redirect) {
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT;
params.redirects.push_back(GURL("http://foo1"));
@@ -1818,16 +1869,18 @@ TEST_F(NavigationControllerTest, PostThenRedirect) {
// First request as POST
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
controller.GetVisibleEntry()->SetHasPostData(true);
EXPECT_EQ(0U, notifications.size());
- main_test_rfh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Second request
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
@@ -1835,6 +1888,8 @@ TEST_F(NavigationControllerTest, PostThenRedirect) {
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT;
params.redirects.push_back(GURL("http://foo1"));
@@ -1921,13 +1976,15 @@ TEST_F(NavigationControllerTest, NewSubframe) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
params.should_update_history = false;
@@ -1986,13 +2043,15 @@ TEST_F(NavigationControllerTest, AutoSubframe) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
params.should_update_history = false;
@@ -2018,14 +2077,17 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Main page.
const GURL url1("http://foo1");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
navigation_entry_committed_counter_ = 0;
// First manual subframe navigation.
const GURL url2("http://foo2");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
params.should_update_history = false;
@@ -2037,6 +2099,7 @@ TEST_F(NavigationControllerTest, BackSubframe) {
LoadCommittedDetails details;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
&details));
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(2, controller.GetEntryCount());
@@ -2044,6 +2107,8 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Second manual subframe navigation should also make a new entry.
const GURL url3("http://foo3");
params.page_id = 2;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url3;
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2056,6 +2121,8 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Go back one.
controller.GoBack();
params.page_id = 1;
+ params.nav_entry_id = entry2->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2070,6 +2137,8 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Go back one more.
controller.GoBack();
params.page_id = 0;
+ params.nav_entry_id = entry1->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url1;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2090,15 +2159,15 @@ TEST_F(NavigationControllerTest, LinkClick) {
const GURL url1("http://foo1");
const GURL url2("http://foo2");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, 0, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- // Should not have produced a new session history entry.
+ // Should have produced a new session history entry.
EXPECT_EQ(controller.GetEntryCount(), 2);
EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1);
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
@@ -2115,7 +2184,7 @@ TEST_F(NavigationControllerTest, InPage) {
// Main page.
const GURL url1("http://foo");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -2123,6 +2192,8 @@ TEST_F(NavigationControllerTest, InPage) {
// hint provided in the params.
FrameHostMsg_DidCommitProvisionalLoad_Params self_params;
self_params.page_id = 0;
+ self_params.nav_entry_id = 0;
+ self_params.did_create_new_entry = false;
self_params.url = url1;
self_params.transition = ui::PAGE_TRANSITION_LINK;
self_params.should_update_history = false;
@@ -2134,6 +2205,7 @@ TEST_F(NavigationControllerTest, InPage) {
LoadCommittedDetails details;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), self_params,
&details));
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(details.is_in_page);
@@ -2144,6 +2216,8 @@ TEST_F(NavigationControllerTest, InPage) {
const GURL url2("http://foo#a");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2155,6 +2229,7 @@ TEST_F(NavigationControllerTest, InPage) {
// This should generate a new entry.
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
&details));
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(details.is_in_page);
@@ -2166,6 +2241,8 @@ TEST_F(NavigationControllerTest, InPage) {
controller.GoBack();
back_params.url = url1;
back_params.page_id = 0;
+ back_params.nav_entry_id = entry1->GetUniqueID();
+ back_params.did_create_new_entry = false;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), back_params,
&details));
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -2175,11 +2252,13 @@ TEST_F(NavigationControllerTest, InPage) {
EXPECT_EQ(0, controller.GetCurrentEntryIndex());
EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL());
- // Go forward
+ // Go forward.
FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params);
controller.GoForward();
forward_params.url = url2;
forward_params.page_id = 1;
+ forward_params.nav_entry_id = entry2->GetUniqueID();
+ forward_params.did_create_new_entry = false;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), forward_params,
&details));
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -2206,6 +2285,8 @@ TEST_F(NavigationControllerTest, InPage) {
// Finally, navigate to an unrelated URL to make sure in_page is not sticky.
const GURL url3("http://bar");
params.page_id = 2;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url3;
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2224,7 +2305,7 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
// Main page.
const GURL url1("http://foo");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -2232,6 +2313,8 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
const GURL url2("http://foo#a");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0; // Same page_id
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2265,7 +2348,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Load an initial page.
{
const GURL url("http://foo/");
- main_test_rfh()->SendNavigate(0, url);
+ main_test_rfh()->SendNavigate(0, 0, true, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
}
@@ -2273,7 +2356,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Navigate to a new page.
{
const GURL url("http://foo2/");
- main_test_rfh()->SendNavigate(1, url);
+ main_test_rfh()->SendNavigate(1, 0, true, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
}
@@ -2283,6 +2366,8 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
const GURL url("http://foo2/#a");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1; // Same page_id
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.redirects.push_back(url);
@@ -2308,6 +2393,8 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
const GURL url("http://foo3/");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 2; // New page_id
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT;
params.redirects.push_back(GURL("http://foo2/#a"));
@@ -2331,7 +2418,8 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
{
const GURL url("http://foo2/");
controller.GoBack();
- main_test_rfh()->SendNavigate(1, url);
+ NavigationEntry* entry = controller.GetPendingEntry();
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), false, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL());
@@ -2344,6 +2432,8 @@ TEST_F(NavigationControllerTest, PushStateWithoutPreviousEntry)
FrameHostMsg_DidCommitProvisionalLoad_Params params;
GURL url("http://foo");
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.page_state = PageState::CreateFromURL(url);
params.was_within_same_page = true;
@@ -2396,8 +2486,9 @@ 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());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, entry->GetUniqueID(), true, url);
}
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
@@ -2409,8 +2500,9 @@ 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());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, entry->GetUniqueID(), true, url);
url_index++;
// We should have got a pruned navigation.
@@ -2421,20 +2513,21 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
// We expect http://www.a.com/0 to be gone.
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(),
- GURL("http:////www.a.com/1"));
+ GURL("http://www.a.com/1"));
// More navigations.
for (int i = 0; i < 3; i++) {
- url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index));
+ url = GURL(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, entry->GetUniqueID(), true, url);
url_index++;
}
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(),
- GURL("http:////www.a.com/4"));
+ GURL("http://www.a.com/4"));
NavigationControllerImpl::set_max_entry_count_for_testing(original_count);
}
@@ -2488,6 +2581,8 @@ TEST_F(NavigationControllerTest, RestoreNavigate) {
// Say we navigated to that entry.
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = our_controller.GetPendingEntry()->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2536,6 +2631,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
// Before navigating to the restored entry, it should have a restore_type
// and no SiteInstance.
+ entry = our_controller.GetEntryAtIndex(0);
EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY,
our_controller.GetEntryAtIndex(0)->restore_type());
EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance());
@@ -2565,6 +2661,8 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
// Now the pending restored entry commits.
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2593,19 +2691,21 @@ TEST_F(NavigationControllerTest, Interstitial) {
const GURL url1("http://foo");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
// Now navigate somewhere with an interstitial.
const GURL url2("http://bar");
controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED,
std::string());
+ entry = controller.GetPendingEntry();
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();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, url2);
// The page should be a normal page again.
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
@@ -2625,24 +2725,29 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, url2);
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry->GetUniqueID(), true, url3);
controller.LoadURL(
url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url4);
+ main_test_rfh()->SendNavigate(3, entry->GetUniqueID(), true, url4);
controller.LoadURL(
url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(4, url5);
+ main_test_rfh()->SendNavigate(4, entry->GetUniqueID(), true, url5);
// Try to remove the last entry. Will fail because it is the current entry.
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
@@ -2652,12 +2757,13 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
// Go back, but don't commit yet. Check that we can't delete the current
// and pending entries.
controller.GoBack();
+ entry = controller.GetPendingEntry();
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2));
// Now commit and delete the last entry.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url4);
+ main_test_rfh()->SendNavigate(3, entry->GetUniqueID(), false, url4);
EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
EXPECT_EQ(4, controller.GetEntryCount());
EXPECT_EQ(3, controller.GetLastCommittedEntryIndex());
@@ -2687,20 +2793,24 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, url2);
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry->GetUniqueID(), true, url3);
// Go back, but don't commit yet. Check that we can't delete the current
// and pending entries.
controller.GoBack();
+ entry = controller.GetPendingEntry();
EXPECT_FALSE(controller.RemoveEntryAtIndex(2));
EXPECT_FALSE(controller.RemoveEntryAtIndex(1));
@@ -2715,7 +2825,7 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
// Now commit and ensure we land on the right entry.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), false, url2);
EXPECT_EQ(2, controller.GetEntryCount());
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_FALSE(controller.GetPendingEntry());
@@ -2737,12 +2847,14 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url0);
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, url1);
notifications.Reset();
@@ -2768,8 +2880,9 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Navigate.
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url2);
+ main_test_rfh()->SendNavigate(2, entry->GetUniqueID(), true, url2);
// We should have navigated, transient entry should be gone.
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
@@ -2782,7 +2895,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, 0, true, url3);
// Transient entry should be gone.
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 4);
@@ -2790,12 +2903,13 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Initiate a navigation, add a transient then commit navigation.
controller.LoadURL(
url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry = controller.GetPendingEntry();
transient_entry = new NavigationEntryImpl;
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(4, url4);
+ main_test_rfh()->SendNavigate(4, entry->GetUniqueID(), true, url4);
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 5);
@@ -2807,13 +2921,14 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_TRUE(controller.CanGoBack());
EXPECT_FALSE(controller.CanGoForward());
controller.GoBack();
+ entry = controller.GetPendingEntry();
// Transient entry should be gone.
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 5);
main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, false);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, entry->GetUniqueID(), false, url3);
// Add a transient and go to an entry before the current one.
transient_entry = new NavigationEntryImpl;
@@ -2821,13 +2936,14 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
controller.GoToIndex(1);
+ entry = controller.GetPendingEntry();
// The navigation should have been initiated, transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
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();
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), false, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
// Add a transient and go to an entry after the current one.
@@ -2836,13 +2952,14 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
controller.GoToIndex(3);
+ entry = controller.GetPendingEntry();
// The navigation should have been initiated, transient entry should be gone.
// Because of the transient entry that is removed, going to index 3 makes us
// 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();
- main_test_rfh()->SendNavigate(2, url2);
+ main_test_rfh()->SendNavigate(2, entry->GetUniqueID(), false, url2);
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
// Add a transient and go forward.
@@ -2852,12 +2969,13 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
EXPECT_TRUE(controller.CanGoForward());
controller.GoForward();
+ entry = controller.GetPendingEntry();
// We should have navigated, transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, entry->GetUniqueID(), false, url3);
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
// Add a transient and do an in-page navigation, replacing the current entry.
@@ -2868,7 +2986,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3_ref);
+ main_test_rfh()->SendNavigate(3, 0, false, url3_ref);
// Transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL());
@@ -2892,8 +3010,9 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// Load |url0|, and start a pending navigation to |url1|.
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url0);
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
@@ -2908,6 +3027,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// the transient entry for |transient_url|, and start a navigation to
// |transient_url|.
controller.Reload(true);
+ entry = controller.GetPendingEntry();
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
@@ -2916,7 +3036,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// Load of |transient_url| completes.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, transient_url);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), false, transient_url);
ASSERT_EQ(controller.GetEntryCount(), 2);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), transient_url);
@@ -2953,7 +3073,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL());
// Once it commits, the URL and virtual URL should reflect the actual page.
- main_test_rfh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, 0, true, url2);
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL());
@@ -2973,7 +3093,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
// 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);
+ main_test_rfh()->SendNavigate(0, 0, false, url2);
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
}
@@ -2992,16 +3112,18 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
// should update before commit.
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url0);
// For link clicks (renderer-initiated navigations), the pending entry should
// update before commit but the visible should not.
NavigationController::LoadURLParams load_url_params(url1);
load_url_params.is_renderer_initiated = true;
controller.LoadURLWithParams(load_url_params);
+ entry = controller.GetPendingEntry();
EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated());
@@ -3009,7 +3131,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();
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry->GetUniqueID(), true, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
EXPECT_FALSE(controller.GetPendingEntry());
EXPECT_FALSE(controller.GetLastCommittedEntry()->is_renderer_initiated());
@@ -3167,13 +3289,14 @@ TEST_F(NavigationControllerTest, DontShowRendererURLInNewTabAfterCommit) {
load_url_params.transition_type = ui::PAGE_TRANSITION_LINK;
load_url_params.is_renderer_initiated = true;
controller.LoadURLWithParams(load_url_params);
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated());
EXPECT_TRUE(controller.IsInitialNavigation());
EXPECT_FALSE(contents()->HasAccessedInitialDocument());
// Simulate a commit and then starting a new pending navigation.
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry->GetUniqueID(), true, url1);
NavigationController::LoadURLParams load_url2_params(url2);
load_url2_params.transition_type = ui::PAGE_TRANSITION_LINK;
load_url2_params.is_renderer_initiated = true;
@@ -3203,16 +3326,14 @@ 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);
- EXPECT_TRUE(controller.IsURLInPageNavigation(url, true,
- main_test_rfh()));
+ main_test_rfh()->SendNavigate(0, 0, false, 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()->SendNavigate(0, 0, false, url);
// Reloading the page is not an in-page navigation.
- EXPECT_FALSE(controller.IsURLInPageNavigation(url, false,
- main_test_rfh()));
+ EXPECT_FALSE(controller.IsURLInPageNavigation(url, false, main_test_rfh()));
const GURL other_url("http://www.google.com/add.html");
EXPECT_FALSE(controller.IsURLInPageNavigation(other_url, false,
main_test_rfh()));
@@ -3221,7 +3342,7 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
main_test_rfh()));
// Navigate to URL with refs.
- main_test_rfh()->SendNavigate(1, url_with_ref);
+ main_test_rfh()->SendNavigate(1, 0, true, url_with_ref);
// Reloading the page is not an in-page navigation.
EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref, false,
@@ -3260,14 +3381,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()->SendNavigate(0, 0, true, 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()->SendNavigate(0, 0, true, url);
EXPECT_FALSE(controller.IsURLInPageNavigation(different_origin_url, true,
main_test_rfh()));
EXPECT_EQ(1, rph->bad_msg_count());
@@ -3294,7 +3415,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()->SendNavigate(0, 0, true, url);
// We should be at the first navigation entry.
EXPECT_EQ(controller.GetEntryCount(), 1);
@@ -3304,6 +3425,8 @@ TEST_F(NavigationControllerTest, SameSubframe) {
const GURL subframe("http://www.google.com/#");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = subframe;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
params.should_update_history = false;
@@ -3449,6 +3572,8 @@ TEST_F(NavigationControllerTest, SubframeWhilePending) {
const GURL url1_sub("http://foo/subframe");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = controller.GetLastCommittedEntry()->GetPageID();
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url1_sub;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
params.should_update_history = false;
@@ -4127,6 +4252,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) {
// Create a pending entry that is not in the entry list.
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ NavigationEntry* entry = controller.GetPendingEntry();
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(2, controller.GetEntryCount());
@@ -4143,7 +4269,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) {
// Try to commit the pending entry.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry->GetUniqueID(), true, url3);
EXPECT_EQ(-1, controller.GetPendingEntryIndex());
EXPECT_FALSE(controller.GetPendingEntry());
EXPECT_EQ(2, controller.GetEntryCount());
@@ -4185,7 +4311,7 @@ TEST_F(NavigationControllerTest, IsInitialNavigation) {
// After commit, it stays false.
const GURL url1("http://foo1");
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_FALSE(controller.IsInitialNavigation());
@@ -4208,7 +4334,7 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller);
- main_test_rfh()->SendNavigate(0, kPageWithFavicon);
+ main_test_rfh()->SendNavigate(0, 0, true, kPageWithFavicon);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -4225,6 +4351,8 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
main_test_rfh()->SendNavigateWithTransition(
0, // same page ID.
+ 0, // nav_entry_id
+ false, // no new entry
kPageWithoutFavicon,
ui::PAGE_TRANSITION_CLIENT_REDIRECT);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -4248,7 +4376,7 @@ TEST_F(NavigationControllerTest, BackNavigationDoesNotClearFavicon) {
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller);
- main_test_rfh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(0, 0, true, kUrl1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -4262,11 +4390,13 @@ 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()->SendNavigate(1, 0, true, kUrl2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
main_test_rfh()->SendNavigateWithTransition(
0,
+ controller.GetEntryAtIndex(0)->GetUniqueID(),
+ false,
kUrl1,
ui::PAGE_TRANSITION_FORWARD_BACK);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -4368,7 +4498,7 @@ TEST_F(NavigationControllerTest, MAYBE_PurgeScreenshot) {
TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) {
// Navigate.
- contents()->GetMainFrame()->SendNavigate(1, GURL("http://foo"));
+ contents()->GetMainFrame()->SendNavigate(1, 0, true, GURL("http://foo"));
// Set title and favicon.
base::string16 title(base::ASCIIToUTF16("Title"));
@@ -4382,6 +4512,8 @@ TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) {
FrameHostMsg_DidCommitProvisionalLoad_Params params;
GURL url("http://foo#foo");
params.page_id = 2;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.page_state = PageState::CreateFromURL(url);
params.was_within_same_page = true;
@@ -4458,6 +4590,8 @@ TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
GURL url("http://foo");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.transition = ui::PAGE_TRANSITION_FORM_SUBMIT;
params.gesture = NavigationGestureUser;
@@ -4470,6 +4604,8 @@ TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
// history.replaceState() is called.
GURL replace_url("http://foo#foo");
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = replace_url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.gesture = NavigationGestureUser;
@@ -4489,6 +4625,8 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
GURL url("http://foo");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.gesture = NavigationGestureUser;
@@ -4497,7 +4635,7 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
params.is_post = true;
params.post_id = 2;
params.url_is_unreachable = true;
- // Navigate to new page
+ // Navigate to new page.
{
LoadCommittedDetails details;
controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);

Powered by Google App Engine
This is Rietveld 408576698