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

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

Issue 281663002: Create RenderFrameProxyHost at time of swap-out instead of commit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/render_view_host/GetRenderViewHost/ Created 6 years, 7 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/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/frame_host/cross_site_transferring_request.h" 7 #include "content/browser/frame_host/cross_site_transferring_request.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/frame_host/navigator.h" 10 #include "content/browser/frame_host/navigator.h"
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) { 1053 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) {
1054 set_should_create_webui(true); 1054 set_should_create_webui(true);
1055 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); 1055 SiteInstance* blank_instance = SiteInstance::Create(browser_context());
1056 1056
1057 // Create a blank tab. 1057 // Create a blank tab.
1058 scoped_ptr<TestWebContents> web_contents1( 1058 scoped_ptr<TestWebContents> web_contents1(
1059 TestWebContents::Create(browser_context(), blank_instance)); 1059 TestWebContents::Create(browser_context(), blank_instance));
1060 RenderFrameHostManager* manager1 = 1060 RenderFrameHostManager* manager1 =
1061 web_contents1->GetRenderManagerForTesting(); 1061 web_contents1->GetRenderManagerForTesting();
1062 // Test the case that new RVH is considered live. 1062 // Test the case that new RVH is considered live.
1063 manager1->current_host()->CreateRenderView(base::string16(), -1, -1, false); 1063 manager1->current_host()->CreateRenderView(
1064 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1064 1065
1065 // Navigate to a WebUI page. 1066 // Navigate to a WebUI page.
1066 const GURL kUrl1("chrome://foo"); 1067 const GURL kUrl1("chrome://foo");
1067 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 1068 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
1068 Referrer(), base::string16() /* title */, 1069 Referrer(), base::string16() /* title */,
1069 PAGE_TRANSITION_TYPED, 1070 PAGE_TRANSITION_TYPED,
1070 false /* is_renderer_init */); 1071 false /* is_renderer_init */);
1071 RenderFrameHostImpl* host1 = manager1->Navigate(entry1); 1072 RenderFrameHostImpl* host1 = manager1->Navigate(entry1);
1072 1073
1073 // We should have a pending navigation to the WebUI RenderViewHost. 1074 // We should have a pending navigation to the WebUI RenderViewHost.
(...skipping 10 matching lines...) Expand all
1084 EXPECT_TRUE( 1085 EXPECT_TRUE(
1085 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1086 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1086 1087
1087 // Now simulate clicking a link that opens in a new tab. 1088 // Now simulate clicking a link that opens in a new tab.
1088 scoped_ptr<TestWebContents> web_contents2( 1089 scoped_ptr<TestWebContents> web_contents2(
1089 TestWebContents::Create(browser_context(), webui_instance)); 1090 TestWebContents::Create(browser_context(), webui_instance));
1090 RenderFrameHostManager* manager2 = 1091 RenderFrameHostManager* manager2 =
1091 web_contents2->GetRenderManagerForTesting(); 1092 web_contents2->GetRenderManagerForTesting();
1092 // Make sure the new RVH is considered live. This is usually done in 1093 // Make sure the new RVH is considered live. This is usually done in
1093 // RenderWidgetHost::Init when opening a new tab from a link. 1094 // RenderWidgetHost::Init when opening a new tab from a link.
1094 manager2->current_host()->CreateRenderView(base::string16(), -1, -1, false); 1095 manager2->current_host()->CreateRenderView(
1096 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1095 1097
1096 const GURL kUrl2("chrome://foo/bar"); 1098 const GURL kUrl2("chrome://foo/bar");
1097 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, 1099 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2,
1098 Referrer(), base::string16() /* title */, 1100 Referrer(), base::string16() /* title */,
1099 PAGE_TRANSITION_LINK, 1101 PAGE_TRANSITION_LINK,
1100 true /* is_renderer_init */); 1102 true /* is_renderer_init */);
1101 RenderFrameHostImpl* host2 = manager2->Navigate(entry2); 1103 RenderFrameHostImpl* host2 = manager2->Navigate(entry2);
1102 1104
1103 // No cross-process transition happens because we are already in the right 1105 // No cross-process transition happens because we are already in the right
1104 // SiteInstance. We should grant bindings immediately. 1106 // SiteInstance. We should grant bindings immediately.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 1289
1288 // Create a new tab as an opener for the main tab. 1290 // Create a new tab as an opener for the main tab.
1289 scoped_ptr<TestWebContents> opener1( 1291 scoped_ptr<TestWebContents> opener1(
1290 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 1292 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
1291 RenderFrameHostManager* opener1_manager = 1293 RenderFrameHostManager* opener1_manager =
1292 opener1->GetRenderManagerForTesting(); 1294 opener1->GetRenderManagerForTesting();
1293 contents()->SetOpener(opener1.get()); 1295 contents()->SetOpener(opener1.get());
1294 1296
1295 // Make sure the new opener RVH is considered live. 1297 // Make sure the new opener RVH is considered live.
1296 opener1_manager->current_host()->CreateRenderView( 1298 opener1_manager->current_host()->CreateRenderView(
1297 base::string16(), -1, -1, false); 1299 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1298 1300
1299 // Use a cross-process navigation in the opener to swap out the old RVH. 1301 // Use a cross-process navigation in the opener to swap out the old RVH.
1300 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( 1302 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost(
1301 rvh1->GetSiteInstance())); 1303 rvh1->GetSiteInstance()));
1302 opener1->NavigateAndCommit(kUrl2); 1304 opener1->NavigateAndCommit(kUrl2);
1303 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost( 1305 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost(
1304 rvh1->GetSiteInstance())); 1306 rvh1->GetSiteInstance()));
1305 1307
1306 // Fake a process crash. 1308 // Fake a process crash.
1307 RenderProcessHost::RendererClosedDetails details( 1309 RenderProcessHost::RendererClosedDetails details(
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 pending_rfh->GetSiteInstance())->increment_active_view_count(); 1794 pending_rfh->GetSiteInstance())->increment_active_view_count();
1793 1795
1794 main_test_rfh()->OnMessageReceived( 1796 main_test_rfh()->OnMessageReceived(
1795 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); 1797 FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
1796 EXPECT_FALSE(contents()->cross_navigation_pending()); 1798 EXPECT_FALSE(contents()->cross_navigation_pending());
1797 EXPECT_FALSE(rvh_deleted_observer.deleted()); 1799 EXPECT_FALSE(rvh_deleted_observer.deleted());
1798 } 1800 }
1799 } 1801 }
1800 1802
1801 } // namespace content 1803 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698