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

Unified Diff: content/browser/tab_contents/navigation_controller_unittest.cc

Issue 6801052: Fix classification of a history.back() that interrupts a pending navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test comment. Created 9 years, 8 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
« no previous file with comments | « content/browser/tab_contents/navigation_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tab_contents/navigation_controller_unittest.cc
diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc
index 6a2ad6539472aa620ef429b16c5388245f0e1883..a605330c16877af71e382b850c0a412587fd1b45 100644
--- a/content/browser/tab_contents/navigation_controller_unittest.cc
+++ b/content/browser/tab_contents/navigation_controller_unittest.cc
@@ -388,6 +388,45 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
EXPECT_EQ(kNewURL, controller().GetActiveEntry()->url());
}
+// 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) {
+ TestNotificationTracker notifications;
+ RegisterForAllNavNotifications(&notifications, &controller());
+
+ // First make some history.
+ const GURL kExistingURL1("http://eh");
+ controller().LoadURL(kExistingURL1, GURL(), PageTransition::TYPED);
+ rvh()->SendNavigate(0, kExistingURL1);
+ EXPECT_TRUE(notifications.Check1AndReset(
+ NotificationType::NAV_ENTRY_COMMITTED));
+
+ const GURL kExistingURL2("http://bee");
+ controller().LoadURL(kExistingURL2, GURL(), PageTransition::TYPED);
+ rvh()->SendNavigate(1, kExistingURL2);
+ EXPECT_TRUE(notifications.Check1AndReset(
+ NotificationType::NAV_ENTRY_COMMITTED));
+
+ // Now make a pending new navigation.
+ const GURL kNewURL("http://see");
+ controller().LoadURL(kNewURL, GURL(), PageTransition::TYPED);
+ EXPECT_EQ(0U, notifications.size());
+ EXPECT_EQ(-1, controller().pending_entry_index());
+ EXPECT_EQ(1, controller().last_committed_entry_index());
+
+ // Before that commits, a back navigation from the renderer commits.
+ rvh()->SendNavigate(0, kExistingURL1);
+
+ // There should no longer be any pending entry, and the back navigation we
+ // just made should be committed.
+ EXPECT_TRUE(notifications.Check1AndReset(
+ NotificationType::NAV_ENTRY_COMMITTED));
+ EXPECT_EQ(-1, controller().pending_entry_index());
+ EXPECT_EQ(0, controller().last_committed_entry_index());
+ EXPECT_EQ(kExistingURL1, controller().GetActiveEntry()->url());
+}
+
TEST_F(NavigationControllerTest, Reload) {
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller());
« no previous file with comments | « content/browser/tab_contents/navigation_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698