| 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 621ab2406df8034bc9100e678b8659bbf37b7884..aafd1ded5b60ebc0a14c0cddd8526408ede0d343 100644
|
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| @@ -2611,6 +2611,45 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
|
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
|
| }
|
|
|
| +TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
|
| + NavigationControllerImpl& controller = controller_impl();
|
| + const GURL url1("http://foo/1");
|
| + const GURL url2("http://foo/2");
|
| + const GURL url3("http://foo/3");
|
| + const GURL default_url("http://foo/default");
|
| +
|
| + controller.LoadURL(
|
| + url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->SendNavigate(0, url1);
|
| + controller.LoadURL(
|
| + url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->SendNavigate(1, url2);
|
| + controller.LoadURL(
|
| + url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + main_test_rfh()->SendNavigate(2, url3);
|
| +
|
| + // Go back, but don't commit yet. Check that we can't delete the current
|
| + // and pending entries.
|
| + controller.GoBack();
|
| + EXPECT_FALSE(controller.RemoveEntryAtIndex(2));
|
| + EXPECT_FALSE(controller.RemoveEntryAtIndex(1));
|
| +
|
| + // Remove the first entry, while there is a pending entry. This is expected
|
| + // to discard the pending entry.
|
| + EXPECT_TRUE(controller.RemoveEntryAtIndex(0));
|
| + EXPECT_FALSE(controller.GetPendingEntry());
|
| + EXPECT_EQ(-1, controller.GetPendingEntryIndex());
|
| +
|
| + // We should update the last committed entry index.
|
| + EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
|
| +
|
| + // Now commit and ensure we land on the right entry.
|
| + main_test_rfh()->SendNavigate(1, url2);
|
| + EXPECT_EQ(2, controller.GetEntryCount());
|
| + EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
|
| + EXPECT_FALSE(controller.GetPendingEntry());
|
| +}
|
| +
|
| // Tests the transient entry, making sure it goes away with all navigations.
|
| TEST_F(NavigationControllerTest, TransientEntry) {
|
| NavigationControllerImpl& controller = controller_impl();
|
|
|