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

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

Issue 10704048: [RDS] Reloads a page using the original request URL (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding unit test & removing public function Created 8 years, 6 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/web_contents/navigation_controller_impl_unittest.cc
diff --git a/content/browser/web_contents/navigation_controller_impl_unittest.cc b/content/browser/web_contents/navigation_controller_impl_unittest.cc
index f3b95609a6dad83ddb53b37a6995c470b20833d1..e73ef8eed6355c47c418e733aac20b138ecedbca 100644
--- a/content/browser/web_contents/navigation_controller_impl_unittest.cc
+++ b/content/browser/web_contents/navigation_controller_impl_unittest.cc
@@ -628,6 +628,58 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
EXPECT_FALSE(controller.CanGoForward());
}
+TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
+ NavigationControllerImpl& controller = controller_impl();
+ TestNotificationTracker notifications;
+ RegisterForAllNavNotifications(&notifications, &controller);
+
+ const GURL original_url("http://foo1");
+ const GURL final_url("http://foo2");
+
+ // Load up the original URL, but get redirected. The NavigationEntry should
+ // save both the original URL and the final redirected URL.
Charlie Reis 2012/07/03 17:22:26 Can you check this using GetURL() and GetOriginalR
gone 2012/07/03 18:24:39 Done.
+ controller.LoadURL(original_url, content::Referrer(),
+ content::PAGE_TRANSITION_TYPED, std::string());
+ EXPECT_EQ(0U, notifications.size());
+ test_rvh()->SendNavigateWithOriginalRequestURL(0, final_url, original_url);
+ EXPECT_TRUE(notifications.Check1AndReset(
+ content::NOTIFICATION_NAV_ENTRY_COMMITTED));
+
+ // Reload using the original URL.
+ controller.GetActiveEntry()->SetTitle(ASCIIToUTF16("Title"));
+ controller.ReloadOriginalRequestURL(false);
+ EXPECT_EQ(0U, notifications.size());
+
+ // The reload is pending. The request should point to the original URL.
+ EXPECT_EQ(original_url, test_rvh()->last_params()->url);
+ EXPECT_EQ(controller.GetEntryCount(), 1);
+ EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
+ EXPECT_EQ(controller.GetPendingEntryIndex(), 0);
+ EXPECT_TRUE(controller.GetLastCommittedEntry());
+ EXPECT_TRUE(controller.GetPendingEntry());
Charlie Reis 2012/07/03 17:22:26 Why not check that the pending entry's URL is the
gone 2012/07/03 18:24:39 We need to know where the NavigationController is
+ EXPECT_FALSE(controller.CanGoBack());
+ EXPECT_FALSE(controller.CanGoForward());
+
+ // Make sure the title has been cleared (will be redrawn just after reload).
+ // Avoids a stale cached title when the new page being reloaded has no title.
+ // See http://crbug.com/96041.
+ EXPECT_TRUE(controller.GetActiveEntry()->GetTitle().empty());
+
+ // Send that the navigation has proceeded; say it got redirected again.
+ test_rvh()->SendNavigate(0, final_url);
+ EXPECT_TRUE(notifications.Check1AndReset(
+ content::NOTIFICATION_NAV_ENTRY_COMMITTED));
+
+ // Now the reload is committed.
+ EXPECT_EQ(controller.GetEntryCount(), 1);
+ EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
+ EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
+ EXPECT_TRUE(controller.GetLastCommittedEntry());
+ EXPECT_FALSE(controller.GetPendingEntry());
+ EXPECT_FALSE(controller.CanGoBack());
+ EXPECT_FALSE(controller.CanGoForward());
+}
+
// Tests what happens when we navigate back successfully
TEST_F(NavigationControllerTest, Back) {
NavigationControllerImpl& controller = controller_impl();

Powered by Google App Engine
This is Rietveld 408576698