Commit eb7a973b authored by Charlie Reis's avatar Charlie Reis Committed by Commit Bot

Remove GetSwappedOutRenderViewHost.

This is no longer necessary now that we track RenderFrameProxyHosts.
This CL also cleans up many other references to "swapped out."

Bug: 1015882
Change-Id: Ib5391d360460540945891232c5eca0701fce138f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2022350
Commit-Queue: Charlie Reis <creis@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736480}
parent aa9d6fbc
...@@ -2371,8 +2371,8 @@ bool RenderFrameHostManager::ReinitializeRenderFrame( ...@@ -2371,8 +2371,8 @@ bool RenderFrameHostManager::ReinitializeRenderFrame(
// Main frames need both the RenderView and RenderFrame reinitialized, so // Main frames need both the RenderView and RenderFrame reinitialized, so
// use InitRenderView. For cross-process subframes, InitRenderView won't // use InitRenderView. For cross-process subframes, InitRenderView won't
// recreate the RenderFrame, so use InitRenderFrame instead. Note that for // recreate the RenderFrame, so use InitRenderFrame instead. Note that for
// subframe RenderFrameHosts, the swapped out RenderView in their // subframe RenderFrameHosts, the inactive RenderView in their SiteInstance
// SiteInstance will be recreated as part of CreateOpenerProxies above. // will be recreated as part of CreateOpenerProxies above.
if (!frame_tree_node_->parent()) { if (!frame_tree_node_->parent()) {
DCHECK(!GetRenderFrameProxyHost(render_frame_host->GetSiteInstance())); DCHECK(!GetRenderFrameProxyHost(render_frame_host->GetSiteInstance()));
if (!InitRenderView(render_frame_host->render_view_host(), nullptr)) if (!InitRenderView(render_frame_host->render_view_host(), nullptr))
...@@ -2684,14 +2684,6 @@ std::unique_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost( ...@@ -2684,14 +2684,6 @@ std::unique_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost(
return old_render_frame_host; return old_render_frame_host;
} }
RenderViewHostImpl* RenderFrameHostManager::GetSwappedOutRenderViewHost(
SiteInstance* instance) const {
RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
if (proxy)
return proxy->GetRenderViewHost();
return nullptr;
}
RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost( RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost(
SiteInstance* instance) const { SiteInstance* instance) const {
auto it = proxy_hosts_.find(instance->GetId()); auto it = proxy_hosts_.find(instance->GetId());
...@@ -2924,7 +2916,7 @@ void RenderFrameHostManager::CreateNewFrameForInnerDelegateAttachIfNecessary() { ...@@ -2924,7 +2916,7 @@ void RenderFrameHostManager::CreateNewFrameForInnerDelegateAttachIfNecessary() {
NotifyPrepareForInnerDelegateAttachComplete(false /* success */); NotifyPrepareForInnerDelegateAttachComplete(false /* success */);
return; return;
} }
// Swap in the speculative frame. It will later on be swapped out when the // Swap in the speculative frame. It will later be replaced when
// WebContents::AttachToOuterWebContentsFrame is called. // WebContents::AttachToOuterWebContentsFrame is called.
speculative_render_frame_host_->Send( speculative_render_frame_host_->Send(
new FrameMsg_SwapIn(speculative_render_frame_host_->GetRoutingID())); new FrameMsg_SwapIn(speculative_render_frame_host_->GetRoutingID()));
......
...@@ -283,10 +283,6 @@ class CONTENT_EXPORT RenderFrameHostManager ...@@ -283,10 +283,6 @@ class CONTENT_EXPORT RenderFrameHostManager
// SiteInstance. // SiteInstance.
void CreateProxiesForChildFrame(FrameTreeNode* child); void CreateProxiesForChildFrame(FrameTreeNode* child);
// Returns the swapped out RenderViewHost for the given SiteInstance, if any.
// This method is *deprecated* and GetRenderFrameProxyHost should be used.
RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const;
// Returns the RenderFrameProxyHost for the given SiteInstance, if any. // Returns the RenderFrameProxyHost for the given SiteInstance, if any.
RenderFrameProxyHost* GetRenderFrameProxyHost(SiteInstance* instance) const; RenderFrameProxyHost* GetRenderFrameProxyHost(SiteInstance* instance) const;
...@@ -385,7 +381,7 @@ class CONTENT_EXPORT RenderFrameHostManager ...@@ -385,7 +381,7 @@ class CONTENT_EXPORT RenderFrameHostManager
void EnsureRenderViewInitialized(RenderViewHostImpl* render_view_host, void EnsureRenderViewInitialized(RenderViewHostImpl* render_view_host,
SiteInstance* instance); SiteInstance* instance);
// Creates swapped out RenderViews and RenderFrameProxies for this frame's // Creates RenderFrameProxies and inactive RenderViewHosts for this frame's
// FrameTree and for its opener chain in the given SiteInstance. This allows // FrameTree and for its opener chain in the given SiteInstance. This allows
// other tabs to send cross-process JavaScript calls to their opener(s) and // other tabs to send cross-process JavaScript calls to their opener(s) and
// to any other frames in the opener's FrameTree (e.g., supporting calls like // to any other frames in the opener's FrameTree (e.g., supporting calls like
...@@ -412,8 +408,8 @@ class CONTENT_EXPORT RenderFrameHostManager ...@@ -412,8 +408,8 @@ class CONTENT_EXPORT RenderFrameHostManager
// RenderFrameProxyHost in its outer WebContents's SiteInstance, // RenderFrameProxyHost in its outer WebContents's SiteInstance,
// |outer_contents_site_instance|. The frame in outer WebContents that is // |outer_contents_site_instance|. The frame in outer WebContents that is
// hosting the inner WebContents is |render_frame_host|, and the frame will // hosting the inner WebContents is |render_frame_host|, and the frame will
// be swapped out with the proxy. Note that this method must only be called // be swapped with the proxy. Note that this method must only be called for an
// for an OOPIF-based inner WebContents. // OOPIF-based inner WebContents.
RenderFrameProxyHost* CreateOuterDelegateProxy( RenderFrameProxyHost* CreateOuterDelegateProxy(
SiteInstance* outer_contents_site_instance); SiteInstance* outer_contents_site_instance);
...@@ -473,8 +469,8 @@ class CONTENT_EXPORT RenderFrameHostManager ...@@ -473,8 +469,8 @@ class CONTENT_EXPORT RenderFrameHostManager
// Sets up the necessary state for a new RenderViewHost. If |proxy| is not // Sets up the necessary state for a new RenderViewHost. If |proxy| is not
// null, it creates a RenderFrameProxy in the target renderer process which is // null, it creates a RenderFrameProxy in the target renderer process which is
// used to route IPC messages when in swapped out state. Returns early if the // used to route IPC messages. Returns early if the RenderViewHost has
// RenderViewHost has already been initialized for another RenderFrameHost. // already been initialized for another RenderFrameHost.
bool InitRenderView(RenderViewHostImpl* render_view_host, bool InitRenderView(RenderViewHostImpl* render_view_host,
RenderFrameProxyHost* proxy); RenderFrameProxyHost* proxy);
...@@ -684,7 +680,7 @@ class CONTENT_EXPORT RenderFrameHostManager ...@@ -684,7 +680,7 @@ class CONTENT_EXPORT RenderFrameHostManager
std::vector<FrameTree*>* opener_frame_trees, std::vector<FrameTree*>* opener_frame_trees,
std::unordered_set<FrameTreeNode*>* nodes_with_back_links); std::unordered_set<FrameTreeNode*>* nodes_with_back_links);
// Create swapped out RenderViews and RenderFrameProxies in the given // Create RenderFrameProxies and inactive RenderViewHosts in the given
// SiteInstance for the current node's FrameTree. Used as a helper function // SiteInstance for the current node's FrameTree. Used as a helper function
// in CreateOpenerProxies for creating proxies in each FrameTree on the // in CreateOpenerProxies for creating proxies in each FrameTree on the
// opener chain. Don't create proxies for the subtree rooted at // opener chain. Don't create proxies for the subtree rooted at
......
...@@ -1040,13 +1040,11 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1040,13 +1040,11 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
RenderFrameHostManager* new_manager = RenderFrameHostManager* new_manager =
static_cast<WebContentsImpl*>(new_contents)->GetRenderManagerForTesting(); static_cast<WebContentsImpl*>(new_contents)->GetRenderManagerForTesting();
// We now have three windows. The opener should have a swapped out RVH // We now have three windows. The opener should have a RenderFrameProxyHost
// for the new SiteInstance, but the _blank window should not. // for the new SiteInstance, but the _blank window should not.
EXPECT_EQ(3u, Shell::windows().size()); EXPECT_EQ(3u, Shell::windows().size());
EXPECT_TRUE( EXPECT_TRUE(opener_manager->GetRenderFrameProxyHost(foo_site_instance.get()));
opener_manager->GetSwappedOutRenderViewHost(foo_site_instance.get())); EXPECT_FALSE(new_manager->GetRenderFrameProxyHost(foo_site_instance.get()));
EXPECT_FALSE(
new_manager->GetSwappedOutRenderViewHost(foo_site_instance.get()));
// 2) Fail to post a message from the foo window to the opener if the target // 2) Fail to post a message from the foo window to the opener if the target
// origin is wrong. We won't see an error, but we can check for the right // origin is wrong. We won't see an error, but we can check for the right
...@@ -1058,7 +1056,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1058,7 +1056,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
&success)); &success));
EXPECT_TRUE(success); EXPECT_TRUE(success);
ASSERT_FALSE( ASSERT_FALSE(
opener_manager->GetSwappedOutRenderViewHost(orig_site_instance.get())); opener_manager->GetRenderFrameProxyHost(orig_site_instance.get()));
// 3) Post a message from the foo window to the opener. The opener will // 3) Post a message from the foo window to the opener. The opener will
// reply, causing the foo window to update its own title. // reply, causing the foo window to update its own title.
...@@ -1070,7 +1068,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1070,7 +1068,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
&success)); &success));
EXPECT_TRUE(success); EXPECT_TRUE(success);
ASSERT_FALSE( ASSERT_FALSE(
opener_manager->GetSwappedOutRenderViewHost(orig_site_instance.get())); opener_manager->GetRenderFrameProxyHost(orig_site_instance.get()));
ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle());
// We should have received only 1 message in the opener and "foo" tabs, // We should have received only 1 message in the opener and "foo" tabs,
...@@ -1099,10 +1097,9 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1099,10 +1097,9 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
EXPECT_TRUE(success); EXPECT_TRUE(success);
ASSERT_EQ(expected_title, title_watcher2.WaitAndGetTitle()); ASSERT_EQ(expected_title, title_watcher2.WaitAndGetTitle());
// This postMessage should have created a swapped out RVH for the new // This postMessage should have created a RenderFrameProxyHost for the new
// SiteInstance in the target=_blank window. // SiteInstance in the target=_blank window.
EXPECT_TRUE( EXPECT_TRUE(new_manager->GetRenderFrameProxyHost(foo_site_instance.get()));
new_manager->GetSwappedOutRenderViewHost(foo_site_instance.get()));
// TODO(nasko): Test subframe targeting of postMessage once // TODO(nasko): Test subframe targeting of postMessage once
// http://crbug.com/153701 is fixed. // http://crbug.com/153701 is fixed.
...@@ -1162,11 +1159,10 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1162,11 +1159,10 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
foo_contents->GetSiteInstance()); foo_contents->GetSiteInstance());
EXPECT_NE(orig_site_instance, foo_site_instance); EXPECT_NE(orig_site_instance, foo_site_instance);
// We now have two windows. The opener should have a swapped out RVH // We now have two windows. The opener should have a RenderFrameProxyHost
// for the new SiteInstance. // for the new SiteInstance.
EXPECT_EQ(2u, Shell::windows().size()); EXPECT_EQ(2u, Shell::windows().size());
EXPECT_TRUE( EXPECT_TRUE(opener_manager->GetRenderFrameProxyHost(foo_site_instance.get()));
opener_manager->GetSwappedOutRenderViewHost(foo_site_instance.get()));
// 2) Post a message containing a MessagePort from opener to the the foo // 2) Post a message containing a MessagePort from opener to the the foo
// window. The foo window will reply via the passed port, causing the opener // window. The foo window will reply via the passed port, causing the opener
...@@ -1178,7 +1174,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1178,7 +1174,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
"window.domAutomationController.send(postWithPortToFoo());", &success)); "window.domAutomationController.send(postWithPortToFoo());", &success));
EXPECT_TRUE(success); EXPECT_TRUE(success);
ASSERT_FALSE( ASSERT_FALSE(
opener_manager->GetSwappedOutRenderViewHost(orig_site_instance.get())); opener_manager->GetRenderFrameProxyHost(orig_site_instance.get()));
ASSERT_EQ(expected_title, title_observer.WaitAndGetTitle()); ASSERT_EQ(expected_title, title_observer.WaitAndGetTitle());
// Check message counts. // Check message counts.
...@@ -1268,7 +1264,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1268,7 +1264,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
} }
// Test that subframes do not crash when sending a postMessage to the top frame // Test that subframes do not crash when sending a postMessage to the top frame
// from an unload handler while the top frame is being swapped out as part of // from an unload handler while the top frame is being replaced as part of
// navigating cross-process. https://crbug.com/475651. // navigating cross-process. https://crbug.com/475651.
IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
PostMessageFromSubframeUnloadHandler) { PostMessageFromSubframeUnloadHandler) {
...@@ -1295,8 +1291,8 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1295,8 +1291,8 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
EXPECT_TRUE(ExecuteScript(root->child_at(0), "registerUnload();")); EXPECT_TRUE(ExecuteScript(root->child_at(0), "registerUnload();"));
// Navigate the top frame cross-site. This will cause the top frame to be // Navigate the top frame cross-site. This will cause the top frame to be
// swapped out and run unload handlers, and the original renderer process // unloaded, and the original renderer process should then terminate since
// should then terminate since it's not rendering any other frames. // it's not rendering any other frames.
RenderProcessHostWatcher exit_observer( RenderProcessHostWatcher exit_observer(
root->current_frame_host()->GetProcess(), root->current_frame_host()->GetProcess(),
RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION);
...@@ -1366,7 +1362,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -1366,7 +1362,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
EXPECT_TRUE(orig_process->IsInitializedAndNotDead()); EXPECT_TRUE(orig_process->IsInitializedAndNotDead());
// Navigate the first window to a different site as well. The original // Navigate the first window to a different site as well. The original
// process should exit, since all of its views are now swapped out. // process should exit, since all of its active frames are gone.
RenderProcessHostWatcher exit_observer( RenderProcessHostWatcher exit_observer(
orig_process, RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); orig_process, RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION);
EXPECT_TRUE(NavigateToURLInSameBrowsingInstance(shell(), cross_site_url)); EXPECT_TRUE(NavigateToURLInSameBrowsingInstance(shell(), cross_site_url));
...@@ -2299,7 +2295,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -2299,7 +2295,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
// Specifically: // Specifically:
// 1) Open 2 tabs in an HTTP SiteInstance, with a subframe in the opener. // 1) Open 2 tabs in an HTTP SiteInstance, with a subframe in the opener.
// 2) Send the second tab to a different foo.com SiteInstance. // 2) Send the second tab to a different foo.com SiteInstance.
// This created a swapped out opener for the first tab in the foo process. // This created an opener proxy for the first tab in the foo process.
// 3) Navigate the first tab to the foo.com SiteInstance, and have the first // 3) Navigate the first tab to the foo.com SiteInstance, and have the first
// tab's unload handler remove its frame. // tab's unload handler remove its frame.
// In older versions of Chrome, this caused an update to the frame tree that // In older versions of Chrome, this caused an update to the frame tree that
...@@ -2507,10 +2503,10 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, WebUIGetsBindings) { ...@@ -2507,10 +2503,10 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, WebUIGetsBindings) {
EXPECT_NE(site_instance2, site_instance1); EXPECT_NE(site_instance2, site_instance1);
EXPECT_TRUE(site_instance2->IsRelatedSiteInstance(site_instance1)); EXPECT_TRUE(site_instance2->IsRelatedSiteInstance(site_instance1));
RenderViewHost* initial_rvh = RenderFrameProxyHost* initial_rfph =
new_web_contents->GetRenderManagerForTesting() new_web_contents->GetRenderManagerForTesting()->GetRenderFrameProxyHost(
->GetSwappedOutRenderViewHost(site_instance1); site_instance1);
ASSERT_TRUE(initial_rvh); ASSERT_TRUE(initial_rfph);
// Navigate to url1 and check bindings. // Navigate to url1 and check bindings.
EXPECT_TRUE(NavigateToURLInSameBrowsingInstance(new_shell, url1)); EXPECT_TRUE(NavigateToURLInSameBrowsingInstance(new_shell, url1));
...@@ -3054,20 +3050,19 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -3054,20 +3050,19 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
EXPECT_FALSE( EXPECT_FALSE(
popup_root->current_frame_host()->render_view_host()->IsRenderViewLive()); popup_root->current_frame_host()->render_view_host()->IsRenderViewLive());
// The swapped-out RVH and proxy for the opener page in the foo.com // The proxy and RVH for the opener page in the foo.com SiteInstance should
// SiteInstance should not be live. // not be live.
RenderFrameHostManager* opener_manager = root->render_manager(); RenderFrameHostManager* opener_manager = root->render_manager();
RenderViewHostImpl* opener_rvh =
opener_manager->GetSwappedOutRenderViewHost(foo_site_instance.get());
EXPECT_TRUE(opener_rvh);
EXPECT_FALSE(opener_rvh->IsRenderViewLive());
RenderFrameProxyHost* opener_rfph = RenderFrameProxyHost* opener_rfph =
opener_manager->GetRenderFrameProxyHost(foo_site_instance.get()); opener_manager->GetRenderFrameProxyHost(foo_site_instance.get());
EXPECT_TRUE(opener_rfph); EXPECT_TRUE(opener_rfph);
EXPECT_FALSE(opener_rfph->is_render_frame_proxy_live()); EXPECT_FALSE(opener_rfph->is_render_frame_proxy_live());
RenderViewHostImpl* opener_rvh = opener_rfph->GetRenderViewHost();
EXPECT_TRUE(opener_rvh);
EXPECT_FALSE(opener_rvh->IsRenderViewLive());
// Re-navigate the popup to the same URL and check that this recreates the // Re-navigate the popup to the same URL and check that this recreates the
// opener's swapped out RVH and proxy in the foo.com SiteInstance. // opener's RVH and proxy in the foo.com SiteInstance.
EXPECT_TRUE(NavigateToURL(new_shell, cross_site_url)); EXPECT_TRUE(NavigateToURL(new_shell, cross_site_url));
EXPECT_TRUE(opener_rvh->IsRenderViewLive()); EXPECT_TRUE(opener_rvh->IsRenderViewLive());
EXPECT_TRUE(opener_rfph->is_render_frame_proxy_live()); EXPECT_TRUE(opener_rfph->is_render_frame_proxy_live());
...@@ -3247,52 +3242,6 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, ...@@ -3247,52 +3242,6 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
back_nav_load_observer.Wait(); back_nav_load_observer.Wait();
} }
// Tests that InputMsg type IPCs are ignored by swapped out RenderViews. It
// uses the SetFocus IPC, as RenderView has a CHECK to ensure that condition
// never happens.
IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
InputMsgToSwappedOutRVHIsIgnored) {
StartEmbeddedServer();
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL("a.com", "/title1.html")));
// Open a popup to navigate cross-process.
Shell* new_shell = OpenPopup(shell(), GURL(url::kAboutBlankURL), "foo");
EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
new_shell->web_contents()->GetSiteInstance());
// Keep a pointer to the RenderViewHost, which will be in swapped out
// state after navigating cross-process. This is how this test is causing
// a swapped out RenderView to receive InputMsg IPC message.
WebContentsImpl* new_web_contents =
static_cast<WebContentsImpl*>(new_shell->web_contents());
FrameTreeNode* new_root = new_web_contents->GetFrameTree()->root();
RenderViewHostImpl* rvh = new_web_contents->GetRenderViewHost();
// Navigate the popup to a different site, so the |rvh| is swapped out.
EXPECT_TRUE(NavigateToURL(
new_shell, embedded_test_server()->GetURL("b.com", "/title2.html")));
EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
new_shell->web_contents()->GetSiteInstance());
EXPECT_EQ(rvh, new_root->render_manager()->GetSwappedOutRenderViewHost(
shell()->web_contents()->GetSiteInstance()));
// Setup a process observer to ensure there is no crash and send the IPC
// message.
RenderProcessHostWatcher watcher(
rvh->GetProcess(), RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
rvh->GetWidget()->GetWidgetInputHandler()->SetFocus(true);
// The test must wait for a process to exit, but if the IPC message is
// properly ignored, there will be no crash. Therefore, navigate the
// original window to the same site as the popup, which will just exit the
// process cleanly.
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL("b.com", "/title3.html")));
watcher.Wait();
EXPECT_TRUE(watcher.did_exit_normally());
}
// Tests that navigating cross-process and reusing an existing RenderViewHost // Tests that navigating cross-process and reusing an existing RenderViewHost
// (whose process has been killed/crashed) recreates properly the RenderView and // (whose process has been killed/crashed) recreates properly the RenderView and
// RenderFrameProxy on the renderer side. // RenderFrameProxy on the renderer side.
......
...@@ -311,8 +311,8 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness { ...@@ -311,8 +311,8 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
return GURL("http://isolated-cross-site.com"); return GURL("http://isolated-cross-site.com");
} }
// Creates a test RenderViewHost that's swapped out. // Creates an inactive test RenderViewHost.
void CreateSwappedOutRenderViewHost() { void CreateInactiveRenderViewHost() {
const GURL kChromeURL(GetWebUIURL("foo")); const GURL kChromeURL(GetWebUIURL("foo"));
const GURL kDestUrl("http://www.google.com/"); const GURL kDestUrl("http://www.google.com/");
...@@ -327,15 +327,15 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness { ...@@ -327,15 +327,15 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
EXPECT_TRUE(contents()->CrossProcessNavigationPending()); EXPECT_TRUE(contents()->CrossProcessNavigationPending());
// Manually increase the number of active frames in the // Manually increase the number of active frames in the
// SiteInstance that ntp_rfh belongs to, to prevent it from being // SiteInstance that ntp_rfh belongs to, to prevent the SiteInstance from
// destroyed when it gets swapped out. // being destroyed when ntp_rfh goes away.
ntp_rfh->GetSiteInstance()->IncrementActiveFrameCount(); ntp_rfh->GetSiteInstance()->IncrementActiveFrameCount();
TestRenderFrameHost* dest_rfh = contents()->GetPendingMainFrame(); TestRenderFrameHost* dest_rfh = contents()->GetPendingMainFrame();
CHECK(dest_rfh); CHECK(dest_rfh);
EXPECT_NE(ntp_rfh, dest_rfh); EXPECT_NE(ntp_rfh, dest_rfh);
// Commit. This will swap out ntp_rfh. // Commit. This replaces ntp_rfh with a proxy and leaves its RVH inactive.
navigation->Commit(); navigation->Commit();
} }
...@@ -590,13 +590,12 @@ TEST_F(RenderFrameHostManagerTest, UpdateFaviconURLWhilePendingUnload) { ...@@ -590,13 +590,12 @@ TEST_F(RenderFrameHostManagerTest, UpdateFaviconURLWhilePendingUnload) {
// Test if RenderViewHost::GetRenderWidgetHosts() only returns active // Test if RenderViewHost::GetRenderWidgetHosts() only returns active
// widgets. // widgets.
TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) { TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) {
CreateSwappedOutRenderViewHost(); CreateInactiveRenderViewHost();
std::unique_ptr<RenderWidgetHostIterator> widgets( std::unique_ptr<RenderWidgetHostIterator> widgets(
RenderWidgetHost::GetRenderWidgetHosts()); RenderWidgetHost::GetRenderWidgetHosts());
// We know that there is the only one active widget. Another view is // We know that there is the only one active widget. Another view is
// now swapped out, so the swapped out view is not included in the // now inactive, so the inactive view is not included in the list.
// list.
RenderWidgetHost* widget = widgets->GetNextHost(); RenderWidgetHost* widget = widgets->GetNextHost();
EXPECT_FALSE(widgets->GetNextHost()); EXPECT_FALSE(widgets->GetNextHost());
RenderViewHost* rvh = RenderViewHost::From(widget); RenderViewHost* rvh = RenderViewHost::From(widget);
...@@ -607,10 +606,10 @@ TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) { ...@@ -607,10 +606,10 @@ TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) {
// RenderViewHostImpl::GetAllRenderWidgetHosts(). // RenderViewHostImpl::GetAllRenderWidgetHosts().
// RenderViewHost::GetRenderWidgetHosts() returns only active widgets, but // RenderViewHost::GetRenderWidgetHosts() returns only active widgets, but
// RenderViewHostImpl::GetAllRenderWidgetHosts() returns everything // RenderViewHostImpl::GetAllRenderWidgetHosts() returns everything
// including swapped out ones. // including inactive ones.
TEST_F(RenderFrameHostManagerTest, TEST_F(RenderFrameHostManagerTest,
GetRenderWidgetHostsWithinGetAllRenderWidgetHosts) { GetRenderWidgetHostsWithinGetAllRenderWidgetHosts) {
CreateSwappedOutRenderViewHost(); CreateInactiveRenderViewHost();
std::unique_ptr<RenderWidgetHostIterator> widgets( std::unique_ptr<RenderWidgetHostIterator> widgets(
RenderWidgetHost::GetRenderWidgetHosts()); RenderWidgetHost::GetRenderWidgetHosts());
...@@ -629,7 +628,7 @@ TEST_F(RenderFrameHostManagerTest, ...@@ -629,7 +628,7 @@ TEST_F(RenderFrameHostManagerTest,
} }
// Test if SiteInstanceImpl::active_frame_count() is correctly updated // Test if SiteInstanceImpl::active_frame_count() is correctly updated
// as frames in a SiteInstance get swapped out and in. // as frames in a SiteInstance get replaced.
TEST_F(RenderFrameHostManagerTest, ActiveFrameCountWhileSwappingInAndOut) { TEST_F(RenderFrameHostManagerTest, ActiveFrameCountWhileSwappingInAndOut) {
const GURL kUrl1("http://www.google.com/"); const GURL kUrl1("http://www.google.com/");
const GURL kUrl2("http://www.chromium.org/"); const GURL kUrl2("http://www.chromium.org/");
...@@ -1175,28 +1174,26 @@ TEST_F(RenderFrameHostManagerTest, CreateProxiesForOpeners) { ...@@ -1175,28 +1174,26 @@ TEST_F(RenderFrameHostManagerTest, CreateProxiesForOpeners) {
// BrowsingInstance). // BrowsingInstance).
contents()->NavigateAndCommit(kUrl2); contents()->NavigateAndCommit(kUrl2);
TestRenderFrameHost* rfh2 = main_test_rfh(); TestRenderFrameHost* rfh2 = main_test_rfh();
TestRenderViewHost* rvh2 = test_rvh();
EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); EXPECT_NE(site_instance1, rfh2->GetSiteInstance());
EXPECT_TRUE(site_instance1->IsRelatedSiteInstance(rfh2->GetSiteInstance())); EXPECT_TRUE(site_instance1->IsRelatedSiteInstance(rfh2->GetSiteInstance()));
// Ensure rvh1 is placed on swapped out list of the current tab. // Ensure rvh1 is kept with the proxy of the current tab.
EXPECT_TRUE(rfh1_deleted_observer.deleted()); EXPECT_TRUE(rfh1_deleted_observer.deleted());
EXPECT_TRUE(manager->GetRenderFrameProxyHost(site_instance1.get())); EXPECT_EQ(rvh1, manager->GetRenderFrameProxyHost(site_instance1.get())
EXPECT_EQ(rvh1, ->GetRenderViewHost());
manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance()));
// Ensure a proxy and inactive RVH are created in the first opener tab.
// Ensure a proxy and swapped out RVH are created in the first opener tab. RenderFrameProxyHost* rfph1 =
EXPECT_TRUE( opener1_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance());
opener1_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance())); TestRenderViewHost* opener1_rvh =
TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( static_cast<TestRenderViewHost*>(rfph1->GetRenderViewHost());
opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance()));
EXPECT_FALSE(opener1_rvh->is_active()); EXPECT_FALSE(opener1_rvh->is_active());
// Ensure a proxy and swapped out RVH are created in the second opener tab. // Ensure a proxy and inactive RVH are created in the second opener tab.
EXPECT_TRUE( RenderFrameProxyHost* rfph2 =
opener2_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance())); opener2_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance());
TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( TestRenderViewHost* opener2_rvh =
opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); static_cast<TestRenderViewHost*>(rfph2->GetRenderViewHost());
EXPECT_FALSE(opener2_rvh->is_active()); EXPECT_FALSE(opener2_rvh->is_active());
// Navigate to a cross-BrowsingInstance URL. // Navigate to a cross-BrowsingInstance URL.
...@@ -1206,15 +1203,11 @@ TEST_F(RenderFrameHostManagerTest, CreateProxiesForOpeners) { ...@@ -1206,15 +1203,11 @@ TEST_F(RenderFrameHostManagerTest, CreateProxiesForOpeners) {
EXPECT_FALSE(site_instance1->IsRelatedSiteInstance(rfh3->GetSiteInstance())); EXPECT_FALSE(site_instance1->IsRelatedSiteInstance(rfh3->GetSiteInstance()));
// No scripting is allowed across BrowsingInstances, so we should not create // No scripting is allowed across BrowsingInstances, so we should not create
// swapped out RVHs for the opener chain in this case. // proxies for the opener chain in this case.
EXPECT_FALSE( EXPECT_FALSE(
opener1_manager->GetRenderFrameProxyHost(rfh3->GetSiteInstance())); opener1_manager->GetRenderFrameProxyHost(rfh3->GetSiteInstance()));
EXPECT_FALSE(
opener1_manager->GetSwappedOutRenderViewHost(rfh3->GetSiteInstance()));
EXPECT_FALSE( EXPECT_FALSE(
opener2_manager->GetRenderFrameProxyHost(rfh3->GetSiteInstance())); opener2_manager->GetRenderFrameProxyHost(rfh3->GetSiteInstance()));
EXPECT_FALSE(
opener2_manager->GetSwappedOutRenderViewHost(rfh3->GetSiteInstance()));
} }
// Test that a page can disown the opener of the WebContents. // Test that a page can disown the opener of the WebContents.
...@@ -1352,9 +1345,9 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) { ...@@ -1352,9 +1345,9 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) {
EXPECT_FALSE(contents()->HasOpener()); EXPECT_FALSE(contents()->HasOpener());
} }
// Test that we clean up swapped out RenderViewHosts when a process hosting // Test that we clean up RenderFrameProxyHosts when a process hosting the
// those associated RenderViews crashes. http://crbug.com/258993 // associated frames crashes. http://crbug.com/258993
TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { TEST_F(RenderFrameHostManagerTest, CleanUpProxiesOnProcessCrash) {
const GURL kUrl1("http://www.google.com/"); const GURL kUrl1("http://www.google.com/");
const GURL kUrl2 = isolated_cross_site_url(); const GURL kUrl2 = isolated_cross_site_url();
...@@ -1376,14 +1369,15 @@ TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { ...@@ -1376,14 +1369,15 @@ TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) {
EXPECT_TRUE(opener1_manager->current_host()->IsRenderViewLive()); EXPECT_TRUE(opener1_manager->current_host()->IsRenderViewLive());
EXPECT_TRUE(opener1_manager->current_frame_host()->IsRenderFrameLive()); EXPECT_TRUE(opener1_manager->current_frame_host()->IsRenderFrameLive());
// Use a cross-process navigation in the opener to swap out the old RVH. // Use a cross-process navigation in the opener to make the old RVH inactive.
EXPECT_FALSE( EXPECT_FALSE(
opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance())); opener1_manager->GetRenderFrameProxyHost(rfh1->GetSiteInstance()));
opener1->NavigateAndCommit(kUrl2); opener1->NavigateAndCommit(kUrl2);
RenderViewHostImpl* swapped_out_rvh = RenderFrameProxyHost* rfph1 =
opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance()); opener1_manager->GetRenderFrameProxyHost(rfh1->GetSiteInstance());
EXPECT_TRUE(swapped_out_rvh); RenderViewHostImpl* rvh1 = rfph1->GetRenderViewHost();
EXPECT_FALSE(swapped_out_rvh->is_active()); EXPECT_TRUE(rvh1);
EXPECT_FALSE(rvh1->is_active());
// Fake a process crash. // Fake a process crash.
rfh1->GetProcess()->SimulateCrash(); rfh1->GetProcess()->SimulateCrash();
...@@ -1392,23 +1386,20 @@ TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { ...@@ -1392,23 +1386,20 @@ TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) {
// is deleted. // is deleted.
RenderFrameProxyHost* render_frame_proxy_host = RenderFrameProxyHost* render_frame_proxy_host =
opener1_manager->GetRenderFrameProxyHost(rfh1->GetSiteInstance()); opener1_manager->GetRenderFrameProxyHost(rfh1->GetSiteInstance());
EXPECT_TRUE(render_frame_proxy_host); EXPECT_EQ(rfph1, render_frame_proxy_host);
EXPECT_FALSE(render_frame_proxy_host->is_render_frame_proxy_live()); EXPECT_FALSE(render_frame_proxy_host->is_render_frame_proxy_live());
// Expect the swapped out RVH to exist but not be live. // Expect the RVH to exist but not be live.
EXPECT_TRUE( EXPECT_TRUE(rfph1->GetRenderViewHost());
opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance())); EXPECT_FALSE(rfph1->GetRenderViewHost()->IsRenderViewLive());
EXPECT_FALSE(
opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance())
->IsRenderViewLive());
// Reload the initial tab. This should recreate the opener's swapped out RVH // Reload the initial tab. This should recreate the opener's RVH in the
// in the original SiteInstance. // original SiteInstance.
contents()->GetController().Reload(ReloadType::NORMAL, true); contents()->GetController().Reload(ReloadType::NORMAL, true);
contents()->GetMainFrame()->PrepareForCommit(); contents()->GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* rfh2 = contents()->GetMainFrame(); TestRenderFrameHost* rfh2 = contents()->GetMainFrame();
EXPECT_TRUE( EXPECT_TRUE(opener1_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance())
opener1_manager->GetSwappedOutRenderViewHost(rfh2->GetSiteInstance()) ->GetRenderViewHost()
->IsRenderViewLive()); ->IsRenderViewLive());
EXPECT_EQ( EXPECT_EQ(
opener1_manager->GetRoutingIdForSiteInstance(rfh2->GetSiteInstance()), opener1_manager->GetRoutingIdForSiteInstance(rfh2->GetSiteInstance()),
...@@ -1685,9 +1676,9 @@ TEST_F(RenderFrameHostManagerTest, UnloadFrameAfterUnloadACK) { ...@@ -1685,9 +1676,9 @@ TEST_F(RenderFrameHostManagerTest, UnloadFrameAfterUnloadACK) {
EXPECT_TRUE(rfh_deleted_observer.deleted()); EXPECT_TRUE(rfh_deleted_observer.deleted());
} }
// Test that the RenderViewHost is properly swapped out if a navigation in the // Test that a RenderFrameHost is properly deleted if a navigation in the new
// new renderer commits before sending the UnfreezableFrameMsg_Unload message to // renderer commits before sending the UnfreezableFrameMsg_Unload message to the
// the old renderer. // old renderer.
// This simulates a cross-site navigation to a synchronously committing URL // This simulates a cross-site navigation to a synchronously committing URL
// (e.g., a data URL) and ensures it works properly. // (e.g., a data URL) and ensures it works properly.
TEST_F(RenderFrameHostManagerTest, CommitNewNavigationBeforeSendingUnload) { TEST_F(RenderFrameHostManagerTest, CommitNewNavigationBeforeSendingUnload) {
...@@ -1704,8 +1695,8 @@ TEST_F(RenderFrameHostManagerTest, CommitNewNavigationBeforeSendingUnload) { ...@@ -1704,8 +1695,8 @@ TEST_F(RenderFrameHostManagerTest, CommitNewNavigationBeforeSendingUnload) {
RenderFrameDeletedObserver rfh_deleted_observer(rfh1); RenderFrameDeletedObserver rfh_deleted_observer(rfh1);
EXPECT_TRUE(rfh1->is_active()); EXPECT_TRUE(rfh1->is_active());
// Increment the number of active frames in SiteInstanceImpl so that rfh1 is // Increment the number of active frames in rfh1's SiteInstance so that the
// not deleted on unload. // SiteInstance is not deleted on unload.
scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance(); scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance();
site_instance->IncrementActiveFrameCount(); site_instance->IncrementActiveFrameCount();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment