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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 118553006: Move DidFailProvisionalLoad handling from RenderView(Host) to RenderFrame(Host). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Huh? Created 6 years, 11 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 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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "content/browser/frame_host/navigation_controller_impl.h" 14 #include "content/browser/frame_host/navigation_controller_impl.h"
15 #include "content/browser/frame_host/navigation_entry_impl.h" 15 #include "content/browser/frame_host/navigation_entry_impl.h"
16 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" 16 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
17 #include "content/browser/frame_host/navigator.h" 17 #include "content/browser/frame_host/navigator.h"
18 #include "content/browser/site_instance_impl.h" 18 #include "content/browser/site_instance_impl.h"
19 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
20 #include "content/common/frame_messages.h"
20 #include "content/common/view_messages.h" 21 #include "content/common/view_messages.h"
21 #include "content/public/browser/navigation_details.h" 22 #include "content/public/browser/navigation_details.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents_delegate.h" 26 #include "content/public/browser/web_contents_delegate.h"
26 #include "content/public/browser/web_contents_observer.h" 27 #include "content/public/browser/web_contents_observer.h"
27 #include "content/public/common/page_state.h" 28 #include "content/public/common/page_state.h"
28 #include "content/public/common/url_constants.h" 29 #include "content/public/common/url_constants.h"
29 #include "content/public/test/mock_render_process_host.h" 30 #include "content/public/test/mock_render_process_host.h"
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 controller.LoadURL( 948 controller.LoadURL(
948 kNewURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 949 kNewURL, Referrer(), PAGE_TRANSITION_TYPED, std::string());
949 EXPECT_EQ(0U, notifications.size()); 950 EXPECT_EQ(0U, notifications.size());
950 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 951 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
951 EXPECT_TRUE(controller.GetPendingEntry()); 952 EXPECT_TRUE(controller.GetPendingEntry());
952 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); 953 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex());
953 EXPECT_EQ(1, delegate->navigation_state_change_count()); 954 EXPECT_EQ(1, delegate->navigation_state_change_count());
954 955
955 // It may abort before committing, if it's a download or due to a stop or 956 // It may abort before committing, if it's a download or due to a stop or
956 // a new navigation from the user. 957 // a new navigation from the user.
957 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; 958 FrameHostMsg_DidFailProvisionalLoadWithError_Params params;
958 params.frame_id = 1; 959 params.frame_id = 1;
959 params.is_main_frame = true; 960 params.is_main_frame = true;
960 params.error_code = net::ERR_ABORTED; 961 params.error_code = net::ERR_ABORTED;
961 params.error_description = base::string16(); 962 params.error_description = base::string16();
962 params.url = kNewURL; 963 params.url = kNewURL;
963 params.showing_repost_interstitial = false; 964 params.showing_repost_interstitial = false;
964 test_rvh()->OnMessageReceived( 965 test_rvh()->OnMessageReceived(
965 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id 966 FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
Charlie Reis 2014/01/06 18:13:35 nit: This had the wrong indent before, so we shoul
nasko 2014/01/06 18:47:03 Done.
966 params)); 967 params));
967 968
968 // This should not clear the pending entry or notify of a navigation state 969 // This should not clear the pending entry or notify of a navigation state
969 // change, so that we keep displaying kNewURL (until the user clears it). 970 // change, so that we keep displaying kNewURL (until the user clears it).
970 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 971 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
971 EXPECT_TRUE(controller.GetPendingEntry()); 972 EXPECT_TRUE(controller.GetPendingEntry());
972 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); 973 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex());
973 EXPECT_EQ(1, delegate->navigation_state_change_count()); 974 EXPECT_EQ(1, delegate->navigation_state_change_count());
974 NavigationEntry* pending_entry = controller.GetPendingEntry(); 975 NavigationEntry* pending_entry = controller.GetPendingEntry();
975 976
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 -1, // pending page_id 1026 -1, // pending page_id
1026 kNewURL, // old url 1027 kNewURL, // old url
1027 kRedirectURL)); // new url 1028 kRedirectURL)); // new url
1028 1029
1029 // We don't want to change the NavigationEntry's url, in case it cancels. 1030 // We don't want to change the NavigationEntry's url, in case it cancels.
1030 // Prevents regression of http://crbug.com/77786. 1031 // Prevents regression of http://crbug.com/77786.
1031 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); 1032 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL());
1032 1033
1033 // It may abort before committing, if it's a download or due to a stop or 1034 // It may abort before committing, if it's a download or due to a stop or
1034 // a new navigation from the user. 1035 // a new navigation from the user.
1035 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; 1036 FrameHostMsg_DidFailProvisionalLoadWithError_Params params;
1036 params.frame_id = 1; 1037 params.frame_id = 1;
1037 params.is_main_frame = true; 1038 params.is_main_frame = true;
1038 params.error_code = net::ERR_ABORTED; 1039 params.error_code = net::ERR_ABORTED;
1039 params.error_description = base::string16(); 1040 params.error_description = base::string16();
1040 params.url = kRedirectURL; 1041 params.url = kRedirectURL;
1041 params.showing_repost_interstitial = false; 1042 params.showing_repost_interstitial = false;
1042 test_rvh()->OnMessageReceived( 1043 test_rvh()->OnMessageReceived(
1043 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id 1044 FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
1044 params)); 1045 params));
1045 1046
1046 // Because the pending entry is renderer initiated and not visible, we 1047 // Because the pending entry is renderer initiated and not visible, we
1047 // clear it when it fails. 1048 // clear it when it fails.
1048 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 1049 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
1049 EXPECT_FALSE(controller.GetPendingEntry()); 1050 EXPECT_FALSE(controller.GetPendingEntry());
1050 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 1051 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
1051 EXPECT_EQ(0, delegate->navigation_state_change_count()); 1052 EXPECT_EQ(0, delegate->navigation_state_change_count());
1052 1053
1053 // The visible entry should be the last committed URL, not the pending one, 1054 // The visible entry should be the last committed URL, not the pending one,
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, 2406 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE,
2406 NavigationEntryImpl::FromNavigationEntry( 2407 NavigationEntryImpl::FromNavigationEntry(
2407 our_controller.GetEntryAtIndex(0))->restore_type()); 2408 our_controller.GetEntryAtIndex(0))->restore_type());
2408 EXPECT_TRUE(NavigationEntryImpl::FromNavigationEntry( 2409 EXPECT_TRUE(NavigationEntryImpl::FromNavigationEntry(
2409 our_controller.GetEntryAtIndex(0))->site_instance()); 2410 our_controller.GetEntryAtIndex(0))->site_instance());
2410 2411
2411 // This pending navigation may have caused a different navigation to fail, 2412 // This pending navigation may have caused a different navigation to fail,
2412 // which causes the pending entry to be cleared. 2413 // which causes the pending entry to be cleared.
2413 TestRenderViewHost* rvh = 2414 TestRenderViewHost* rvh =
2414 static_cast<TestRenderViewHost*>(our_contents->GetRenderViewHost()); 2415 static_cast<TestRenderViewHost*>(our_contents->GetRenderViewHost());
2415 ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; 2416 FrameHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params;
2416 fail_load_params.frame_id = 1; 2417 fail_load_params.frame_id = 1;
2417 fail_load_params.is_main_frame = true; 2418 fail_load_params.is_main_frame = true;
2418 fail_load_params.error_code = net::ERR_ABORTED; 2419 fail_load_params.error_code = net::ERR_ABORTED;
2419 fail_load_params.error_description = base::string16(); 2420 fail_load_params.error_description = base::string16();
2420 fail_load_params.url = url; 2421 fail_load_params.url = url;
2421 fail_load_params.showing_repost_interstitial = false; 2422 fail_load_params.showing_repost_interstitial = false;
2422 rvh->OnMessageReceived( 2423 rvh->OnMessageReceived(
2423 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id 2424 FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
2424 fail_load_params)); 2425 fail_load_params));
2425 2426
2426 // Now the pending restored entry commits. 2427 // Now the pending restored entry commits.
2427 ViewHostMsg_FrameNavigate_Params params; 2428 ViewHostMsg_FrameNavigate_Params params;
2428 params.page_id = 0; 2429 params.page_id = 0;
2429 params.url = url; 2430 params.url = url;
2430 params.transition = PAGE_TRANSITION_LINK; 2431 params.transition = PAGE_TRANSITION_LINK;
2431 params.should_update_history = false; 2432 params.should_update_history = false;
2432 params.gesture = NavigationGestureUser; 2433 params.gesture = NavigationGestureUser;
2433 params.is_post = false; 2434 params.is_post = false;
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 EXPECT_EQ(1, controller.GetEntryCount()); 4015 EXPECT_EQ(1, controller.GetEntryCount());
4015 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 4016 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
4016 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 4017 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
4017 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 4018 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
4018 EXPECT_FALSE(controller.CanGoBack()); 4019 EXPECT_FALSE(controller.CanGoBack());
4019 EXPECT_FALSE(controller.CanGoForward()); 4020 EXPECT_FALSE(controller.CanGoForward());
4020 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); 4021 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
4021 } 4022 }
4022 4023
4023 } // namespace content 4024 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigator.h » ('j') | content/browser/frame_host/navigator_delegate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698