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

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: Fix IPC_BEGIN_MESSAGE_MAP macro, as _EX version doesn't exist anymore. 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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) { 1041 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) {
1042 set_should_create_webui(true); 1042 set_should_create_webui(true);
1043 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); 1043 SiteInstance* blank_instance = SiteInstance::Create(browser_context());
1044 1044
1045 // Create a blank tab. 1045 // Create a blank tab.
1046 scoped_ptr<TestWebContents> web_contents1( 1046 scoped_ptr<TestWebContents> web_contents1(
1047 TestWebContents::Create(browser_context(), blank_instance)); 1047 TestWebContents::Create(browser_context(), blank_instance));
1048 RenderFrameHostManager* manager1 = 1048 RenderFrameHostManager* manager1 =
1049 web_contents1->GetRenderManagerForTesting(); 1049 web_contents1->GetRenderManagerForTesting();
1050 // Test the case that new RVH is considered live. 1050 // Test the case that new RVH is considered live.
1051 manager1->current_host()->CreateRenderView(base::string16(), -1, -1, false); 1051 manager1->current_host()->CreateRenderView(
1052 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1052 1053
1053 // Navigate to a WebUI page. 1054 // Navigate to a WebUI page.
1054 const GURL kUrl1("chrome://foo"); 1055 const GURL kUrl1("chrome://foo");
1055 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 1056 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
1056 Referrer(), base::string16() /* title */, 1057 Referrer(), base::string16() /* title */,
1057 PAGE_TRANSITION_TYPED, 1058 PAGE_TRANSITION_TYPED,
1058 false /* is_renderer_init */); 1059 false /* is_renderer_init */);
1059 RenderFrameHostImpl* host1 = manager1->Navigate(entry1); 1060 RenderFrameHostImpl* host1 = manager1->Navigate(entry1);
1060 1061
1061 // We should have a pending navigation to the WebUI RenderViewHost. 1062 // We should have a pending navigation to the WebUI RenderViewHost.
(...skipping 10 matching lines...) Expand all
1072 EXPECT_TRUE( 1073 EXPECT_TRUE(
1073 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1074 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1074 1075
1075 // Now simulate clicking a link that opens in a new tab. 1076 // Now simulate clicking a link that opens in a new tab.
1076 scoped_ptr<TestWebContents> web_contents2( 1077 scoped_ptr<TestWebContents> web_contents2(
1077 TestWebContents::Create(browser_context(), webui_instance)); 1078 TestWebContents::Create(browser_context(), webui_instance));
1078 RenderFrameHostManager* manager2 = 1079 RenderFrameHostManager* manager2 =
1079 web_contents2->GetRenderManagerForTesting(); 1080 web_contents2->GetRenderManagerForTesting();
1080 // Make sure the new RVH is considered live. This is usually done in 1081 // Make sure the new RVH is considered live. This is usually done in
1081 // RenderWidgetHost::Init when opening a new tab from a link. 1082 // RenderWidgetHost::Init when opening a new tab from a link.
1082 manager2->current_host()->CreateRenderView(base::string16(), -1, -1, false); 1083 manager2->current_host()->CreateRenderView(
1084 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1083 1085
1084 const GURL kUrl2("chrome://foo/bar"); 1086 const GURL kUrl2("chrome://foo/bar");
1085 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, 1087 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2,
1086 Referrer(), base::string16() /* title */, 1088 Referrer(), base::string16() /* title */,
1087 PAGE_TRANSITION_LINK, 1089 PAGE_TRANSITION_LINK,
1088 true /* is_renderer_init */); 1090 true /* is_renderer_init */);
1089 RenderFrameHostImpl* host2 = manager2->Navigate(entry2); 1091 RenderFrameHostImpl* host2 = manager2->Navigate(entry2);
1090 1092
1091 // No cross-process transition happens because we are already in the right 1093 // No cross-process transition happens because we are already in the right
1092 // SiteInstance. We should grant bindings immediately. 1094 // SiteInstance. We should grant bindings immediately.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 1277
1276 // Create a new tab as an opener for the main tab. 1278 // Create a new tab as an opener for the main tab.
1277 scoped_ptr<TestWebContents> opener1( 1279 scoped_ptr<TestWebContents> opener1(
1278 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 1280 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
1279 RenderFrameHostManager* opener1_manager = 1281 RenderFrameHostManager* opener1_manager =
1280 opener1->GetRenderManagerForTesting(); 1282 opener1->GetRenderManagerForTesting();
1281 contents()->SetOpener(opener1.get()); 1283 contents()->SetOpener(opener1.get());
1282 1284
1283 // Make sure the new opener RVH is considered live. 1285 // Make sure the new opener RVH is considered live.
1284 opener1_manager->current_host()->CreateRenderView( 1286 opener1_manager->current_host()->CreateRenderView(
1285 base::string16(), -1, -1, false); 1287 base::string16(), -1, MSG_ROUTING_NONE, -1, false);
1286 1288
1287 // Use a cross-process navigation in the opener to swap out the old RVH. 1289 // Use a cross-process navigation in the opener to swap out the old RVH.
1288 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( 1290 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost(
1289 rvh1->GetSiteInstance())); 1291 rvh1->GetSiteInstance()));
1290 opener1->NavigateAndCommit(kUrl2); 1292 opener1->NavigateAndCommit(kUrl2);
1291 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost( 1293 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost(
1292 rvh1->GetSiteInstance())); 1294 rvh1->GetSiteInstance()));
1293 1295
1294 // Fake a process crash. 1296 // Fake a process crash.
1295 RenderProcessHost::RendererClosedDetails details( 1297 RenderProcessHost::RendererClosedDetails details(
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 pending_rfh->GetSiteInstance())->increment_active_view_count(); 1782 pending_rfh->GetSiteInstance())->increment_active_view_count();
1781 1783
1782 main_test_rfh()->OnMessageReceived( 1784 main_test_rfh()->OnMessageReceived(
1783 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); 1785 FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
1784 EXPECT_FALSE(contents()->cross_navigation_pending()); 1786 EXPECT_FALSE(contents()->cross_navigation_pending());
1785 EXPECT_FALSE(rvh_deleted_observer.deleted()); 1787 EXPECT_FALSE(rvh_deleted_observer.deleted());
1786 } 1788 }
1787 } 1789 }
1788 1790
1789 } // namespace content 1791 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | content/browser/frame_host/render_frame_proxy_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698