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

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

Issue 257083002: Check BrowsingInstance before swapping prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 MSG_ROUTING_NONE); 1042 MSG_ROUTING_NONE);
1043 EXPECT_FALSE(manager->current_host()->IsRenderViewLive()); 1043 EXPECT_FALSE(manager->current_host()->IsRenderViewLive());
1044 1044
1045 const GURL kUrl("chrome://foo"); 1045 const GURL kUrl("chrome://foo");
1046 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, 1046 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl,
1047 Referrer(), base::string16() /* title */, 1047 Referrer(), base::string16() /* title */,
1048 PAGE_TRANSITION_TYPED, 1048 PAGE_TRANSITION_TYPED,
1049 false /* is_renderer_init */); 1049 false /* is_renderer_init */);
1050 RenderFrameHostImpl* host = manager->Navigate(entry); 1050 RenderFrameHostImpl* host = manager->Navigate(entry);
1051 1051
1052 // This test creates a second FrameTree for the WebContents which throws off
1053 // some of the accounting. This inverts what was done in
1054 // WebContentsImpl::NotifySwapped.
1055 static_cast<SiteInstanceImpl*>(instance)->
1056 IncrementRelatedActiveContentsCount();
1057 static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->
1058 DecrementRelatedActiveContentsCount();
davidben 2014/04/28 18:34:39 Not super-thrilled about this bit. Another possibi
Charlie Reis 2014/04/29 22:13:51 I'm not entirely sure why we need a separate Frame
davidben 2014/04/29 23:02:25 Oh. Well then. Handy. I've gone and fixed those.
1059
1052 // We commit the pending RenderFrameHost immediately because the previous 1060 // We commit the pending RenderFrameHost immediately because the previous
1053 // RenderFrameHost was not live. We test a case where it is live in 1061 // RenderFrameHost was not live. We test a case where it is live in
1054 // WebUIInNewTab. 1062 // WebUIInNewTab.
1055 EXPECT_TRUE(host); 1063 EXPECT_TRUE(host);
1056 EXPECT_EQ(host, manager->current_frame_host()); 1064 EXPECT_EQ(host, manager->current_frame_host());
1057 EXPECT_FALSE(manager->pending_frame_host()); 1065 EXPECT_FALSE(manager->pending_frame_host());
1058 1066
1059 // It's important that the site instance get set on the Web UI page as soon 1067 // It's important that the site instance get set on the Web UI page as soon
1060 // as the navigation starts, rather than lazily after it commits, so we don't 1068 // as the navigation starts, rather than lazily after it commits, so we don't
1061 // try to re-use the SiteInstance/process for non Web UI things that may 1069 // try to re-use the SiteInstance/process for non Web UI things that may
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 EXPECT_TRUE( 1116 EXPECT_TRUE(
1109 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1117 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1110 1118
1111 // Commit and ensure we still have bindings. 1119 // Commit and ensure we still have bindings.
1112 manager1->DidNavigateFrame(host1); 1120 manager1->DidNavigateFrame(host1);
1113 SiteInstance* webui_instance = host1->GetSiteInstance(); 1121 SiteInstance* webui_instance = host1->GetSiteInstance();
1114 EXPECT_EQ(host1, manager1->current_frame_host()); 1122 EXPECT_EQ(host1, manager1->current_frame_host());
1115 EXPECT_TRUE( 1123 EXPECT_TRUE(
1116 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); 1124 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1117 1125
1126 // This test creates a second FrameTree for the WebContents which throws off
1127 // some of the accounting. This inverts what was done in
1128 // WebContentsImpl::NotifySwapped.
1129 static_cast<SiteInstanceImpl*>(blank_instance)->
1130 IncrementRelatedActiveContentsCount();
1131 static_cast<SiteInstanceImpl*>(host1->GetSiteInstance())->
1132 DecrementRelatedActiveContentsCount();
1133
davidben 2014/04/28 18:34:39 Ditto.
1118 // Now simulate clicking a link that opens in a new tab. 1134 // Now simulate clicking a link that opens in a new tab.
1119 scoped_ptr<TestWebContents> web_contents2( 1135 scoped_ptr<TestWebContents> web_contents2(
1120 TestWebContents::Create(browser_context(), webui_instance)); 1136 TestWebContents::Create(browser_context(), webui_instance));
1121 FrameTree tree2(web_contents2->GetFrameTree()->root()->navigator(), 1137 FrameTree tree2(web_contents2->GetFrameTree()->root()->navigator(),
1122 web_contents2.get(), web_contents2.get(), 1138 web_contents2.get(), web_contents2.get(),
1123 web_contents2.get(), web_contents2.get()); 1139 web_contents2.get(), web_contents2.get());
1124 RenderFrameHostManager* manager2 = tree2.root()->render_manager(); 1140 RenderFrameHostManager* manager2 = tree2.root()->render_manager();
1125 manager2->Init( 1141 manager2->Init(
1126 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); 1142 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE);
1127 // Make sure the new RVH is considered live. This is usually done in 1143 // Make sure the new RVH is considered live. This is usually done in
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 pending_rfh->GetSiteInstance())->increment_active_view_count(); 1857 pending_rfh->GetSiteInstance())->increment_active_view_count();
1842 1858
1843 main_test_rfh()->OnMessageReceived( 1859 main_test_rfh()->OnMessageReceived(
1844 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); 1860 FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
1845 EXPECT_FALSE(contents()->cross_navigation_pending()); 1861 EXPECT_FALSE(contents()->cross_navigation_pending());
1846 EXPECT_FALSE(rvh_deleted_observer.deleted()); 1862 EXPECT_FALSE(rvh_deleted_observer.deleted());
1847 } 1863 }
1848 } 1864 }
1849 1865
1850 } // namespace content 1866 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698