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

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

Issue 135723003: Move DidCommitProvisionalLoad code from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit tests and removed WebContents::DidNavigate Created 6 years, 10 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/browser/frame_host/navigation_controller_impl.h" 6 #include "content/browser/frame_host/navigation_controller_impl.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/frame_host/navigator.h"
8 #include "content/browser/frame_host/render_frame_host_manager.h" 9 #include "content/browser/frame_host/render_frame_host_manager.h"
9 #include "content/browser/site_instance_impl.h" 10 #include "content/browser/site_instance_impl.h"
10 #include "content/browser/webui/web_ui_controller_factory_registry.h" 11 #include "content/browser/webui/web_ui_controller_factory_registry.h"
12 #include "content/common/frame_messages.h"
11 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
12 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
13 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
15 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/render_widget_host_iterator.h" 19 #include "content/public/browser/render_widget_host_iterator.h"
18 #include "content/public/browser/web_contents_delegate.h" 20 #include "content/public/browser/web_contents_delegate.h"
19 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/browser/web_ui_controller.h" 22 #include "content/public/browser/web_ui_controller.h"
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 968
967 // Now let's simulate the evil page calling history.back(). 969 // Now let's simulate the evil page calling history.back().
968 contents()->OnGoToEntryAtOffset(-1); 970 contents()->OnGoToEntryAtOffset(-1);
969 // We should have a new pending RVH. 971 // We should have a new pending RVH.
970 // Note that in this case, the navigation has not committed, so evil_rvh will 972 // Note that in this case, the navigation has not committed, so evil_rvh will
971 // not be deleted yet. 973 // not be deleted yet.
972 EXPECT_NE(evil_rvh, contents()->GetRenderManagerForTesting()-> 974 EXPECT_NE(evil_rvh, contents()->GetRenderManagerForTesting()->
973 pending_render_view_host()); 975 pending_render_view_host());
974 976
975 // Before that RVH has committed, the evil page reloads itself. 977 // Before that RVH has committed, the evil page reloads itself.
976 ViewHostMsg_FrameNavigate_Params params; 978 FrameHostMsg_DidCommitProvisionalLoad_Params params;
977 params.page_id = 1; 979 params.page_id = 1;
978 params.url = kUrl2; 980 params.url = kUrl2;
979 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT; 981 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT;
980 params.should_update_history = false; 982 params.should_update_history = false;
981 params.gesture = NavigationGestureAuto; 983 params.gesture = NavigationGestureAuto;
982 params.was_within_same_page = false; 984 params.was_within_same_page = false;
983 params.is_post = false; 985 params.is_post = false;
984 params.page_state = PageState::CreateFromURL(kUrl2); 986 params.page_state = PageState::CreateFromURL(kUrl2);
985 contents()->DidNavigate(evil_rvh, params); 987
988 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(evil_rvh);
989 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(
990 rvh->GetProcess()->GetID(), rvh->main_frame_routing_id());
991 contents()->GetFrameTree()->root()->navigator()->DidNavigate(rfh, params);
986 992
987 // That should have cancelled the pending RVH, and the evil RVH should be the 993 // That should have cancelled the pending RVH, and the evil RVH should be the
988 // current one. 994 // current one.
989 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> 995 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->
990 pending_render_view_host() == NULL); 996 pending_render_view_host() == NULL);
991 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); 997 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host());
992 998
993 // Also we should not have a pending navigation entry. 999 // Also we should not have a pending navigation entry.
994 EXPECT_TRUE(contents()->GetController().GetPendingEntry() == NULL); 1000 EXPECT_TRUE(contents()->GetController().GetPendingEntry() == NULL);
995 NavigationEntry* entry = contents()->GetController().GetVisibleEntry(); 1001 NavigationEntry* entry = contents()->GetController().GetVisibleEntry();
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 Source<RenderWidgetHost>(host2->render_view_host())); 1342 Source<RenderWidgetHost>(host2->render_view_host()));
1337 manager->ShouldClosePage(false, true, base::TimeTicks()); 1343 manager->ShouldClosePage(false, true, base::TimeTicks());
1338 1344
1339 EXPECT_TRUE( 1345 EXPECT_TRUE(
1340 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); 1346 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED));
1341 EXPECT_FALSE(manager->pending_frame_host()); 1347 EXPECT_FALSE(manager->pending_frame_host());
1342 EXPECT_EQ(host, manager->current_frame_host()); 1348 EXPECT_EQ(host, manager->current_frame_host());
1343 } 1349 }
1344 1350
1345 } // namespace content 1351 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698