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

Side by Side Diff: content/browser/tab_contents/navigation_controller_unittest.cc

Issue 6709056: Avoid corrupting the pending_entry when an unexpected navigation commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clear pending entry Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 606
607 // Now start going back one to the second page. It will be pending. 607 // Now start going back one to the second page. It will be pending.
608 controller().GoBack(); 608 controller().GoBack();
609 EXPECT_EQ(1, controller().pending_entry_index()); 609 EXPECT_EQ(1, controller().pending_entry_index());
610 EXPECT_EQ(2, controller().last_committed_entry_index()); 610 EXPECT_EQ(2, controller().last_committed_entry_index());
611 611
612 // Not synthesize a totally new back event to the first page. This will not 612 // Not synthesize a totally new back event to the first page. This will not
613 // match the pending one. 613 // match the pending one.
614 rvh()->SendNavigate(0, kUrl1); 614 rvh()->SendNavigate(0, kUrl1);
615 615
616 // The navigation should not have affected the pending entry. 616 // The committed navigation should clear the pending entry.
617 EXPECT_EQ(1, controller().pending_entry_index()); 617 EXPECT_EQ(-1, controller().pending_entry_index());
618 618
619 // But the navigated entry should be the last committed. 619 // But the navigated entry should be the last committed.
620 EXPECT_EQ(0, controller().last_committed_entry_index()); 620 EXPECT_EQ(0, controller().last_committed_entry_index());
621 EXPECT_EQ(kUrl1, controller().GetLastCommittedEntry()->url()); 621 EXPECT_EQ(kUrl1, controller().GetLastCommittedEntry()->url());
622 } 622 }
623 623
624 // Tests what happens when we navigate forward successfully. 624 // Tests what happens when we navigate forward successfully.
625 TEST_F(NavigationControllerTest, Forward) { 625 TEST_F(NavigationControllerTest, Forward) {
626 TestNotificationTracker notifications; 626 TestNotificationTracker notifications;
627 RegisterForAllNavNotifications(&notifications, &controller()); 627 RegisterForAllNavNotifications(&notifications, &controller());
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 TabNavigation nav(0, url0, GURL(), string16(), 2032 TabNavigation nav(0, url0, GURL(), string16(),
2033 webkit_glue::CreateHistoryStateForURL(url0), 2033 webkit_glue::CreateHistoryStateForURL(url0),
2034 PageTransition::LINK); 2034 PageTransition::LINK);
2035 session_helper_.AssertNavigationEquals(nav, 2035 session_helper_.AssertNavigationEquals(nav,
2036 windows_[0]->tabs[0]->navigations[0]); 2036 windows_[0]->tabs[0]->navigations[0]);
2037 nav.set_url(url2); 2037 nav.set_url(url2);
2038 session_helper_.AssertNavigationEquals(nav, 2038 session_helper_.AssertNavigationEquals(nav,
2039 windows_[0]->tabs[0]->navigations[1]); 2039 windows_[0]->tabs[0]->navigations[1]);
2040 } 2040 }
2041 */ 2041 */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698