Index: content/browser/web_contents/navigation_controller_impl_unittest.cc |
=================================================================== |
--- content/browser/web_contents/navigation_controller_impl_unittest.cc (revision 153076) |
+++ content/browser/web_contents/navigation_controller_impl_unittest.cc (working copy) |
@@ -2064,7 +2064,7 @@ |
test_rvh()->SendNavigate(3, url3); |
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
- // Ensure the URLS are correct. |
+ // Ensure the URLs are correct. |
EXPECT_EQ(controller.GetEntryCount(), 5); |
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), url1); |
@@ -2073,6 +2073,44 @@ |
EXPECT_EQ(controller.GetEntryAtIndex(4)->GetURL(), url4); |
} |
+// Test that Reload initiates a new navigation to a transient entry's URL. |
+TEST_F(NavigationControllerTest, ReloadTransient) { |
+ NavigationControllerImpl& controller = controller_impl(); |
+ const GURL url0("http://foo/0"); |
+ const GURL url1("http://foo/1"); |
+ const GURL transient_url("http://foo/transient"); |
+ |
+ // Load |url0|, and start a pending navigation to |url1|. |
+ controller.LoadURL( |
+ url0, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
+ test_rvh()->SendNavigate(0, url0); |
+ controller.LoadURL( |
+ url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
+ |
+ // A transient entry is added, interrupting the navigation. |
+ NavigationEntryImpl* transient_entry = new NavigationEntryImpl; |
+ transient_entry->SetURL(transient_url); |
+ controller.AddTransientEntry(transient_entry); |
+ EXPECT_TRUE(controller.GetTransientEntry()); |
+ EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
+ |
+ // The page is reloaded, which should remove the pending entry for |url1| and |
+ // the transient entry for |transient_url|, and start a navigation to |
+ // |transient_url|. |
+ controller.Reload(true); |
+ EXPECT_FALSE(controller.GetTransientEntry()); |
+ EXPECT_TRUE(controller.GetPendingEntry()); |
+ EXPECT_EQ(transient_url, controller.GetActiveEntry()->GetURL()); |
+ ASSERT_EQ(controller.GetEntryCount(), 1); |
+ EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
+ |
+ // Load of |transient_url| completes. |
+ test_rvh()->SendNavigate(1, transient_url); |
+ ASSERT_EQ(controller.GetEntryCount(), 2); |
+ EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0); |
+ EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), transient_url); |
+} |
+ |
// Tests that the URLs for renderer-initiated navigations are not displayed to |
// the user until the navigation commits, to prevent URL spoof attacks. |
// See http://crbug.com/99016. |