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

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: All comments addressed. 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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 // Create a blank tab. 1083 // Create a blank tab.
1084 scoped_ptr<TestWebContents> web_contents1( 1084 scoped_ptr<TestWebContents> web_contents1(
1085 TestWebContents::Create(browser_context(), blank_instance)); 1085 TestWebContents::Create(browser_context(), blank_instance));
1086 FrameTree tree1(web_contents1->GetFrameTree()->root()->navigator(), 1086 FrameTree tree1(web_contents1->GetFrameTree()->root()->navigator(),
1087 web_contents1.get(), web_contents1.get(), 1087 web_contents1.get(), web_contents1.get(),
1088 web_contents1.get(), web_contents1.get()); 1088 web_contents1.get(), web_contents1.get());
1089 RenderFrameHostManager* manager1 = tree1.root()->render_manager(); 1089 RenderFrameHostManager* manager1 = tree1.root()->render_manager();
1090 manager1->Init( 1090 manager1->Init(
1091 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 1091 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
1092 // Test the case that new RVH is considered live. 1092 // Test the case that new RVH is considered live.
1093 manager1->current_host()->CreateRenderView(base::string16(), -1, -1, false); 1093 manager1->current_host()->CreateRenderView(
1094 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1094 1095
1095 // Navigate to a WebUI page. 1096 // Navigate to a WebUI page.
1096 const GURL kUrl1("chrome://foo"); 1097 const GURL kUrl1("chrome://foo");
1097 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 1098 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
1098 Referrer(), base::string16() /* title */, 1099 Referrer(), base::string16() /* title */,
1099 PAGE_TRANSITION_TYPED, 1100 PAGE_TRANSITION_TYPED,
1100 false /* is_renderer_init */); 1101 false /* is_renderer_init */);
1101 RenderFrameHostImpl* host1 = manager1->Navigate(entry1); 1102 RenderFrameHostImpl* host1 = manager1->Navigate(entry1);
1102 1103
1103 // We should have a pending navigation to the WebUI RenderViewHost. 1104 // We should have a pending navigation to the WebUI RenderViewHost.
(...skipping 14 matching lines...) Expand all
1118 scoped_ptr<TestWebContents> web_contents2( 1119 scoped_ptr<TestWebContents> web_contents2(
1119 TestWebContents::Create(browser_context(), webui_instance)); 1120 TestWebContents::Create(browser_context(), webui_instance));
1120 FrameTree tree2(web_contents2->GetFrameTree()->root()->navigator(), 1121 FrameTree tree2(web_contents2->GetFrameTree()->root()->navigator(),
1121 web_contents2.get(), web_contents2.get(), 1122 web_contents2.get(), web_contents2.get(),
1122 web_contents2.get(), web_contents2.get()); 1123 web_contents2.get(), web_contents2.get());
1123 RenderFrameHostManager* manager2 = tree2.root()->render_manager(); 1124 RenderFrameHostManager* manager2 = tree2.root()->render_manager();
1124 manager2->Init( 1125 manager2->Init(
1125 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 1126 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
1126 // Make sure the new RVH is considered live. This is usually done in 1127 // Make sure the new RVH is considered live. This is usually done in
1127 // RenderWidgetHost::Init when opening a new tab from a link. 1128 // RenderWidgetHost::Init when opening a new tab from a link.
1128 manager2->current_host()->CreateRenderView(base::string16(), -1, -1, false); 1129 manager2->current_host()->CreateRenderView(
1130 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1129 1131
1130 const GURL kUrl2("chrome://foo/bar"); 1132 const GURL kUrl2("chrome://foo/bar");
1131 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, 1133 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2,
1132 Referrer(), base::string16() /* title */, 1134 Referrer(), base::string16() /* title */,
1133 PAGE_TRANSITION_LINK, 1135 PAGE_TRANSITION_LINK,
1134 true /* is_renderer_init */); 1136 true /* is_renderer_init */);
1135 RenderFrameHostImpl* host2 = manager2->Navigate(entry2); 1137 RenderFrameHostImpl* host2 = manager2->Navigate(entry2);
1136 1138
1137 // No cross-process transition happens because we are already in the right 1139 // No cross-process transition happens because we are already in the right
1138 // SiteInstance. We should grant bindings immediately. 1140 // SiteInstance. We should grant bindings immediately.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 1323
1322 // Create a new tab as an opener for the main tab. 1324 // Create a new tab as an opener for the main tab.
1323 scoped_ptr<TestWebContents> opener1( 1325 scoped_ptr<TestWebContents> opener1(
1324 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 1326 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
1325 RenderFrameHostManager* opener1_manager = 1327 RenderFrameHostManager* opener1_manager =
1326 opener1->GetRenderManagerForTesting(); 1328 opener1->GetRenderManagerForTesting();
1327 contents()->SetOpener(opener1.get()); 1329 contents()->SetOpener(opener1.get());
1328 1330
1329 // Make sure the new opener RVH is considered live. 1331 // Make sure the new opener RVH is considered live.
1330 opener1_manager->current_host()->CreateRenderView( 1332 opener1_manager->current_host()->CreateRenderView(
1331 base::string16(), -1, -1, false); 1333 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1332 1334
1333 // Use a cross-process navigation in the opener to swap out the old RVH. 1335 // Use a cross-process navigation in the opener to swap out the old RVH.
1334 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( 1336 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost(
1335 rvh1->GetSiteInstance())); 1337 rvh1->GetSiteInstance()));
1336 opener1->NavigateAndCommit(kUrl2); 1338 opener1->NavigateAndCommit(kUrl2);
1337 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost( 1339 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost(
1338 rvh1->GetSiteInstance())); 1340 rvh1->GetSiteInstance()));
1339 1341
1340 // Fake a process crash. 1342 // Fake a process crash.
1341 RenderProcessHost::RendererClosedDetails details( 1343 RenderProcessHost::RendererClosedDetails details(
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 pending_rfh->GetSiteInstance())->increment_active_view_count(); 1842 pending_rfh->GetSiteInstance())->increment_active_view_count();
1841 1843
1842 main_test_rfh()->OnMessageReceived( 1844 main_test_rfh()->OnMessageReceived(
1843 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); 1845 FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
1844 EXPECT_FALSE(contents()->cross_navigation_pending()); 1846 EXPECT_FALSE(contents()->cross_navigation_pending());
1845 EXPECT_FALSE(rvh_deleted_observer.deleted()); 1847 EXPECT_FALSE(rvh_deleted_observer.deleted());
1846 } 1848 }
1847 } 1849 }
1848 1850
1849 } // namespace content 1851 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698