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 91a7a52750e57511cc9ae6b0313e3fff98825757..aeefbbbdef019e33e50c1c02fceb3a8ed4c939e5 100644 |
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc |
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
@@ -218,6 +218,7 @@ class NavigationControllerTest |
void DidStartNavigationToPendingEntry(const GURL& url, |
ReloadType reload_type) override { |
navigated_url_ = url; |
+ last_reload_type_ = reload_type; |
} |
void NavigationEntryCommitted( |
@@ -262,6 +263,7 @@ class NavigationControllerTest |
protected: |
GURL navigated_url_; |
size_t navigation_entry_committed_counter_; |
+ ReloadType last_reload_type_; |
}; |
void RegisterForAllNavNotifications(TestNotificationTracker* tracker, |
@@ -5210,4 +5212,87 @@ TEST_F(NavigationControllerTest, StaleNavigationsResurrected) { |
EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); |
} |
+// Tests that successive navigations with intermittent duplicate navigations |
+// are correctly marked as reload in the navigation controller. |
+// We test the cases where in a navigation is pending/comitted before the new |
+// navigation is initiated. |
+// http://crbug.com/664319 |
+TEST_F(NavigationControllerTest, MultipleNavigationsAndReload) { |
+ NavigationControllerImpl& controller = controller_impl(); |
+ TestNotificationTracker notifications; |
+ RegisterForAllNavNotifications(¬ifications, &controller); |
+ |
+ GURL initial_url("http://www.google.com"); |
+ GURL url_1("http://foo.com"); |
+ GURL url_2("http://foo2.com"); |
+ |
+ // Test 1. |
+ // A normal navigation to initial_url should not be marked as a reload. |
+ controller.LoadURL(initial_url, Referrer(), ui::PAGE_TRANSITION_TYPED, |
+ std::string()); |
+ EXPECT_EQ(initial_url, controller.GetVisibleEntry()->GetURL()); |
+ main_test_rfh()->SimulateNavigationStart(initial_url); |
+ EXPECT_EQ(initial_url, controller.GetVisibleEntry()->GetURL()); |
+ |
+ main_test_rfh()->SimulateNavigationCommit(initial_url); |
+ EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
+ |
+ // Test 2. |
+ // A navigation to initial_url with the navigation commit delayed should be |
+ // marked as a reload. |
+ controller.LoadURL(initial_url, Referrer(), ui::PAGE_TRANSITION_TYPED, |
+ std::string()); |
+ |
+ EXPECT_EQ(initial_url, controller.GetVisibleEntry()->GetURL()); |
+ main_test_rfh()->SimulateNavigationStart(initial_url); |
+ EXPECT_EQ(initial_url, controller.GetVisibleEntry()->GetURL()); |
+ EXPECT_EQ(ReloadType::NORMAL, last_reload_type_); |
+ |
+ // Test 3. |
+ // A navigation to url_1 while the navigation to intial_url is still pending |
+ // should not be marked as a reload. |
+ controller.LoadURL(url_1, Referrer(), ui::PAGE_TRANSITION_TYPED, |
+ std::string()); |
+ |
+ EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
+ main_test_rfh()->SimulateNavigationStart(url_1); |
+ EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
+ EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
+ |
+ // Test 4. |
+ // A navigation to url_1 while the previous navigation to url_1 is pending |
+ // should be marked as reload. |
+ controller.LoadURL(url_1, Referrer(), ui::PAGE_TRANSITION_TYPED, |
+ std::string()); |
+ |
+ EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
+ main_test_rfh()->SimulateNavigationStart(url_1); |
+ EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
+ EXPECT_EQ(ReloadType::NORMAL, last_reload_type_); |
+ |
+ main_test_rfh()->SimulateNavigationCommit(initial_url); |
+ |
+ // Test 5 |
+ // A navigation to url_2 followed by a navigation to the previously pending |
+ // url_1 shoul not be marked as a reload. |
+ controller.LoadURL(url_2, Referrer(), ui::PAGE_TRANSITION_TYPED, |
+ std::string()); |
+ EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL()); |
+ main_test_rfh()->SimulateNavigationStart(url_2); |
+ EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL()); |
+ EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
+ |
+ controller.LoadURL(url_1, Referrer(), ui::PAGE_TRANSITION_TYPED, |
+ std::string()); |
+ |
+ EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
+ main_test_rfh()->SimulateNavigationStart(url_1); |
+ EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
+ EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
+ |
+ main_test_rfh()->SimulateNavigationCommit(url_2); |
+ main_test_rfh()->SimulateNavigationCommit(url_1); |
+ main_test_rfh()->SimulateNavigationCommit(url_1); |
+} |
+ |
} // namespace content |