summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/zoom/zoom_controller_unittest.cc2
-rw-r--r--chrome/renderer/content_settings_observer.cc12
-rw-r--r--components/visitedlink/test/visitedlink_unittest.cc4
-rw-r--r--content/browser/frame_host/frame_tree.cc17
-rw-r--r--content/browser/frame_host/interstitial_page_impl.cc1
-rw-r--r--content/browser/frame_host/navigation_controller_impl_unittest.cc3
-rw-r--r--content/browser/frame_host/navigator_impl_unittest.cc7
-rw-r--r--content/browser/frame_host/render_frame_host_manager.cc113
-rw-r--r--content/browser/frame_host/render_frame_host_manager.h2
-rw-r--r--content/browser/frame_host/render_frame_host_manager_browsertest.cc6
-rw-r--r--content/browser/frame_host/render_frame_host_manager_unittest.cc218
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc15
-rw-r--r--content/browser/renderer_host/render_view_host_impl.h16
-rw-r--r--content/browser/site_per_process_browsertest.cc2
-rw-r--r--content/browser/web_contents/web_contents_impl.cc37
-rw-r--r--content/browser/web_contents/web_contents_impl.h1
-rw-r--r--content/browser/web_contents/web_contents_impl_unittest.cc21
-rw-r--r--content/public/test/test_renderer_host.h11
-rw-r--r--content/renderer/accessibility/renderer_accessibility_browsertest.cc9
-rw-r--r--content/renderer/history_entry.cc5
-rw-r--r--content/renderer/render_frame_impl.cc47
-rw-r--r--content/renderer/render_frame_proxy.cc19
-rw-r--r--content/renderer/render_view_browsertest.cc13
-rw-r--r--content/renderer/render_view_impl.cc71
-rw-r--r--content/test/test_render_frame_host.cc2
-rw-r--r--content/test/test_render_view_host.cc12
-rw-r--r--content/test/test_render_view_host.h8
-rw-r--r--content/test/test_web_contents.cc5
-rw-r--r--content/test/test_web_contents.h10
-rw-r--r--testing/buildbot/chromium.fyi.json4
-rw-r--r--ui/views/controls/webview/webview_interactive_uitest.cc8
31 files changed, 487 insertions, 214 deletions
diff --git a/chrome/browser/ui/zoom/zoom_controller_unittest.cc b/chrome/browser/ui/zoom/zoom_controller_unittest.cc
index 7614a8d..b6fc968 100644
--- a/chrome/browser/ui/zoom/zoom_controller_unittest.cc
+++ b/chrome/browser/ui/zoom/zoom_controller_unittest.cc
@@ -65,7 +65,7 @@ class ZoomControllerTest : public ChromeRenderViewHostTestHarness {
// This call is needed so that the RenderViewHost reports being alive. This
// is only important for tests that call ZoomController::SetZoomLevel().
- content::RenderViewHostTester::For(rvh())->CreateRenderView(
+ content::RenderViewHostTester::For(rvh())->CreateTestRenderView(
base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, -1, false);
}
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
index 3769a85..332e29a 100644
--- a/chrome/renderer/content_settings_observer.cc
+++ b/chrome/renderer/content_settings_observer.cc
@@ -170,11 +170,15 @@ ContentSettingsObserver::ContentSettingsObserver(
ClearBlockedContentSettings();
render_frame->GetWebFrame()->setContentSettingsClient(this);
- if (render_frame->GetRenderView()->GetMainRenderFrame() != render_frame) {
+ content::RenderFrame* main_frame =
+ render_frame->GetRenderView()->GetMainRenderFrame();
+ // TODO(nasko): The main frame is not guaranteed to be in the same process
+ // with this frame with --site-per-process. This code needs to be updated
+ // to handle this case. See https://crbug.com/496670.
+ if (main_frame && main_frame != render_frame) {
// Copy all the settings from the main render frame to avoid race conditions
- // when initializing this data. See http://crbug.com/333308.
- ContentSettingsObserver* parent = ContentSettingsObserver::Get(
- render_frame->GetRenderView()->GetMainRenderFrame());
+ // when initializing this data. See https://crbug.com/333308.
+ ContentSettingsObserver* parent = ContentSettingsObserver::Get(main_frame);
allow_displaying_insecure_content_ =
parent->allow_displaying_insecure_content_;
allow_running_insecure_content_ = parent->allow_running_insecure_content_;
diff --git a/components/visitedlink/test/visitedlink_unittest.cc b/components/visitedlink/test/visitedlink_unittest.cc
index 1b0454d..f663f83 100644
--- a/components/visitedlink/test/visitedlink_unittest.cc
+++ b/components/visitedlink/test/visitedlink_unittest.cc
@@ -680,7 +680,7 @@ TEST_F(VisitedLinkEventsTest, Coalescense) {
}
TEST_F(VisitedLinkEventsTest, Basics) {
- RenderViewHostTester::For(rvh())->CreateRenderView(
+ RenderViewHostTester::For(rvh())->CreateTestRenderView(
base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, -1, false);
// Add a few URLs.
@@ -704,7 +704,7 @@ TEST_F(VisitedLinkEventsTest, Basics) {
}
TEST_F(VisitedLinkEventsTest, TabVisibility) {
- RenderViewHostTester::For(rvh())->CreateRenderView(
+ RenderViewHostTester::For(rvh())->CreateTestRenderView(
base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, -1, false);
// Simulate tab becoming inactive.
diff --git a/content/browser/frame_host/frame_tree.cc b/content/browser/frame_host/frame_tree.cc
index e463c3c..814980e 100644
--- a/content/browser/frame_host/frame_tree.cc
+++ b/content/browser/frame_host/frame_tree.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/command_line.h"
#include "base/containers/hash_tables.h"
#include "base/lazy_instance.h"
#include "content/browser/frame_host/frame_tree_node.h"
@@ -17,6 +18,7 @@
#include "content/browser/frame_host/render_frame_proxy_host.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/public/common/content_switches.h"
#include "third_party/WebKit/public/web/WebSandboxFlags.h"
namespace content {
@@ -226,9 +228,14 @@ void FrameTree::CreateProxiesForSiteInstance(
RenderViewHostImpl* render_view_host =
source->frame_tree()->GetRenderViewHost(site_instance);
if (!render_view_host) {
- root()->render_manager()->CreateRenderFrame(
- site_instance, nullptr, MSG_ROUTING_NONE,
- CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ root()->render_manager()->CreateRenderFrameProxy(site_instance);
+ } else {
+ root()->render_manager()->CreateRenderFrame(
+ site_instance, nullptr, MSG_ROUTING_NONE,
+ CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr);
+ }
} else {
root()->render_manager()->EnsureRenderViewInitialized(
source, render_view_host, site_instance);
@@ -265,7 +272,6 @@ RenderViewHostImpl* FrameTree::CreateRenderViewHost(SiteInstance* site_instance,
int main_frame_routing_id,
bool swapped_out,
bool hidden) {
- DCHECK(main_frame_routing_id != MSG_ROUTING_NONE);
RenderViewHostMap::iterator iter =
render_view_host_map_.find(site_instance->GetId());
if (iter != render_view_host_map_.end()) {
@@ -274,7 +280,8 @@ RenderViewHostImpl* FrameTree::CreateRenderViewHost(SiteInstance* site_instance,
// Otherwise return the existing RenderViewHost for the SiteInstance.
RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>(
iter->second->GetMainFrame());
- if (main_frame->frame_tree_node()->render_manager()->IsPendingDeletion(
+ if (main_frame &&
+ main_frame->frame_tree_node()->render_manager()->IsPendingDeletion(
main_frame)) {
render_view_host_pending_shutdown_map_.insert(
std::pair<int, RenderViewHostImpl*>(site_instance->GetId(),
diff --git a/content/browser/frame_host/interstitial_page_impl.cc b/content/browser/frame_host/interstitial_page_impl.cc
index 455ac74..6e32401 100644
--- a/content/browser/frame_host/interstitial_page_impl.cc
+++ b/content/browser/frame_host/interstitial_page_impl.cc
@@ -565,6 +565,7 @@ WebContentsView* InterstitialPageImpl::CreateWebContentsView() {
MSG_ROUTING_NONE,
MSG_ROUTING_NONE,
max_page_id,
+ FrameReplicationState(),
false);
controller_->delegate()->RenderFrameForInterstitialPageCreated(
frame_tree_.root()->current_frame_host());
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index 4e0eae1..f813393 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -1201,7 +1201,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// Going back, the first entry should still appear unprivileged.
controller.GoBack();
new_rfh->PrepareForCommit();
- orig_rfh->SendNavigate(0, entry1_id, false, url1);
+ contents()->GetPendingMainFrame()->SendNavigate(0, entry1_id, false, url1);
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings());
}
@@ -2857,6 +2857,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
fail_load_params.error_description = base::string16();
fail_load_params.url = url;
fail_load_params.showing_repost_interstitial = false;
+ main_test_rfh()->InitializeRenderFrameIfNeeded();
main_test_rfh()->OnMessageReceived(
FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
fail_load_params));
diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc
index c72708b..8f1886f 100644
--- a/content/browser/frame_host/navigator_impl_unittest.cc
+++ b/content/browser/frame_host/navigator_impl_unittest.cc
@@ -931,6 +931,13 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// using the same SiteInstance.
TEST_F(NavigatorTestWithBrowserSideNavigation,
SpeculativeRendererReuseSwappedOutRFH) {
+ // This test doesn't make sense in --site-per-process where swapped out
+ // RenderFrameHost is no longer used.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
+
// Navigate to an initial site.
const GURL kUrl1("http://wikipedia.org/");
contents()->NavigateAndCommit(kUrl1);
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc
index 7c0cf40..952b0b0 100644
--- a/content/browser/frame_host/render_frame_host_manager.cc
+++ b/content/browser/frame_host/render_frame_host_manager.cc
@@ -204,7 +204,8 @@ RenderFrameHostImpl* RenderFrameHostManager::Navigate(
// soon anyway, and we don't have the NavigationEntry for this host.
delegate_->CreateRenderViewForRenderManager(
render_frame_host_->render_view_host(), MSG_ROUTING_NONE,
- MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame());
+ MSG_ROUTING_NONE, frame_tree_node_->current_replication_state(),
+ frame_tree_node_->IsMainFrame());
}
// If the renderer crashed, then try to create a new one to satisfy this
@@ -609,18 +610,16 @@ void RenderFrameHostManager::SwapOutOldFrame(
// SwapOut creates a RenderFrameProxy, so set the proxy to be initialized.
proxy->set_render_frame_proxy_created(true);
- bool is_main_frame = frame_tree_node_->IsMainFrame();
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSitePerProcess) &&
- !is_main_frame) {
- // In --site-per-process, subframes delete their RFH rather than storing it
+ switches::kSitePerProcess)) {
+ // In --site-per-process, frames delete their RFH rather than storing it
// in the proxy. Schedule it for deletion once the SwapOutACK comes in.
// TODO(creis): This will be the default when we remove swappedout://.
MoveToPendingDeleteHosts(old_render_frame_host.Pass());
} else {
// We shouldn't get here for subframes, since we only swap subframes when
// --site-per-process is used.
- DCHECK(is_main_frame);
+ DCHECK(frame_tree_node_->IsMainFrame());
// The old RenderFrameHost will stay alive inside the proxy so that existing
// JavaScript window references to it stay valid.
@@ -635,6 +634,8 @@ void RenderFrameHostManager::DiscardUnusedFrame(
// If the SiteInstance for the pending RFH is being used by others don't
// delete the RFH. Just swap it out and it can be reused at a later point.
+ // In --site-per-process, RenderFrameHosts are not kept around and are
+ // deleted when not used, replaced by RenderFrameProxyHosts.
SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance();
if (site_instance->HasSite() && site_instance->active_frame_count() > 1) {
// Any currently suspended navigations are no longer needed.
@@ -650,9 +651,14 @@ void RenderFrameHostManager::DiscardUnusedFrame(
if (!render_frame_host->is_swapped_out())
render_frame_host->SwapOut(proxy, false);
- if (frame_tree_node_->IsMainFrame())
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ DCHECK(frame_tree_node_->IsMainFrame());
proxy->TakeFrameHostOwnership(render_frame_host.Pass());
- } else {
+ }
+ }
+
+ if (render_frame_host) {
// We won't be coming back, so delete this one.
ShutdownProxiesIfLastActiveFrameInSiteInstance(render_frame_host.get());
render_frame_host.reset();
@@ -920,7 +926,9 @@ bool RenderFrameHostManager::ClearProxiesInSiteInstance(
if (node->IsMainFrame() &&
proxy->render_frame_host() &&
proxy->render_frame_host()->rfh_state() ==
- RenderFrameHostImpl::STATE_PENDING_SWAP_OUT) {
+ RenderFrameHostImpl::STATE_PENDING_SWAP_OUT) {
+ DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess));
scoped_ptr<RenderFrameHostImpl> swapped_out_rfh =
proxy->PassFrameHostOwnership();
node->render_manager()->MoveToPendingDeleteHosts(swapped_out_rfh.Pass());
@@ -1458,14 +1466,15 @@ scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame(
int flags,
int* view_routing_id_ptr) {
bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT);
+ bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess);
+
CHECK(instance);
- // Swapped out views should always be hidden.
- DCHECK(!swapped_out || (flags & CREATE_RF_HIDDEN));
+ CHECK_IMPLIES(is_site_per_process, !swapped_out);
+ CHECK_IMPLIES(!is_site_per_process, frame_tree_node_->IsMainFrame());
- // TODO(nasko): Remove the following CHECK once cross-process navigation no
- // longer relies on swapped out RFH for the top-level frame.
- if (!frame_tree_node_->IsMainFrame())
- CHECK(!swapped_out);
+ // Swapped out views should always be hidden.
+ DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN));
scoped_ptr<RenderFrameHostImpl> new_render_frame_host;
bool success = true;
@@ -1481,6 +1490,7 @@ scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame(
// remove it from the list of proxy hosts below if it will be active.
RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
if (proxy && proxy->render_frame_host()) {
+ CHECK(!is_site_per_process);
if (view_routing_id_ptr)
*view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID();
// Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost.
@@ -1527,7 +1537,13 @@ scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame(
// will be created later and hidden.
if (render_view_host->GetView())
render_view_host->GetView()->Hide();
- } else if (!swapped_out) {
+ }
+ // With --site-per-process, RenderViewHost for |instance| might exist
+ // prior to calling CreateRenderFrame, due to a subframe in
+ // |instance|. In such a case, InitRenderView will not create the
+ // RenderFrame in the renderer process and it needs to be done
+ // explicitly.
+ if (is_site_per_process) {
// Init the RFH, so a RenderFrame is created in the renderer.
DCHECK(new_render_frame_host);
success = InitRenderFrame(new_render_frame_host.get());
@@ -1569,17 +1585,40 @@ int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) {
CHECK(instance);
CHECK_NE(instance, render_frame_host_->GetSiteInstance());
+ bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess);
+ RenderViewHostImpl* render_view_host = nullptr;
+
+ // Ensure a RenderViewHost exists for |instance|, as it creates the page
+ // level structure in Blink.
+ if (is_site_per_process) {
+ render_view_host =
+ frame_tree_node_->frame_tree()->GetRenderViewHost(instance);
+ if (!render_view_host) {
+ CHECK(frame_tree_node_->IsMainFrame());
+ render_view_host = frame_tree_node_->frame_tree()->CreateRenderViewHost(
+ instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, true, true);
+ }
+ }
+
RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
if (proxy && proxy->is_render_frame_proxy_live())
return proxy->GetRoutingID();
if (!proxy) {
proxy = new RenderFrameProxyHost(
- instance, frame_tree_node_->frame_tree()->GetRenderViewHost(instance),
- frame_tree_node_);
+ instance, render_view_host, frame_tree_node_);
proxy_hosts_[instance->GetId()] = proxy;
}
- proxy->InitRenderFrameProxy();
+
+ if (is_site_per_process && frame_tree_node_->IsMainFrame()) {
+ InitRenderView(
+ render_view_host, MSG_ROUTING_NONE, proxy->GetRoutingID(), true);
+ proxy->set_render_frame_proxy_created(true);
+ } else {
+ proxy->InitRenderFrameProxy();
+ }
+
return proxy->GetRoutingID();
}
@@ -1613,15 +1652,15 @@ bool RenderFrameHostManager::InitRenderView(
int opener_route_id,
int proxy_routing_id,
bool for_main_frame_navigation) {
- // We may have initialized this RenderViewHost for another RenderFrameHost.
- if (render_view_host->IsRenderViewLive())
- return true;
-
// Ensure the renderer process is initialized before creating the
// RenderView.
if (!render_view_host->GetProcess()->Init())
return false;
+ // We may have initialized this RenderViewHost for another RenderFrameHost.
+ if (render_view_host->IsRenderViewLive())
+ return true;
+
// If the ongoing navigation is to a WebUI and the RenderView is not in a
// guest process, tell the RenderViewHost about any bindings it will need
// enabled.
@@ -1644,10 +1683,12 @@ bool RenderFrameHostManager::InitRenderView(
}
}
- return delegate_->CreateRenderViewForRenderManager(render_view_host,
- opener_route_id,
- proxy_routing_id,
- for_main_frame_navigation);
+ return delegate_->CreateRenderViewForRenderManager(
+ render_view_host,
+ opener_route_id,
+ proxy_routing_id,
+ frame_tree_node_->current_replication_state(),
+ for_main_frame_navigation);
}
bool RenderFrameHostManager::InitRenderFrame(
@@ -1717,6 +1758,9 @@ void RenderFrameHostManager::CommitPending() {
bool browser_side_navigation =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation);
+ bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess);
+
// First check whether we're going to want to focus the location bar after
// this commit. We do this now because the navigation hasn't formally
// committed yet, so if we've already cleared |pending_web_ui_| the call chain
@@ -1818,6 +1862,17 @@ void RenderFrameHostManager::CommitPending() {
delegate_->NotifySwappedFromRenderManager(
old_render_frame_host.get(), render_frame_host_.get(), is_main_frame);
+ // The RenderViewHost keeps track of the main RenderFrameHost routing id.
+ // If this is committing a main frame navigation, update it and set the
+ // routing id in the RenderViewHost associated with the old RenderFrameHost
+ // to MSG_ROUTING_NONE.
+ if (is_main_frame && is_site_per_process) {
+ render_frame_host_->render_view_host()->set_main_frame_routing_id(
+ render_frame_host_->routing_id());
+ old_render_frame_host->render_view_host()->set_main_frame_routing_id(
+ MSG_ROUTING_NONE);
+ }
+
// Swap out the old frame now that the new one is visible.
// This will swap it out and then put it on the proxy list (if there are other
// active views in its SiteInstance) or schedule it for deletion when the swap
@@ -1826,9 +1881,7 @@ void RenderFrameHostManager::CommitPending() {
// the proxy.
SwapOutOldFrame(old_render_frame_host.Pass());
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSitePerProcess) &&
- !is_main_frame) {
+ if (is_site_per_process) {
// Since the new RenderFrameHost is now committed, there must be no proxies
// for its SiteInstance. Delete any existing ones.
RenderFrameProxyHostMap::iterator iter =
diff --git a/content/browser/frame_host/render_frame_host_manager.h b/content/browser/frame_host/render_frame_host_manager.h
index cc7dd6c..9b28575 100644
--- a/content/browser/frame_host/render_frame_host_manager.h
+++ b/content/browser/frame_host/render_frame_host_manager.h
@@ -44,6 +44,7 @@ class RenderWidgetHostView;
class TestWebContents;
class WebUIImpl;
struct CommonNavigationParams;
+struct FrameReplicationState;
// Manages RenderFrameHosts for a FrameTreeNode. It maintains a
// current_frame_host() which is the content currently visible to the user. When
@@ -121,6 +122,7 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
+ const FrameReplicationState& replicated_frame_state,
bool for_main_frame_navigation) = 0;
virtual bool CreateRenderFrameForRenderManager(
RenderFrameHost* render_frame_host,
diff --git a/content/browser/frame_host/render_frame_host_manager_browsertest.cc b/content/browser/frame_host/render_frame_host_manager_browsertest.cc
index aec9dac..9567394 100644
--- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc
@@ -1160,6 +1160,12 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, MAYBE_BackForwardNotStale) {
// Swapping out a render view should update its visiblity state.
IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
SwappedOutViewHasCorrectVisibilityState) {
+ // This test is invalid in --site-per-process mode, as swapped-out is no
+ // longer used.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
StartServer();
// Load a page with links that open in a new window.
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 c03a0bb..6bf1476 100644
--- a/content/browser/frame_host/render_frame_host_manager_unittest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc
@@ -330,7 +330,9 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
if (old_rfh != active_rfh && !rfh_observer.deleted()) {
EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT,
old_rfh->rfh_state());
- if (!old_rfh->GetSiteInstance()->active_frame_count()) {
+ if (!old_rfh->GetSiteInstance()->active_frame_count() ||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
expecting_rfh_shutdown = true;
EXPECT_TRUE(
old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion(
@@ -344,7 +346,10 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
old_rfh->OnSwappedOut();
if (expecting_rfh_shutdown) {
EXPECT_TRUE(rfh_observer.deleted());
- EXPECT_TRUE(rvh_observer.deleted());
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ EXPECT_TRUE(rvh_observer.deleted());
+ }
} else {
EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT,
old_rfh->rfh_state());
@@ -527,6 +532,7 @@ TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) {
// Navigate our first tab to a chrome url and then to the destination.
NavigateActiveAndCommit(kChromeURL);
TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame();
+ TestRenderViewHost* ntp_rvh = ntp_rfh->GetRenderViewHost();
// Send an update favicon message and make sure it works.
{
@@ -559,16 +565,22 @@ TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) {
// The old renderer, being slow, now updates the favicon. It should be
// filtered out and not take effect.
- EXPECT_TRUE(ntp_rfh->is_swapped_out());
{
PluginFaviconMessageObserver observer(contents());
EXPECT_TRUE(
- ntp_rfh->GetRenderViewHost()->OnMessageReceived(
+ ntp_rvh->OnMessageReceived(
ViewHostMsg_UpdateFaviconURL(
dest_rfh->GetRenderViewHost()->GetRoutingID(), icons)));
EXPECT_FALSE(observer.favicon_received());
}
+ // In --site-per-process, the RenderFrameHost is deleted on cross-process
+ // navigation, so the rest of the test case doesn't apply.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
+
#if defined(ENABLE_PLUGINS)
// The same logic should apply to RenderFrameHosts as well and routing through
// swapped out RFH shouldn't be allowed. Use a PluginCrashObserver to check
@@ -673,6 +685,13 @@ TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) {
const GURL kUrl1("http://foo.com");
const GURL kUrl2("http://www.google.com/");
+ // This test is invalid in --site-per-process mode, as swapped-out is no
+ // longer used.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
+
// Navigate to the first site.
NavigateActiveAndCommit(kUrl1);
TestRenderFrameHost* initial_rfh = contents()->GetMainFrame();
@@ -711,6 +730,12 @@ TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) {
}
TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) {
+ // TODO(nasko): Check with kenrb whether this test can be rewritten and
+ // whether it makes sense when swapped out is replaced with proxies.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost();
TestRenderWidgetHostView* swapped_out_rwhv =
static_cast<TestRenderWidgetHostView*>(
@@ -731,6 +756,13 @@ TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) {
// Test if RenderViewHost::GetRenderWidgetHosts() only returns active
// widgets.
TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) {
+ // This test is invalid in --site-per-process mode, as swapped-out is no
+ // longer used.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
+
TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost();
EXPECT_TRUE(swapped_out_rfh->is_swapped_out());
@@ -752,6 +784,13 @@ TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) {
// including swapped out ones.
TEST_F(RenderFrameHostManagerTest,
GetRenderWidgetHostsWithinGetAllRenderWidgetHosts) {
+ // This test is invalid in --site-per-process mode, as swapped-out is no
+ // longer used.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
+
TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost();
EXPECT_TRUE(swapped_out_rfh->is_swapped_out());
@@ -1109,7 +1148,8 @@ TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) {
web_contents1->GetRenderManagerForTesting();
// Test the case that new RVH is considered live.
manager1->current_host()->CreateRenderView(
- base::string16(), -1, MSG_ROUTING_NONE, -1, false);
+ base::string16(), -1, MSG_ROUTING_NONE, -1,
+ FrameReplicationState(), false);
EXPECT_TRUE(manager1->current_host()->IsRenderViewLive());
EXPECT_TRUE(manager1->current_frame_host()->IsRenderFrameLive());
@@ -1143,7 +1183,8 @@ TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) {
// Make sure the new RVH is considered live. This is usually done in
// RenderWidgetHost::Init when opening a new tab from a link.
manager2->current_host()->CreateRenderView(
- base::string16(), -1, MSG_ROUTING_NONE, -1, false);
+ base::string16(), -1, MSG_ROUTING_NONE, -1,
+ FrameReplicationState(), false);
EXPECT_TRUE(manager2->current_host()->IsRenderViewLive());
const GURL kUrl2("chrome://foo/bar");
@@ -1313,8 +1354,8 @@ TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) {
// The back navigation commits.
const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
- rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false,
- entry1->GetURL());
+ contents()->GetPendingMainFrame()->SendNavigate(
+ entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL());
EXPECT_TRUE(rfh2->IsWaitingForUnloadACK());
EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh2->rfh_state());
@@ -1322,14 +1363,17 @@ TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) {
contents()->GetController().GoForward();
contents()->GetMainFrame()->PrepareForCommit();
const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry();
- rfh2->SendNavigate(entry2->GetPageID(), entry2->GetUniqueID(), false,
- entry2->GetURL());
- EXPECT_EQ(rfh2, main_test_rfh());
- EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state());
- EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state());
- rfh1->OnSwappedOut();
- EXPECT_TRUE(rfh1->is_swapped_out());
- EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, rfh1->rfh_state());
+ contents()->GetPendingMainFrame()->SendNavigate(
+ entry2->GetPageID(), entry2->GetUniqueID(), false, entry2->GetURL());
+ EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state());
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ EXPECT_EQ(rfh2, main_test_rfh());
+ EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state());
+ rfh1->OnSwappedOut();
+ EXPECT_TRUE(rfh1->is_swapped_out());
+ EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, rfh1->rfh_state());
+ }
}
// Test that we create swapped out RFHs for the opener chain when navigating an
@@ -1339,23 +1383,27 @@ TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) {
const GURL kUrl1("http://www.google.com/");
const GURL kUrl2("http://www.chromium.org/");
const GURL kChromeUrl("chrome://foo");
+ bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess);
// Navigate to an initial URL.
contents()->NavigateAndCommit(kUrl1);
RenderFrameHostManager* manager = contents()->GetRenderManagerForTesting();
TestRenderFrameHost* rfh1 = main_test_rfh();
+ scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance();
+ RenderFrameHostDeletedObserver rfh1_deleted_observer(rfh1);
TestRenderViewHost* rvh1 = test_rvh();
// Create 2 new tabs and simulate them being the opener chain for the main
// tab. They should be in the same SiteInstance.
scoped_ptr<TestWebContents> opener1(
- TestWebContents::Create(browser_context(), rfh1->GetSiteInstance()));
+ TestWebContents::Create(browser_context(), site_instance1.get()));
RenderFrameHostManager* opener1_manager =
opener1->GetRenderManagerForTesting();
contents()->SetOpener(opener1.get());
scoped_ptr<TestWebContents> opener2(
- TestWebContents::Create(browser_context(), rfh1->GetSiteInstance()));
+ TestWebContents::Create(browser_context(), site_instance1.get()));
RenderFrameHostManager* opener2_manager =
opener2->GetRenderManagerForTesting();
opener1->SetOpener(opener2.get());
@@ -1365,16 +1413,21 @@ TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) {
contents()->NavigateAndCommit(kUrl2);
TestRenderFrameHost* rfh2 = main_test_rfh();
TestRenderViewHost* rvh2 = test_rvh();
- EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance());
- EXPECT_TRUE(rfh1->GetSiteInstance()->IsRelatedSiteInstance(
- rfh2->GetSiteInstance()));
+ EXPECT_NE(site_instance1, rfh2->GetSiteInstance());
+ EXPECT_TRUE(site_instance1->IsRelatedSiteInstance(rfh2->GetSiteInstance()));
// Ensure rvh1 is placed on swapped out list of the current tab.
- EXPECT_TRUE(manager->IsOnSwappedOutList(rfh1));
- EXPECT_TRUE(manager->IsRVHOnSwappedOutList(rvh1));
- EXPECT_EQ(rfh1,
- manager->GetRenderFrameProxyHost(rfh1->GetSiteInstance())
- ->render_frame_host());
+ if (!is_site_per_process) {
+ EXPECT_TRUE(manager->IsRVHOnSwappedOutList(rvh1));
+ EXPECT_FALSE(rfh1_deleted_observer.deleted());
+ EXPECT_TRUE(manager->IsOnSwappedOutList(rfh1));
+ EXPECT_EQ(rfh1,
+ manager->GetRenderFrameProxyHost(site_instance1.get())
+ ->render_frame_host());
+ } else {
+ EXPECT_TRUE(rfh1_deleted_observer.deleted());
+ EXPECT_TRUE(manager->GetRenderFrameProxyHost(site_instance1.get()));
+ }
EXPECT_EQ(rvh1,
manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance()));
@@ -1384,9 +1437,13 @@ TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) {
RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host();
TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>(
opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance()));
- EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh));
- EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh));
- EXPECT_TRUE(opener1_rfh->is_swapped_out());
+ if (!is_site_per_process) {
+ EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh));
+ EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh));
+ EXPECT_TRUE(opener1_rfh->is_swapped_out());
+ } else {
+ EXPECT_FALSE(opener1_rfh);
+ }
EXPECT_FALSE(opener1_rvh->is_active());
// Ensure a swapped out RFH and RVH is created in the second opener tab.
@@ -1395,17 +1452,20 @@ TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) {
RenderFrameHostImpl* opener2_rfh = opener2_proxy->render_frame_host();
TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>(
opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance()));
- EXPECT_TRUE(opener2_manager->IsOnSwappedOutList(opener2_rfh));
- EXPECT_TRUE(opener2_manager->IsRVHOnSwappedOutList(opener2_rvh));
- EXPECT_TRUE(opener2_rfh->is_swapped_out());
+ if (!is_site_per_process) {
+ EXPECT_TRUE(opener2_manager->IsOnSwappedOutList(opener2_rfh));
+ EXPECT_TRUE(opener2_manager->IsRVHOnSwappedOutList(opener2_rvh));
+ EXPECT_TRUE(opener2_rfh->is_swapped_out());
+ } else {
+ EXPECT_FALSE(opener2_rfh);
+ }
EXPECT_FALSE(opener2_rvh->is_active());
// Navigate to a cross-BrowsingInstance URL.
contents()->NavigateAndCommit(kChromeUrl);
TestRenderFrameHost* rfh3 = main_test_rfh();
- EXPECT_NE(rfh1->GetSiteInstance(), rfh3->GetSiteInstance());
- EXPECT_FALSE(rfh1->GetSiteInstance()->IsRelatedSiteInstance(
- rfh3->GetSiteInstance()));
+ EXPECT_NE(site_instance1, rfh3->GetSiteInstance());
+ EXPECT_FALSE(site_instance1->IsRelatedSiteInstance(rfh3->GetSiteInstance()));
// No scripting is allowed across BrowsingInstances, so we should not create
// swapped out RVHs for the opener chain in this case.
@@ -1427,6 +1487,7 @@ TEST_F(RenderFrameHostManagerTest, DisownOpener) {
// Navigate to an initial URL.
contents()->NavigateAndCommit(kUrl1);
TestRenderFrameHost* rfh1 = main_test_rfh();
+ scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance();
// Create a new tab and simulate having it be the opener for the main tab.
scoped_ptr<TestWebContents> opener1(
@@ -1438,7 +1499,7 @@ TEST_F(RenderFrameHostManagerTest, DisownOpener) {
// BrowsingInstance).
contents()->NavigateAndCommit(kUrl2);
TestRenderFrameHost* rfh2 = main_test_rfh();
- EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance());
+ EXPECT_NE(site_instance1, rfh2->GetSiteInstance());
// Disown the opener from rfh2.
rfh2->DidDisownOpener();
@@ -1476,11 +1537,12 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerDuringNavigation) {
// Navigate to an initial URL.
contents()->NavigateAndCommit(kUrl1);
- TestRenderFrameHost* rfh1 = main_test_rfh();
+ scoped_refptr<SiteInstanceImpl> site_instance1 =
+ main_test_rfh()->GetSiteInstance();
// Create a new tab and simulate having it be the opener for the main tab.
scoped_ptr<TestWebContents> opener1(
- TestWebContents::Create(browser_context(), rfh1->GetSiteInstance()));
+ TestWebContents::Create(browser_context(), site_instance1.get()));
contents()->SetOpener(opener1.get());
EXPECT_TRUE(contents()->HasOpener());
@@ -1488,9 +1550,9 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerDuringNavigation) {
// BrowsingInstance).
contents()->NavigateAndCommit(kUrl2);
TestRenderFrameHost* rfh2 = main_test_rfh();
- EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance());
+ EXPECT_NE(site_instance1, rfh2->GetSiteInstance());
- // Start a back navigation so that rfh1 becomes the pending RFH.
+ // Start a back navigation.
contents()->GetController().GoBack();
contents()->GetMainFrame()->PrepareForCommit();
@@ -1502,8 +1564,8 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerDuringNavigation) {
// The back navigation commits.
const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
- rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false,
- entry1->GetURL());
+ contents()->GetPendingMainFrame()->SendNavigate(
+ entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL());
// Ensure the opener is still cleared.
EXPECT_FALSE(contents()->HasOpener());
@@ -1517,11 +1579,12 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) {
// Navigate to an initial URL.
contents()->NavigateAndCommit(kUrl1);
- TestRenderFrameHost* rfh1 = main_test_rfh();
+ scoped_refptr<SiteInstanceImpl> site_instance1 =
+ main_test_rfh()->GetSiteInstance();
// Create a new tab and simulate having it be the opener for the main tab.
scoped_ptr<TestWebContents> opener1(
- TestWebContents::Create(browser_context(), rfh1->GetSiteInstance()));
+ TestWebContents::Create(browser_context(), site_instance1.get()));
contents()->SetOpener(opener1.get());
EXPECT_TRUE(contents()->HasOpener());
@@ -1529,15 +1592,14 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) {
// BrowsingInstance).
contents()->NavigateAndCommit(kUrl2);
TestRenderFrameHost* rfh2 = main_test_rfh();
- EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance());
+ EXPECT_NE(site_instance1, rfh2->GetSiteInstance());
// Commit a back navigation before the DidDisownOpener message arrives.
- // rfh1 will be kept alive because of the opener tab.
contents()->GetController().GoBack();
contents()->GetMainFrame()->PrepareForCommit();
const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
- rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false,
- entry1->GetURL());
+ contents()->GetPendingMainFrame()->SendNavigate(
+ entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL());
// Disown the opener from rfh2.
rfh2->DidDisownOpener();
@@ -1563,7 +1625,8 @@ TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) {
// Make sure the new opener RVH is considered live.
opener1_manager->current_host()->CreateRenderView(
- base::string16(), -1, MSG_ROUTING_NONE, -1, false);
+ base::string16(), -1, MSG_ROUTING_NONE, -1,
+ FrameReplicationState(), false);
EXPECT_TRUE(opener1_manager->current_host()->IsRenderViewLive());
EXPECT_TRUE(opener1_manager->current_frame_host()->IsRenderFrameLive());
@@ -1634,9 +1697,14 @@ TEST_F(RenderFrameHostManagerTest, EnableWebUIWithSwappedOutOpener) {
RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host();
TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>(
opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance()));
- EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh));
- EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh));
- EXPECT_TRUE(opener1_rfh->is_swapped_out());
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh));
+ EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh));
+ EXPECT_TRUE(opener1_rfh->is_swapped_out());
+ } else {
+ EXPECT_FALSE(opener1_rfh);
+ }
EXPECT_FALSE(opener1_rvh->is_active());
// Ensure the new RVH has WebUI bindings.
@@ -1874,9 +1942,14 @@ TEST_F(RenderFrameHostManagerTest, SwapOutFrameAfterSwapOutACK) {
// Simulate the swap out ack.
rfh1->OnSwappedOut();
- // rfh1 should be swapped out.
- EXPECT_FALSE(rfh_deleted_observer.deleted());
- EXPECT_TRUE(rfh1->is_swapped_out());
+ // rfh1 should be swapped out or deleted in --site-per-process.
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ EXPECT_FALSE(rfh_deleted_observer.deleted());
+ EXPECT_TRUE(rfh1->is_swapped_out());
+ } else {
+ EXPECT_TRUE(rfh_deleted_observer.deleted());
+ }
}
// Test that the RenderViewHost is properly swapped out if a navigation in the
@@ -1896,7 +1969,8 @@ TEST_F(RenderFrameHostManagerTest,
// Increment the number of active frames in SiteInstanceImpl so that rfh1 is
// not deleted on swap out.
- rfh1->GetSiteInstance()->increment_active_frame_count();
+ scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance();
+ site_instance->increment_active_frame_count();
// Navigate to new site, simulating onbeforeunload approval.
controller().LoadURL(
@@ -1919,12 +1993,19 @@ TEST_F(RenderFrameHostManagerTest,
rfh1->OnSwappedOut();
// rfh1 should be swapped out.
- EXPECT_FALSE(rfh_deleted_observer.deleted());
- EXPECT_TRUE(rfh1->is_swapped_out());
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ EXPECT_TRUE(rfh_deleted_observer.deleted());
+ EXPECT_TRUE(contents()->GetFrameTree()->root()->render_manager()
+ ->GetRenderFrameProxyHost(site_instance.get()));
+ } else {
+ EXPECT_FALSE(rfh_deleted_observer.deleted());
+ EXPECT_TRUE(rfh1->is_swapped_out());
+ }
}
-// Test that a RenderFrameHost is properly deleted or swapped out when a
-// cross-site navigation is cancelled.
+// Test that a RenderFrameHost is properly deleted when a cross-site navigation
+// is cancelled.
TEST_F(RenderFrameHostManagerTest,
CancelPendingProperlyDeletesOrSwaps) {
const GURL kUrl1("http://www.google.com/");
@@ -1964,13 +2045,24 @@ TEST_F(RenderFrameHostManagerTest,
RenderFrameHostDeletedObserver rfh_deleted_observer(pending_rfh);
// Increment the number of active frames in the new SiteInstance, which will
- // cause the pending RFH to be swapped out instead of deleted.
- pending_rfh->GetSiteInstance()->increment_active_frame_count();
+ // cause the pending RFH to be deleted and a RenderFrameProxyHost to be
+ // created.
+ scoped_refptr<SiteInstanceImpl> site_instance =
+ pending_rfh->GetSiteInstance();
+ site_instance->increment_active_frame_count();
contents()->GetMainFrame()->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
EXPECT_FALSE(contents()->CrossProcessNavigationPending());
- EXPECT_FALSE(rfh_deleted_observer.deleted());
+
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ EXPECT_TRUE(rfh_deleted_observer.deleted());
+ EXPECT_TRUE(contents()->GetFrameTree()->root()->render_manager()
+ ->GetRenderFrameProxyHost(site_instance.get()));
+ } else {
+ EXPECT_FALSE(rfh_deleted_observer.deleted());
+ }
}
}
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 4e81849..3495a15 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -278,6 +278,7 @@ bool RenderViewHostImpl::CreateRenderView(
int opener_route_id,
int proxy_route_id,
int32 max_page_id,
+ const FrameReplicationState& replicated_frame_state,
bool window_was_created_with_opener) {
TRACE_EVENT0("renderer_host,navigation",
"RenderViewHostImpl::CreateRenderView");
@@ -319,6 +320,7 @@ bool RenderViewHostImpl::CreateRenderView(
// Ensure the RenderView sets its opener correctly.
params.opener_route_id = opener_route_id;
params.swapped_out = !is_active_;
+ params.replicated_frame_state = replicated_frame_state;
params.proxy_routing_id = proxy_route_id;
params.hidden = is_hidden();
params.never_visible = delegate_->IsNeverVisible();
@@ -328,11 +330,6 @@ bool RenderViewHostImpl::CreateRenderView(
params.min_size = min_size_for_auto_resize();
params.max_size = max_size_for_auto_resize();
GetResizeParams(&params.initial_size);
- if (!is_active_) {
- params.replicated_frame_state =
- static_cast<RenderFrameHostImpl*>(GetMainFrame())->frame_tree_node()
- ->current_replication_state();
- }
if (!Send(new ViewMsg_New(params)))
return false;
@@ -353,10 +350,12 @@ bool RenderViewHostImpl::CreateRenderView(
// Let our delegate know that we created a RenderView.
delegate_->RenderViewCreated(this);
- // Since this method creates the main RenderFrame in the renderer process,
+ // Since this method can create the main RenderFrame in the renderer process,
// set the proper state on its corresponding RenderFrameHost.
- RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_)
- ->SetRenderFrameCreated(true);
+ if (main_frame_routing_id_ != MSG_ROUTING_NONE) {
+ RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_)
+ ->SetRenderFrameCreated(true);
+ }
return true;
}
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
index f780ddd..2ecc27a 100644
--- a/content/browser/renderer_host/render_view_host_impl.h
+++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -57,6 +57,7 @@ class SessionStorageNamespaceImpl;
class TestRenderViewHost;
struct FileChooserFileInfo;
struct FileChooserParams;
+struct FrameReplicationState;
#if defined(COMPILER_MSVC)
// RenderViewHostImpl is the bottom of a diamond-shaped hierarchy,
@@ -202,11 +203,13 @@ class CONTENT_EXPORT RenderViewHostImpl
// created with an opener. (The opener may have been closed since.)
// The |proxy_route_id| is only used when creating a RenderView in swapped out
// state.
- virtual bool CreateRenderView(const base::string16& frame_name,
- int opener_route_id,
- int proxy_route_id,
- int32 max_page_id,
- bool window_was_created_with_opener);
+ virtual bool CreateRenderView(
+ const base::string16& frame_name,
+ int opener_route_id,
+ int proxy_route_id,
+ int32 max_page_id,
+ const FrameReplicationState& replicated_frame_state,
+ bool window_was_created_with_opener);
base::TerminationStatus render_view_termination_status() const {
return render_view_termination_status_;
@@ -300,6 +303,9 @@ class CONTENT_EXPORT RenderViewHostImpl
int main_frame_routing_id() const {
return main_frame_routing_id_;
}
+ void set_main_frame_routing_id(int routing_id) {
+ main_frame_routing_id_ = routing_id;
+ }
void OnTextSurroundingSelectionResponse(const base::string16& content,
size_t start_offset,
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 282141a..b7595bc5 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -1007,8 +1007,6 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
FrameTreeNode* root =
static_cast<WebContentsImpl*>(shell()->web_contents())->
GetFrameTree()->root();
- TestNavigationObserver observer(shell()->web_contents());
-
ASSERT_EQ(2U, root->child_count());
GURL site_b_url(
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 4ab69e9..51695bc 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3962,11 +3962,16 @@ bool WebContentsImpl::AddMessageToConsole(int32 level,
int WebContentsImpl::CreateSwappedOutRenderView(
SiteInstance* instance) {
int render_view_routing_id = MSG_ROUTING_NONE;
- GetRenderManager()->CreateRenderFrame(
- instance, nullptr, MSG_ROUTING_NONE,
- CREATE_RF_SWAPPED_OUT | CREATE_RF_FOR_MAIN_FRAME_NAVIGATION |
- CREATE_RF_HIDDEN,
- &render_view_routing_id);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ GetRenderManager()->CreateRenderFrameProxy(instance);
+ } else {
+ GetRenderManager()->CreateRenderFrame(
+ instance, nullptr, MSG_ROUTING_NONE,
+ CREATE_RF_SWAPPED_OUT | CREATE_RF_FOR_MAIN_FRAME_NAVIGATION |
+ CREATE_RF_HIDDEN,
+ &render_view_routing_id);
+ }
return render_view_routing_id;
}
@@ -4157,11 +4162,18 @@ int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) {
// Create a swapped out RenderView in the given SiteInstance if none exists,
// setting its opener to the given route_id. Return the new view's route_id.
int render_view_routing_id = MSG_ROUTING_NONE;
- GetRenderManager()->CreateRenderFrame(instance, nullptr, opener_route_id,
- CREATE_RF_FOR_MAIN_FRAME_NAVIGATION |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ GetRenderManager()->CreateRenderFrameProxy(instance);
+ render_view_routing_id =
+ frame_tree_.GetRenderViewHost(instance)->GetRoutingID();
+ } else {
+ GetRenderManager()->CreateRenderFrame(instance, nullptr, opener_route_id,
+ CREATE_RF_FOR_MAIN_FRAME_NAVIGATION |
CREATE_RF_SWAPPED_OUT |
CREATE_RF_HIDDEN,
- &render_view_routing_id);
+ &render_view_routing_id);
+ }
return render_view_routing_id;
}
@@ -4183,6 +4195,7 @@ bool WebContentsImpl::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
+ const FrameReplicationState& replicated_frame_state,
bool for_main_frame_navigation) {
TRACE_EVENT0("browser,navigation",
"WebContentsImpl::CreateRenderViewForRenderManager");
@@ -4214,6 +4227,7 @@ bool WebContentsImpl::CreateRenderViewForRenderManager(
opener_route_id,
proxy_routing_id,
max_page_id,
+ replicated_frame_state,
created_with_opener_)) {
return false;
}
@@ -4274,10 +4288,9 @@ WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() {
}
bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() {
- return CreateRenderViewForRenderManager(GetRenderViewHost(),
- MSG_ROUTING_NONE,
- MSG_ROUTING_NONE,
- true);
+ return CreateRenderViewForRenderManager(
+ GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE,
+ frame_tree_.root()->current_replication_state(), true);
}
#elif defined(OS_MACOSX)
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 8a46227..bffa888 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -572,6 +572,7 @@ class CONTENT_EXPORT WebContentsImpl
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
+ const FrameReplicationState& replicated_frame_state,
bool for_main_frame_navigation) override;
bool CreateRenderFrameForRenderManager(RenderFrameHost* render_frame_host,
int parent_routing_id,
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index 22efe5d..309a91c 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -459,6 +459,8 @@ TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) {
// Test that navigating across a site boundary creates a new RenderViewHost
// with a new SiteInstance. Going back should do the same.
TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
+ bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess);
TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
int orig_rvh_delete_count = 0;
orig_rfh->GetRenderViewHost()->set_delete_counter(&orig_rvh_delete_count);
@@ -523,9 +525,9 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
EXPECT_EQ(url2, contents()->GetVisibleURL());
EXPECT_NE(instance1, instance2);
EXPECT_EQ(nullptr, contents()->GetPendingMainFrame());
- // We keep the original RFH around, swapped out.
- EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList(
- orig_rfh));
+ // We keep a proxy for the original RFH's SiteInstance.
+ EXPECT_TRUE(contents()->GetRenderManagerForTesting()->GetRenderFrameProxyHost(
+ orig_rfh->GetSiteInstance()));
EXPECT_EQ(orig_rvh_delete_count, 0);
// Going back should switch SiteInstances again. The first SiteInstance is
@@ -538,7 +540,8 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
contents()->GetMainFrame()->PrepareForCommit();
}
TestRenderFrameHost* goback_rfh = contents()->GetPendingMainFrame();
- EXPECT_EQ(orig_rfh, goback_rfh);
+ if (!is_site_per_process)
+ EXPECT_EQ(orig_rfh, goback_rfh);
EXPECT_TRUE(contents()->CrossProcessNavigationPending());
// Navigations should be suspended in goback_rfh until BeforeUnloadACK.
@@ -555,9 +558,9 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
EXPECT_FALSE(contents()->CrossProcessNavigationPending());
EXPECT_EQ(goback_rfh, contents()->GetMainFrame());
EXPECT_EQ(instance1, contents()->GetSiteInstance());
- // The pending RFH should now be swapped out, not deleted.
+ // There should be a proxy for the pending RFH SiteInstance.
EXPECT_TRUE(contents()->GetRenderManagerForTesting()->
- IsOnSwappedOutList(pending_rfh));
+ GetRenderFrameProxyHost(pending_rfh->GetSiteInstance()));
EXPECT_EQ(pending_rvh_delete_count, 0);
pending_rfh->OnSwappedOut();
@@ -776,9 +779,9 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
EXPECT_EQ(url2, contents()->GetVisibleURL());
EXPECT_NE(new_instance, orig_instance);
EXPECT_FALSE(contents()->GetPendingMainFrame());
- // We keep the original RFH around, swapped out.
- EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList(
- orig_rfh));
+ // We keep a proxy for the original RFH's SiteInstance.
+ EXPECT_TRUE(contents()->GetRenderManagerForTesting()->GetRenderFrameProxyHost(
+ orig_rfh->GetSiteInstance()));
EXPECT_EQ(orig_rvh_delete_count, 0);
orig_rfh->OnSwappedOut();
diff --git a/content/public/test/test_renderer_host.h b/content/public/test/test_renderer_host.h
index 9945d87..fc12cbe 100644
--- a/content/public/test/test_renderer_host.h
+++ b/content/public/test/test_renderer_host.h
@@ -132,11 +132,12 @@ class RenderViewHostTester {
virtual ~RenderViewHostTester() {}
// Gives tests access to RenderViewHostImpl::CreateRenderView.
- virtual bool CreateRenderView(const base::string16& frame_name,
- int opener_route_id,
- int proxy_routing_id,
- int32 max_page_id,
- bool created_with_opener) = 0;
+ virtual bool CreateTestRenderView(
+ const base::string16& frame_name,
+ int opener_route_id,
+ int proxy_routing_id,
+ int32 max_page_id,
+ bool created_with_opener) = 0;
// Makes the WasHidden/WasShown calls to the RenderWidget that
// tell it it has been hidden or restored from having been hidden.
diff --git a/content/renderer/accessibility/renderer_accessibility_browsertest.cc b/content/renderer/accessibility/renderer_accessibility_browsertest.cc
index b237d23..b1d4c0b 100644
--- a/content/renderer/accessibility/renderer_accessibility_browsertest.cc
+++ b/content/renderer/accessibility/renderer_accessibility_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/time/time.h"
#include "content/common/frame_messages.h"
#include "content/common/view_message_enums.h"
+#include "content/public/common/content_switches.h"
#include "content/public/test/render_view_test.h"
#include "content/renderer/accessibility/renderer_accessibility.h"
#include "content/renderer/render_frame_impl.h"
@@ -156,6 +157,14 @@ TEST_F(RendererAccessibilityTest, SendFullAccessibilityTreeOnReload) {
TEST_F(RendererAccessibilityTest,
MAYBE_AccessibilityMessagesQueueWhileSwappedOut) {
+ // This test breaks down in --site-per-process, as swapping out destroys
+ // the main frame and it cannot be further navigated.
+ // TODO(nasko): Figure out what this behavior looks like when swapped out
+ // no longer exists.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
std::string html =
"<body>"
" <p>Hello, world.</p>"
diff --git a/content/renderer/history_entry.cc b/content/renderer/history_entry.cc
index efd6fb5..24d6aea 100644
--- a/content/renderer/history_entry.cc
+++ b/content/renderer/history_entry.cc
@@ -69,7 +69,10 @@ HistoryEntry::HistoryNode* HistoryEntry::HistoryNode::CloneAndReplace(
item_.documentSequenceNumber());
}
- if (clone_children_of_target || !is_target_frame) {
+ // TODO(creis): This needs to be updated to handle HistoryEntry in
+ // subframe processes, where the main frame isn't guaranteed to be in the
+ // same process.
+ if (current_frame && (clone_children_of_target || !is_target_frame)) {
for (WebFrame* child = current_frame->GetWebFrame()->firstChild(); child;
child = child->nextSibling()) {
RenderFrameImpl* child_render_frame =
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index f67a40a..aba81ee 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -537,11 +537,6 @@ void RenderFrameImpl::CreateFrame(
const FrameReplicationState& replicated_state,
CompositorDependencies* compositor_deps,
const FrameMsg_NewFrame_WidgetParams& widget_params) {
- // TODO(nasko): For now, this message is only sent for subframes, as the
- // top level frame is created when the RenderView is created through the
- // ViewMsg_New IPC.
- CHECK_NE(MSG_ROUTING_NONE, parent_routing_id);
-
blink::WebLocalFrame* web_frame;
RenderFrameImpl* render_frame;
if (proxy_routing_id == MSG_ROUTING_NONE) {
@@ -578,6 +573,7 @@ void RenderFrameImpl::CreateFrame(
replicated_state.sandbox_flags);
}
render_frame->SetWebFrame(web_frame);
+ CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent());
if (widget_params.routing_id != MSG_ROUTING_NONE) {
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -700,7 +696,9 @@ RenderFrameImpl::~RenderFrameImpl() {
}
// Ensure the RenderView doesn't point to this object, once it is destroyed.
- CHECK_EQ(render_view_->main_render_frame_, this);
+ // TODO(nasko): Add a check that the |main_render_frame_| of |render_view_|
+ // is |this|, once the object is no longer leaked.
+ // See https://crbug.com/464764.
render_view_->main_render_frame_ = nullptr;
}
@@ -1152,7 +1150,8 @@ void RenderFrameImpl::OnSwapOut(
// TODO(creis): Should we be stopping all frames here and using
// StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this
// frame?
- OnStop();
+ if (!is_site_per_process)
+ OnStop();
// Transfer settings such as initial drawing parameters to the remote frame,
// if one is created, that will replace this frame.
@@ -1163,7 +1162,7 @@ void RenderFrameImpl::OnSwapOut(
// run a second time, thanks to a check in FrameLoader::stopLoading.
// TODO(creis): Need to add a better way to do this that avoids running the
// beforeunload handler. For now, we just run it a second time silently.
- if (!is_site_per_process || is_main_frame)
+ if (!is_site_per_process)
NavigateToSwappedOutURL();
// Let WebKit know that this view is hidden so it can drop resources and
@@ -1182,19 +1181,16 @@ void RenderFrameImpl::OnSwapOut(
Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
+ RenderViewImpl* render_view = render_view_.get();
+
// Now that all of the cleanup is complete and the browser side is notified,
// start using the RenderFrameProxy, if one is created.
if (proxy) {
- if (!is_main_frame) {
+ if (is_site_per_process || !is_main_frame) {
frame_->swap(proxy->web_frame());
if (is_loading)
proxy->OnDidStartLoading();
-
- if (is_site_per_process) {
- // TODO(nasko): delete the frame here, since we've replaced it with a
- // proxy.
- }
}
}
@@ -1206,12 +1202,24 @@ void RenderFrameImpl::OnSwapOut(
// in proxy->web_frame(), the RemoteFrame will not exist for main frames.
// When we do an unconditional swap for all frames, we can remove
// !is_main_frame below.
- if (is_site_per_process && proxy && !is_main_frame)
+ if (is_site_per_process && proxy)
proxy->SetReplicatedState(replicated_frame_state);
// Safe to exit if no one else is using the process.
- if (is_main_frame)
- render_view_->WasSwappedOut();
+ // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count
+ // the process based on the lifetime of this RenderFrameImpl object.
+ if (is_main_frame) {
+ render_view->WasSwappedOut();
+
+ // TODO(nasko): Currently, this RenderFrame is leaked due to
+ // https://crbug.com/464764, therefore the destructor won't be invoked to
+ // destroy this object. Until this bug is fixed, set the main frame of the
+ // RenderView to null here.
+ if (is_site_per_process) {
+ CHECK_EQ(render_view_->main_render_frame_, this);
+ render_view->main_render_frame_ = nullptr;
+ }
+ }
}
void RenderFrameImpl::OnContextMenuClosed(
@@ -2593,10 +2601,13 @@ void RenderFrameImpl::didCommitProvisionalLoad(
proxy_routing_id_ = MSG_ROUTING_NONE;
// If this is the main frame going from a remote frame to a local frame,
- // it needs to set RenderViewImpl's pointer for the main frame to itself.
+ // it needs to set RenderViewImpl's pointer for the main frame to itself
+ // and ensure RenderWidget is no longer in swapped out mode.
if (!is_subframe_) {
CHECK(!render_view_->main_render_frame_);
render_view_->main_render_frame_ = this;
+ if (render_view_->is_swapped_out())
+ render_view_->SetSwappedOut(false);
}
}
diff --git a/content/renderer/render_frame_proxy.cc b/content/renderer/render_frame_proxy.cc
index 66baaf7..fda7b78 100644
--- a/content/renderer/render_frame_proxy.cc
+++ b/content/renderer/render_frame_proxy.cc
@@ -6,12 +6,14 @@
#include <map>
+#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "content/child/webmessageportchannel_impl.h"
#include "content/common/frame_messages.h"
#include "content/common/frame_replication_state.h"
#include "content/common/swapped_out_messages.h"
#include "content/common/view_messages.h"
+#include "content/public/common/content_switches.h"
#include "content/renderer/child_frame_compositing_helper.h"
#include "content/renderer/render_frame_impl.h"
#include "content/renderer/render_thread_impl.h"
@@ -65,7 +67,7 @@ RenderFrameProxy* RenderFrameProxy::CreateFrameProxy(
RenderViewImpl* render_view = NULL;
blink::WebRemoteFrame* web_frame = NULL;
if (parent_routing_id == MSG_ROUTING_NONE) {
- // Create a top level frame.
+ // Create a top level WebRemoteFrame.
render_view = RenderViewImpl::FromRoutingID(render_view_routing_id);
web_frame =
blink::WebRemoteFrame::create(replicated_state.scope, proxy.get());
@@ -292,12 +294,15 @@ void RenderFrameProxy::OnDisownOpener() {
// When there is a RenderFrame for this proxy, tell it to disown its opener.
// TODO(creis): Remove this when we only have WebRemoteFrames and make sure
// they know they have an opener.
- RenderFrameImpl* render_frame =
- RenderFrameImpl::FromRoutingID(frame_routing_id_);
- if (render_frame) {
- if (render_frame->GetWebFrame()->opener())
- render_frame->GetWebFrame()->setOpener(NULL);
- return;
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ RenderFrameImpl* render_frame =
+ RenderFrameImpl::FromRoutingID(frame_routing_id_);
+ if (render_frame) {
+ if (render_frame->GetWebFrame()->opener())
+ render_frame->GetWebFrame()->setOpener(NULL);
+ return;
+ }
}
if (web_frame_->opener())
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index b29bb7d..ca040045 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -640,6 +640,12 @@ TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) {
// Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is
// already swapped out. http://crbug.com/93427.
TEST_F(RenderViewImplTest, SendSwapOutACK) {
+ // This test is invalid in --site-per-process mode, as swapped-out is no
+ // longer used.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
LoadHTML("<div>Page A</div>");
int initial_page_id = view_page_id();
@@ -686,6 +692,13 @@ TEST_F(RenderViewImplTest, SendSwapOutACK) {
// Ensure the RenderViewImpl reloads the previous page if a reload request
// arrives while it is showing swappedout://. http://crbug.com/143155.
TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
+ // This test is invalid in --site-per-process mode, as swapped-out is no
+ // longer used.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ return;
+ }
+
// Load page A.
LoadHTML("<div>Page A</div>");
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 53ba225..1c4f809 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -638,6 +638,7 @@ RenderViewImpl::RenderViewImpl(const ViewMsg_New_Params& params)
top_controls_constraints_(TOP_CONTROLS_STATE_BOTH),
#endif
has_scrolled_focused_editable_node_into_rect_(false),
+ main_render_frame_(nullptr),
speech_recognition_dispatcher_(NULL),
mouse_lock_dispatcher_(NULL),
#if defined(OS_ANDROID)
@@ -668,24 +669,58 @@ void RenderViewImpl::Initialize(const ViewMsg_New_Params& params,
// Ensure we start with a valid next_page_id_ from the browser.
DCHECK_GE(next_page_id_, 0);
- main_render_frame_ = RenderFrameImpl::Create(
- this, params.main_frame_routing_id);
- // The main frame WebLocalFrame object is closed by
- // RenderFrameImpl::frameDetached().
- WebLocalFrame* web_frame = WebLocalFrame::create(
- blink::WebTreeScopeType::Document, main_render_frame_);
- main_render_frame_->SetWebFrame(web_frame);
+ if (params.main_frame_routing_id != MSG_ROUTING_NONE) {
+ main_render_frame_ = RenderFrameImpl::Create(
+ this, params.main_frame_routing_id);
+ // The main frame WebLocalFrame object is closed by
+ // RenderFrameImpl::frameDetached().
+ WebLocalFrame* web_frame = WebLocalFrame::create(
+ blink::WebTreeScopeType::Document, main_render_frame_);
+ main_render_frame_->SetWebFrame(web_frame);
+ }
compositor_deps_ = compositor_deps;
webwidget_ = WebView::create(this);
webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_));
+ g_view_map.Get().insert(std::make_pair(webview(), this));
+ g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this));
+
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kStatsCollectionController))
stats_collection_observer_.reset(new StatsCollectionObserver(this));
+ RenderFrameProxy* proxy = NULL;
+ if (params.proxy_routing_id != MSG_ROUTING_NONE) {
+ CHECK(params.swapped_out);
+ if (main_render_frame_) {
+ proxy = RenderFrameProxy::CreateProxyToReplaceFrame(
+ main_render_frame_, params.proxy_routing_id,
+ blink::WebTreeScopeType::Document);
+ main_render_frame_->set_render_frame_proxy(proxy);
+ } else {
+ proxy = RenderFrameProxy::CreateFrameProxy(
+ params.proxy_routing_id,
+ MSG_ROUTING_NONE,
+ routing_id_,
+ params.replicated_frame_state);
+ }
+ }
+
+ // In --site-per-process, just use the WebRemoteFrame as the main frame.
+ if (command_line.HasSwitch(switches::kSitePerProcess) && proxy) {
+ webview()->setMainFrame(proxy->web_frame());
+ // Initialize the WebRemoteFrame with information replicated from the
+ // browser process.
+ proxy->SetReplicatedState(params.replicated_frame_state);
+ } else {
+ webview()->setMainFrame(main_render_frame_->GetWebFrame());
+ }
+ if (main_render_frame_)
+ main_render_frame_->Initialize();
+
#if defined(OS_ANDROID)
content_detectors_.push_back(linked_ptr<ContentDetector>(
new AddressDetector()));
@@ -717,8 +752,6 @@ void RenderViewImpl::Initialize(const ViewMsg_New_Params& params,
CompleteInit();
}
- g_view_map.Get().insert(std::make_pair(webview(), this));
- g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this));
webview()->setDeviceScaleFactor(device_scale_factor_);
webview()->setDisplayMode(display_mode_);
webview()->settings()->setPreferCompositingToLCDTextEnabled(
@@ -730,26 +763,6 @@ void RenderViewImpl::Initialize(const ViewMsg_New_Params& params,
ApplyWebPreferences(webkit_preferences_, webview());
- RenderFrameProxy* proxy = NULL;
- if (params.proxy_routing_id != MSG_ROUTING_NONE) {
- CHECK(params.swapped_out);
- proxy = RenderFrameProxy::CreateProxyToReplaceFrame(
- main_render_frame_, params.proxy_routing_id,
- blink::WebTreeScopeType::Document);
- main_render_frame_->set_render_frame_proxy(proxy);
- }
-
- // In --site-per-process, just use the WebRemoteFrame as the main frame.
- if (command_line.HasSwitch(switches::kSitePerProcess) && proxy) {
- webview()->setMainFrame(proxy->web_frame());
- // Initialize the WebRemoteFrame with information replicated from the
- // browser process.
- proxy->SetReplicatedState(params.replicated_frame_state);
- } else {
- webview()->setMainFrame(main_render_frame_->GetWebFrame());
- }
- main_render_frame_->Initialize();
-
if (switches::IsTouchDragDropEnabled())
webview()->settings()->setTouchDragDropEnabled(true);
diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc
index 6badf47..504ac77 100644
--- a/content/test/test_render_frame_host.cc
+++ b/content/test/test_render_frame_host.cc
@@ -72,7 +72,7 @@ MockRenderProcessHost* TestRenderFrameHost::GetProcess() {
void TestRenderFrameHost::InitializeRenderFrameIfNeeded() {
if (!render_view_host()->IsRenderViewLive()) {
- RenderViewHostTester::For(render_view_host())->CreateRenderView(
+ RenderViewHostTester::For(render_view_host())->CreateTestRenderView(
base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, -1, false);
}
}
diff --git a/content/test/test_render_view_host.cc b/content/test/test_render_view_host.cc
index d729fb6..5e222d1 100644
--- a/content/test/test_render_view_host.cc
+++ b/content/test/test_render_view_host.cc
@@ -236,11 +236,23 @@ TestRenderViewHost::~TestRenderViewHost() {
++*delete_counter_;
}
+bool TestRenderViewHost::CreateTestRenderView(
+ const base::string16& frame_name,
+ int opener_route_id,
+ int proxy_route_id,
+ int32 max_page_id,
+ bool window_was_created_with_opener) {
+ return CreateRenderView(frame_name, opener_route_id, proxy_route_id,
+ max_page_id, FrameReplicationState(),
+ window_was_created_with_opener);
+}
+
bool TestRenderViewHost::CreateRenderView(
const base::string16& frame_name,
int opener_route_id,
int proxy_route_id,
int32 max_page_id,
+ const FrameReplicationState& replicated_frame_state,
bool window_was_created_with_opener) {
DCHECK(!IsRenderViewLive());
set_renderer_initialized(true);
diff --git a/content/test/test_render_view_host.h b/content/test/test_render_view_host.h
index d3869de..fc21a57 100644
--- a/content/test/test_render_view_host.h
+++ b/content/test/test_render_view_host.h
@@ -39,6 +39,7 @@ namespace content {
class SiteInstance;
class TestRenderFrameHost;
class TestWebContents;
+struct FrameReplicationState;
// Utility function to initialize FrameHostMsg_DidCommitProvisionalLoad_Params
// with given parameters.
@@ -232,12 +233,19 @@ class TestRenderViewHost
// RenderWidgetHost overrides (same value, but in the Mock* type)
MockRenderProcessHost* GetProcess() const override;
+ bool CreateTestRenderView(const base::string16& frame_name,
+ int opener_route_id,
+ int proxy_route_id,
+ int32 max_page_id,
+ bool window_was_created_with_opener) override;
+
// RenderViewHost overrides --------------------------------------------------
bool CreateRenderView(const base::string16& frame_name,
int opener_route_id,
int proxy_route_id,
int32 max_page_id,
+ const FrameReplicationState& replicated_frame_state,
bool window_was_created_with_opener) override;
bool IsFullscreenGranted() const override;
diff --git a/content/test/test_web_contents.cc b/content/test/test_web_contents.cc
index 2f35a8b..b852b0b 100644
--- a/content/test/test_web_contents.cc
+++ b/content/test/test_web_contents.cc
@@ -130,6 +130,7 @@ bool TestWebContents::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
+ const FrameReplicationState& replicated_frame_state,
bool for_main_frame) {
UpdateMaxPageIDIfNecessary(render_view_host);
// This will go to a TestRenderViewHost.
@@ -137,7 +138,9 @@ bool TestWebContents::CreateRenderViewForRenderManager(
render_view_host)->CreateRenderView(base::string16(),
opener_route_id,
proxy_routing_id,
- -1, false);
+ -1,
+ replicated_frame_state,
+ false);
return true;
}
diff --git a/content/test/test_web_contents.h b/content/test/test_web_contents.h
index 53bc82a..de3a103 100644
--- a/content/test/test_web_contents.h
+++ b/content/test/test_web_contents.h
@@ -61,10 +61,12 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester {
bool CrossProcessNavigationPending();
// Prevent interaction with views.
- bool CreateRenderViewForRenderManager(RenderViewHost* render_view_host,
- int opener_route_id,
- int proxy_routing_id,
- bool for_main_frame) override;
+ bool CreateRenderViewForRenderManager(
+ RenderViewHost* render_view_host,
+ int opener_route_id,
+ int proxy_routing_id,
+ const FrameReplicationState& replicated_frame_state,
+ bool for_main_frame) override;
void UpdateRenderViewSizeForRenderManager() override {}
// Returns a clone of this TestWebContents. The returned object is also a
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json
index b706788..8509c57 100644
--- a/testing/buildbot/chromium.fyi.json
+++ b/testing/buildbot/chromium.fyi.json
@@ -3471,7 +3471,7 @@
{
"args": [
"--site-per-process",
- "--gtest_filter=-*.DontPreemptNavigationWithFrameTreeUpdate:*.ProcessExitWithSwappedOutViews:*.SupportCrossProcessPostMessageWithMessagePort"
+ "--gtest_filter=-*.AllowTargetedNavigationsAfterSwap:*.DisownOpener:*.SupportCrossProcessPostMessageWithMessagePort"
],
"test": "content_browsertests"
},
@@ -3501,7 +3501,7 @@
{
"args": [
"--site-per-process",
- "--gtest_filter=-*.DontPreemptNavigationWithFrameTreeUpdate:*.ProcessExitWithSwappedOutViews:*.SupportCrossProcessPostMessageWithMessagePort"
+ "--gtest_filter=-*.AllowTargetedNavigationsAfterSwap:*.DisownOpener:*.SupportCrossProcessPostMessageWithMessagePort"
],
"test": "content_browsertests"
},
diff --git a/ui/views/controls/webview/webview_interactive_uitest.cc b/ui/views/controls/webview/webview_interactive_uitest.cc
index e13b24e..88aab9f 100644
--- a/ui/views/controls/webview/webview_interactive_uitest.cc
+++ b/ui/views/controls/webview/webview_interactive_uitest.cc
@@ -92,8 +92,8 @@ TEST_F(WebViewInteractiveUiTest, TextInputClientIsUpToDate) {
content::WebContents* web_contents1 = webview->GetWebContents();
web_contents1->GetRenderViewHost()->GetProcess()->Init();
content::RenderViewHostTester::For(web_contents1->GetRenderViewHost())
- ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE,
- -1, false);
+ ->CreateTestRenderView(base::string16(), MSG_ROUTING_NONE,
+ MSG_ROUTING_NONE, -1, false);
webview->RequestFocus();
ui::TextInputClient* client1 = webview->GetTextInputClient();
EXPECT_NE(nullptr, client1);
@@ -105,8 +105,8 @@ TEST_F(WebViewInteractiveUiTest, TextInputClientIsUpToDate) {
nullptr));
web_contents2->GetRenderViewHost()->GetProcess()->Init();
content::RenderViewHostTester::For(web_contents2->GetRenderViewHost())
- ->CreateRenderView(base::string16(), MSG_ROUTING_NONE, MSG_ROUTING_NONE,
- -1, false);
+ ->CreateTestRenderView(base::string16(), MSG_ROUTING_NONE,
+ MSG_ROUTING_NONE, -1, false);
webview->SetWebContents(web_contents2.get());
ui::TextInputClient* client2 = webview->GetTextInputClient();
EXPECT_NE(nullptr, client2);