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

Unified Diff: content/browser/tab_contents/render_view_host_manager_unittest.cc

Issue 6319001: Support window.opener after a process swap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/tab_contents/render_view_host_manager_unittest.cc
diff --git a/content/browser/tab_contents/render_view_host_manager_unittest.cc b/content/browser/tab_contents/render_view_host_manager_unittest.cc
index 591d8b73947528f8cf192b145249d70607289c67..c5ada3f2c2f0f86c12f75097b6ae0d27bff528fa 100644
--- a/content/browser/tab_contents/render_view_host_manager_unittest.cc
+++ b/content/browser/tab_contents/render_view_host_manager_unittest.cc
@@ -28,10 +28,23 @@ class RenderViewHostManagerTest : public RenderViewHostTestHarness {
// won't have committed yet, so NavigateAndCommit does the wrong thing
// for us.
controller().LoadURL(url, GURL(), PageTransition::LINK);
+ TestRenderViewHost* old_rvh = rvh();
+
+ // Simulate the ShouldClose_ACK that is received from the current renderer
+ // for a cross-site navigation.
+ if (old_rvh != active_rvh())
+ old_rvh->SendShouldCloseACK(true);
+
+ // Commit the navigation.
active_rvh()->SendNavigate(
static_cast<MockRenderProcessHost*>(active_rvh()->process())->
max_page_id() + 1,
url);
+
+ // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation
+ // without making any network requests.
+ if (old_rvh != active_rvh())
+ old_rvh->OnSwapOutACK();
}
bool ShouldSwapProcesses(RenderViewHostManager* manager,
@@ -61,26 +74,30 @@ TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) {
// a RVH that's not pending (since there is no cross-site transition), so
// we use the committed one, but the second one is the opposite.
contents2.controller().LoadURL(ntp, GURL(), PageTransition::LINK);
- static_cast<TestRenderViewHost*>(contents2.render_manager()->
- current_host())->SendNavigate(100, ntp);
+ TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>(
+ contents2.render_manager()->current_host());
+ ntp_rvh2->SendNavigate(100, ntp);
contents2.controller().LoadURL(dest, GURL(), PageTransition::LINK);
- static_cast<TestRenderViewHost*>(contents2.render_manager()->
- pending_render_view_host())->SendNavigate(101, dest);
+ TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>(
+ contents2.render_manager()->pending_render_view_host());
+ dest_rvh2->SendNavigate(101, dest);
+ ntp_rvh2->OnSwapOutACK();
// The two RVH's should be different in every way.
- EXPECT_NE(active_rvh()->process(), contents2.render_view_host()->process());
- EXPECT_NE(active_rvh()->site_instance(),
- contents2.render_view_host()->site_instance());
+ EXPECT_NE(active_rvh()->process(), dest_rvh2->process());
+ EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance());
EXPECT_NE(active_rvh()->site_instance()->browsing_instance(),
- contents2.render_view_host()->site_instance()->browsing_instance());
+ dest_rvh2->site_instance()->browsing_instance());
// Navigate both to the new tab page, and verify that they share a
// SiteInstance.
NavigateActiveAndCommit(ntp);
contents2.controller().LoadURL(ntp, GURL(), PageTransition::LINK);
+ dest_rvh2->SendShouldCloseACK(true);
static_cast<TestRenderViewHost*>(contents2.render_manager()->
pending_render_view_host())->SendNavigate(102, ntp);
+ dest_rvh2->OnSwapOutACK();
EXPECT_EQ(active_rvh()->site_instance(),
contents2.render_view_host()->site_instance());
« no previous file with comments | « content/browser/tab_contents/render_view_host_manager.cc ('k') | content/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698