| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 // redirect and abort. See http://crbug.com/83031. | 996 // redirect and abort. See http://crbug.com/83031. |
| 997 TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) { | 997 TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) { |
| 998 NavigationControllerImpl& controller = controller_impl(); | 998 NavigationControllerImpl& controller = controller_impl(); |
| 999 TestNotificationTracker notifications; | 999 TestNotificationTracker notifications; |
| 1000 RegisterForAllNavNotifications(¬ifications, &controller); | 1000 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1001 | 1001 |
| 1002 // First make an existing committed entry. | 1002 // First make an existing committed entry. |
| 1003 const GURL kExistingURL("http://foo/eh"); | 1003 const GURL kExistingURL("http://foo/eh"); |
| 1004 controller.LoadURL(kExistingURL, content::Referrer(), | 1004 controller.LoadURL(kExistingURL, content::Referrer(), |
| 1005 content::PAGE_TRANSITION_TYPED, std::string()); | 1005 content::PAGE_TRANSITION_TYPED, std::string()); |
| 1006 main_test_rfh()->SendNavigate(0, kExistingURL); | 1006 main_test_rfh()->SendNavigate(1, kExistingURL); |
| 1007 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1007 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1008 navigation_entry_committed_counter_ = 0; | 1008 navigation_entry_committed_counter_ = 0; |
| 1009 | 1009 |
| 1010 // Set a WebContentsDelegate to listen for state changes. | 1010 // Set a WebContentsDelegate to listen for state changes. |
| 1011 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); | 1011 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); |
| 1012 EXPECT_FALSE(contents()->GetDelegate()); | 1012 EXPECT_FALSE(contents()->GetDelegate()); |
| 1013 contents()->SetDelegate(delegate.get()); | 1013 contents()->SetDelegate(delegate.get()); |
| 1014 | 1014 |
| 1015 // Now make a pending new navigation, initiated by the renderer. | 1015 // Now make a pending new navigation, initiated by the renderer. |
| 1016 const GURL kNewURL("http://foo/bee"); | 1016 const GURL kNewURL("http://foo/bee"); |
| 1017 NavigationController::LoadURLParams load_url_params(kNewURL); | 1017 NavigationController::LoadURLParams load_url_params(kNewURL); |
| 1018 load_url_params.transition_type = PAGE_TRANSITION_TYPED; | 1018 load_url_params.transition_type = PAGE_TRANSITION_TYPED; |
| 1019 load_url_params.is_renderer_initiated = true; | 1019 load_url_params.is_renderer_initiated = true; |
| 1020 controller.LoadURLWithParams(load_url_params); | 1020 controller.LoadURLWithParams(load_url_params); |
| 1021 EXPECT_EQ(0U, notifications.size()); | 1021 EXPECT_EQ(0U, notifications.size()); |
| 1022 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 1022 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 1023 EXPECT_TRUE(controller.GetPendingEntry()); | 1023 EXPECT_TRUE(controller.GetPendingEntry()); |
| 1024 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 1024 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 1025 EXPECT_EQ(0, delegate->navigation_state_change_count()); | 1025 EXPECT_EQ(0, delegate->navigation_state_change_count()); |
| 1026 | 1026 |
| 1027 // The visible entry should be the last committed URL, not the pending one. | 1027 // The visible entry should be the last committed URL, not the pending one. |
| 1028 EXPECT_EQ(kExistingURL, controller.GetVisibleEntry()->GetURL()); | 1028 EXPECT_EQ(kExistingURL, controller.GetVisibleEntry()->GetURL()); |
| 1029 | 1029 |
| 1030 // Now the navigation redirects. | 1030 // Now the navigation redirects. |
| 1031 const GURL kRedirectURL("http://foo/see"); | 1031 const GURL kRedirectURL("http://foo/see"); |
| 1032 main_test_rfh()->OnMessageReceived( | 1032 main_test_rfh()->OnMessageReceived( |
| 1033 FrameHostMsg_DidRedirectProvisionalLoad(0, // routing_id | 1033 FrameHostMsg_DidRedirectProvisionalLoad(0, // routing_id |
| 1034 -1, // pending page_id | 1034 1, // pending page_id |
| 1035 kNewURL, // old url | 1035 kNewURL, // old url |
| 1036 kRedirectURL)); // new url | 1036 kRedirectURL)); // new url |
| 1037 | 1037 |
| 1038 // We don't want to change the NavigationEntry's url, in case it cancels. | 1038 // We don't want to change the NavigationEntry's url, in case it cancels. |
| 1039 // Prevents regression of http://crbug.com/77786. | 1039 // Prevents regression of http://crbug.com/77786. |
| 1040 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); | 1040 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); |
| 1041 | 1041 |
| 1042 // It may abort before committing, if it's a download or due to a stop or | 1042 // It may abort before committing, if it's a download or due to a stop or |
| 1043 // a new navigation from the user. | 1043 // a new navigation from the user. |
| 1044 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 1044 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
| (...skipping 3290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4335 params.post_id = -1; | 4335 params.post_id = -1; |
| 4336 test_rvh()->SendNavigateWithParams(¶ms); | 4336 test_rvh()->SendNavigateWithParams(¶ms); |
| 4337 | 4337 |
| 4338 // Now reload. replaceState overrides the POST, so we should not show a | 4338 // Now reload. replaceState overrides the POST, so we should not show a |
| 4339 // repost warning dialog. | 4339 // repost warning dialog. |
| 4340 controller_impl().Reload(true); | 4340 controller_impl().Reload(true); |
| 4341 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4341 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
| 4342 } | 4342 } |
| 4343 | 4343 |
| 4344 } // namespace content | 4344 } // namespace content |
| OLD | NEW |