diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 01:44:29 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 01:44:29 +0000 |
commit | 4f644da31f9f8d03b02dcfd9176d6fbf48bef578 (patch) | |
tree | 664e95e15c4cbee8fba25b4f8cd2784ab8b1eac1 | |
parent | 420133079985c80f47ed962a85342b32a342a6bd (diff) | |
download | chromium_src-4f644da31f9f8d03b02dcfd9176d6fbf48bef578.zip chromium_src-4f644da31f9f8d03b02dcfd9176d6fbf48bef578.tar.gz chromium_src-4f644da31f9f8d03b02dcfd9176d6fbf48bef578.tar.bz2 |
Also update the session history in the renderer when the active entry is a new pending entry
BUG=178103
TEST:content_unittests:NavigationControllerImplTest.PruneAllButActiveForPendingNotInList
R=creis@chromium.org
Review URL: https://chromiumcodereview.appspot.com/12552005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188910 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/web_contents/navigation_controller_impl.cc | 3 | ||||
-rw-r--r-- | content/browser/web_contents/navigation_controller_impl_unittest.cc | 37 |
2 files changed, 37 insertions, 3 deletions
diff --git a/content/browser/web_contents/navigation_controller_impl.cc b/content/browser/web_contents/navigation_controller_impl.cc index d692b7d..c8218af 100644 --- a/content/browser/web_contents/navigation_controller_impl.cc +++ b/content/browser/web_contents/navigation_controller_impl.cc @@ -1405,12 +1405,11 @@ void NavigationControllerImpl::PruneAllButActive() { // If there is an entry left, we need to update the session history length of // the RenderView. - if (!GetEntryCount()) + if (!GetActiveEntry()) return; NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); - CHECK(entry); // We pass 0 instead of GetEntryCount() for the history_length parameter of // SetHistoryLengthAndPrune, because it will create history_length additional // history entries. diff --git a/content/browser/web_contents/navigation_controller_impl_unittest.cc b/content/browser/web_contents/navigation_controller_impl_unittest.cc index 1d698b3..0f25e2e 100644 --- a/content/browser/web_contents/navigation_controller_impl_unittest.cc +++ b/content/browser/web_contents/navigation_controller_impl_unittest.cc @@ -2970,7 +2970,7 @@ TEST_F(NavigationControllerTest, PruneAllButActiveForIntermediate) { EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url2); } -// Test call to PruneAllButActive for intermediate entry. +// Test call to PruneAllButActive for a pending entry. TEST_F(NavigationControllerTest, PruneAllButActiveForPending) { NavigationControllerImpl& controller = controller_impl(); const GURL url1("http://foo/1"); @@ -2991,6 +2991,41 @@ TEST_F(NavigationControllerTest, PruneAllButActiveForPending) { EXPECT_EQ(0, controller.GetPendingEntryIndex()); } +// Test call to PruneAllButActive for a pending entry that is not yet in the +// list of entries. +TEST_F(NavigationControllerTest, PruneAllButActiveForPendingNotInList) { + NavigationControllerImpl& controller = controller_impl(); + const GURL url1("http://foo/1"); + const GURL url2("http://foo/2"); + const GURL url3("http://foo/3"); + + NavigateAndCommit(url1); + NavigateAndCommit(url2); + + // Create a pending entry that is not in the entry list. + controller.LoadURL( + url3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); + EXPECT_TRUE(controller.GetPendingEntry()); + EXPECT_EQ(2, controller.GetEntryCount()); + + contents()->ExpectSetHistoryLengthAndPrune( + NULL, 0, controller.GetPendingEntry()->GetPageID()); + controller.PruneAllButActive(); + + // We should only have the pending entry at this point, and it should still + // not be in the entry list. + EXPECT_EQ(-1, controller.GetPendingEntryIndex()); + EXPECT_TRUE(controller.GetPendingEntry()); + EXPECT_EQ(0, controller.GetEntryCount()); + + // Try to commit the pending entry. + test_rvh()->SendNavigate(2, url3); + EXPECT_EQ(-1, controller.GetPendingEntryIndex()); + EXPECT_FALSE(controller.GetPendingEntry()); + EXPECT_EQ(1, controller.GetEntryCount()); + EXPECT_EQ(url3, controller.GetEntryAtIndex(0)->GetURL()); +} + // Test call to PruneAllButActive for transient entry. TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { NavigationControllerImpl& controller = controller_impl(); |