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