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

Unified Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 606113005: Move RenderViewHost swap out state to RenderFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review suggestions Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl_unittest.cc
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index a9ce61d6967f21459e5ce25ccfe802a899ff904d..c5e50da2d57f8100073ac7bf7e2fb8bc3ac780d0 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -478,10 +478,9 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
- // Keep the number of active views in orig_rfh's SiteInstance non-zero so that
- // orig_rfh doesn't get deleted when it gets swapped out.
- static_cast<SiteInstanceImpl*>(orig_rfh->GetSiteInstance())->
- increment_active_view_count();
+ // Keep the number of active frames in orig_rfh's SiteInstance non-zero so
+ // that orig_rfh doesn't get deleted when it gets swapped out.
+ orig_rfh->GetSiteInstance()->increment_active_frame_count();
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh->GetRenderViewHost(), contents()->GetRenderViewHost());
@@ -502,7 +501,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
// Navigations should be suspended in pending_rfh until BeforeUnloadACK.
EXPECT_TRUE(pending_rfh->are_navigations_suspended());
- orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true);
+ orig_rfh->SendBeforeUnloadACK(true);
EXPECT_FALSE(pending_rfh->are_navigations_suspended());
// DidNavigate from the pending page
@@ -510,11 +509,10 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED);
SiteInstance* instance2 = contents()->GetSiteInstance();
- // Keep the number of active views in pending_rfh's SiteInstance
+ // Keep the number of active frames in pending_rfh's SiteInstance
// non-zero so that orig_rfh doesn't get deleted when it gets
// swapped out.
- static_cast<SiteInstanceImpl*>(pending_rfh->GetSiteInstance())->
- increment_active_view_count();
+ pending_rfh->GetSiteInstance()->increment_active_frame_count();
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(pending_rfh, contents()->GetMainFrame());
@@ -537,7 +535,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
// Navigations should be suspended in goback_rfh until BeforeUnloadACK.
EXPECT_TRUE(goback_rfh->are_navigations_suspended());
- pending_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true);
+ pending_rfh->SendBeforeUnloadACK(true);
EXPECT_FALSE(goback_rfh->are_navigations_suspended());
// DidNavigate from the back action
@@ -549,7 +547,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
EXPECT_TRUE(contents()->GetRenderManagerForTesting()->
IsOnSwappedOutList(pending_rfh));
EXPECT_EQ(pending_rvh_delete_count, 0);
- pending_rfh->OnSwappedOut(false);
+ pending_rfh->OnSwappedOut();
// Close contents and ensure RVHs are deleted.
DeleteContents();
@@ -631,7 +629,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
const GURL url2a("http://www.yahoo.com");
controller().LoadURL(
url2a, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true);
+ orig_rfh->SendBeforeUnloadACK(true);
TestRenderFrameHost* pending_rfh_a = contents()->GetPendingMainFrame();
contents()->TestDidNavigate(
pending_rfh_a, 1, url2a, ui::PAGE_TRANSITION_TYPED);
@@ -644,7 +642,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
ui::PAGE_TRANSITION_TYPED,
std::string());
TestRenderFrameHost* rfh2 = contents2->GetMainFrame();
- rfh2->GetRenderViewHost()->SendBeforeUnloadACK(true);
+ rfh2->SendBeforeUnloadACK(true);
TestRenderFrameHost* pending_rfh_b = contents2->GetPendingMainFrame();
EXPECT_TRUE(pending_rfh_b != NULL);
EXPECT_TRUE(contents2->cross_navigation_pending());
@@ -672,8 +670,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
int orig_rvh_delete_count = 0;
orig_rfh->GetRenderViewHost()->set_delete_counter(&orig_rvh_delete_count);
- SiteInstanceImpl* orig_instance =
- static_cast<SiteInstanceImpl*>(contents()->GetSiteInstance());
+ SiteInstanceImpl* orig_instance = contents()->GetSiteInstance();
browser_client.set_assign_site_for_url(false);
// Navigate to an URL that will not assign a new SiteInstance.
@@ -702,11 +699,10 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
EXPECT_FALSE(contents()->GetPendingMainFrame());
contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
- // Keep the number of active views in orig_rfh's SiteInstance
+ // Keep the number of active frames in orig_rfh's SiteInstance
// non-zero so that orig_rfh doesn't get deleted when it gets
// swapped out.
- static_cast<SiteInstanceImpl*>(orig_rfh->GetSiteInstance())->
- increment_active_view_count();
+ orig_rfh->GetSiteInstance()->increment_active_frame_count();
EXPECT_EQ(orig_instance, contents()->GetSiteInstance());
EXPECT_TRUE(
@@ -727,7 +723,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
// Navigations should be suspended in pending_rvh until BeforeUnloadACK.
EXPECT_TRUE(pending_rfh->are_navigations_suspended());
- orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true);
+ orig_rfh->SendBeforeUnloadACK(true);
EXPECT_FALSE(pending_rfh->are_navigations_suspended());
// DidNavigate from the pending page.
@@ -745,7 +741,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList(
orig_rfh));
EXPECT_EQ(orig_rvh_delete_count, 0);
- orig_rfh->OnSwappedOut(false);
+ orig_rfh->OnSwappedOut();
// Close contents and ensure RVHs are deleted.
DeleteContents();
@@ -759,8 +755,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
TEST_F(WebContentsImplTest, NavigateFromRestoredSitelessUrl) {
WebContentsImplTestBrowserClient browser_client;
SetBrowserClientForTesting(&browser_client);
- SiteInstanceImpl* orig_instance =
- static_cast<SiteInstanceImpl*>(contents()->GetSiteInstance());
+ SiteInstanceImpl* orig_instance = contents()->GetSiteInstance();
TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
// Restore a navigation entry for URL that should not assign site to the
@@ -803,8 +798,7 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredSitelessUrl) {
TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) {
WebContentsImplTestBrowserClient browser_client;
SetBrowserClientForTesting(&browser_client);
- SiteInstanceImpl* orig_instance =
- static_cast<SiteInstanceImpl*>(contents()->GetSiteInstance());
+ SiteInstanceImpl* orig_instance = contents()->GetSiteInstance();
TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
// Restore a navigation entry for a regular URL ensuring that the embedder
@@ -856,7 +850,7 @@ TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) {
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true);
+ orig_rfh->SendBeforeUnloadACK(true);
TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
// While it is still pending, simulate opening a new tab with the first tab
@@ -937,24 +931,22 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) {
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- EXPECT_TRUE(orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
base::TimeTicks now = base::TimeTicks::Now();
orig_rfh->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
- EXPECT_FALSE(
- orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
// Navigate again, but simulate an onbeforeunload approval.
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- EXPECT_TRUE(orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
now = base::TimeTicks::Now();
orig_rfh->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
- EXPECT_FALSE(
- orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
EXPECT_TRUE(contents()->cross_navigation_pending());
TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
@@ -989,7 +981,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) {
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- EXPECT_TRUE(orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
base::TimeTicks now = base::TimeTicks::Now();
orig_rfh->OnMessageReceived(FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
EXPECT_TRUE(contents()->cross_navigation_pending());
@@ -998,8 +990,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) {
orig_rfh->SendNavigate(2, GURL("http://www.google.com/foo"));
// Verify that the pending navigation is cancelled.
- EXPECT_FALSE(
- orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
SiteInstance* instance2 = contents()->GetSiteInstance();
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
@@ -1033,7 +1024,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame();
// Simulate beforeunload approval.
- EXPECT_TRUE(ntp_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(ntp_rfh->is_waiting_for_beforeunload_ack());
base::TimeTicks now = base::TimeTicks::Now();
ntp_rfh->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
@@ -1084,8 +1075,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
EXPECT_EQ(entry1, controller().GetPendingEntry());
// Simulate beforeunload approval.
- EXPECT_TRUE(
- google_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(google_rfh->is_waiting_for_beforeunload_ack());
now = base::TimeTicks::Now();
google_rfh->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
@@ -1132,15 +1122,14 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) {
TestRenderFrameHost* child_rfh = orig_rfh->AppendChild("subframe");
child_rfh->SendNavigateWithTransition(
1, GURL("http://google.com/frame"), ui::PAGE_TRANSITION_AUTO_SUBFRAME);
- EXPECT_TRUE(orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
// Now simulate the onbeforeunload approval and verify the navigation is
// not canceled.
base::TimeTicks now = base::TimeTicks::Now();
orig_rfh->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
- EXPECT_FALSE(
- orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
EXPECT_TRUE(contents()->cross_navigation_pending());
}
@@ -1162,7 +1151,7 @@ TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) {
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
EXPECT_TRUE(contents()->cross_navigation_pending());
- EXPECT_TRUE(orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
// Suppose the first navigation tries to commit now, with a
// FrameMsg_Stop in flight. This should not cancel the pending navigation,
@@ -1170,8 +1159,7 @@ TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) {
orig_rfh->SendNavigate(1, GURL("chrome://blah"));
EXPECT_TRUE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
- EXPECT_FALSE(
- orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
// The pending navigation should be able to commit successfully.
contents()->TestDidNavigate(pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED);
@@ -1197,14 +1185,14 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) {
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
- EXPECT_TRUE(orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
base::TimeTicks now = base::TimeTicks::Now();
orig_rfh->OnMessageReceived(
FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
EXPECT_TRUE(contents()->cross_navigation_pending());
// Simulate swap out message when the response arrives.
- orig_rfh->OnSwappedOut(false);
+ orig_rfh->OnSwappedOut();
// Suppose the navigation doesn't get a chance to commit, and the user
// navigates in the current RFH's SiteInstance.
@@ -1213,13 +1201,11 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) {
// Verify that the pending navigation is cancelled and the renderer is no
// longer swapped out.
- EXPECT_FALSE(
- orig_rfh->GetRenderViewHost()->is_waiting_for_beforeunload_ack());
+ EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
SiteInstance* instance2 = contents()->GetSiteInstance();
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
- EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT,
- orig_rfh->GetRenderViewHost()->rvh_state());
+ EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, orig_rfh->rfh_state());
EXPECT_EQ(instance1, instance2);
EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
}
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698