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

Unified 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: creis comments Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/render_frame_host_manager_unittest.cc
diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc
index c0afa6718885eef93b86cdd0888ecee92c5869bc..8e44208c5d5f841e91a5c585e5f55e166ba27f5a 100644
--- a/content/browser/frame_host/render_frame_host_manager_unittest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc
@@ -1049,6 +1049,14 @@ TEST_F(RenderFrameHostManagerTest, WebUI) {
false /* is_renderer_init */);
RenderFrameHostImpl* host = manager->Navigate(entry);
+ // This test creates a second FrameTree for the WebContents which throws off
+ // some of the accounting. This inverts what was done in
+ // WebContentsImpl::NotifySwapped.
+ static_cast<SiteInstanceImpl*>(instance)->
+ IncrementRelatedActiveContentsCount();
+ static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->
+ DecrementRelatedActiveContentsCount();
+
// We commit the pending RenderFrameHost immediately because the previous
// RenderFrameHost was not live. We test a case where it is live in
// WebUIInNewTab.
@@ -1115,6 +1123,14 @@ TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) {
EXPECT_TRUE(
host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
+ // This test creates a second FrameTree for the WebContents which throws off
+ // some of the accounting. This inverts what was done in
+ // WebContentsImpl::NotifySwapped.
+ static_cast<SiteInstanceImpl*>(blank_instance)->
+ IncrementRelatedActiveContentsCount();
+ static_cast<SiteInstanceImpl*>(host1->GetSiteInstance())->
+ DecrementRelatedActiveContentsCount();
+
// Now simulate clicking a link that opens in a new tab.
scoped_ptr<TestWebContents> web_contents2(
TestWebContents::Create(browser_context(), webui_instance));

Powered by Google App Engine
This is Rietveld 408576698