diff options
author | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-02 16:43:14 +0000 |
---|---|---|
committer | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-02 16:43:14 +0000 |
commit | afb77faa1a2d3c98176c90e5ca76061b23cf8c13 (patch) | |
tree | 9dd71024b4f0cb27948b4ba28ffa5b8c66dfd6d2 /chrome/browser | |
parent | fe4c9e1cdd9a076616f1575c38e42f2be7985b73 (diff) | |
download | chromium_src-afb77faa1a2d3c98176c90e5ca76061b23cf8c13.zip chromium_src-afb77faa1a2d3c98176c90e5ca76061b23cf8c13.tar.gz chromium_src-afb77faa1a2d3c98176c90e5ca76061b23cf8c13.tar.bz2 |
Avoid canceling a pending navigation if the old RVH commits right away.
BUG=79176
TEST=TabContentsTest.CrossSiteNotPreemptedDuringBeforeUnload
Review URL: http://codereview.chromium.org/6973073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/tab_contents/web_contents_unittest.cc | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 56468c7..55bcf33 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -714,40 +714,40 @@ TEST_F(TabContentsTest, CrossSiteNavigationNotPreemptedByFrame) { EXPECT_TRUE(contents()->cross_navigation_pending()); } -// Test that the original renderer can preempt a cross-site navigation while the -// beforeunload request is in flight. -TEST_F(TabContentsTest, CrossSitePreemptDuringBeforeUnload) { +// Test that a cross-site navigation is not preempted if the previous +// renderer sends a FrameNavigate message just before being told to stop. +// We should only preempt the cross-site navigation if the previous renderer +// has started a new navigation. See http://crbug.com/79176. +TEST_F(TabContentsTest, CrossSiteNotPreemptedDuringBeforeUnload) { contents()->transition_cross_site = true; - TestRenderViewHost* orig_rvh = rvh(); - SiteInstance* instance1 = contents()->GetSiteInstance(); - // Navigate to URL. First URL should use first RenderViewHost. - const GURL url("http://www.google.com"); + // Navigate to NTP URL. + const GURL url("chrome://newtab"); controller().LoadURL(url, GURL(), PageTransition::TYPED); - ViewHostMsg_FrameNavigate_Params params1; - InitNavigateParams(¶ms1, 1, url, PageTransition::TYPED); - contents()->TestDidNavigate(orig_rvh, params1); + TestRenderViewHost* orig_rvh = rvh(); EXPECT_FALSE(contents()->cross_navigation_pending()); - EXPECT_EQ(orig_rvh, contents()->render_view_host()); - // Navigate to new site, with the befureunload request in flight. + // Navigate to new site, with the beforeunload request in flight. const GURL url2("http://www.yahoo.com"); controller().LoadURL(url2, GURL(), PageTransition::TYPED); + TestRenderViewHost* pending_rvh = contents()->pending_rvh(); + EXPECT_TRUE(contents()->cross_navigation_pending()); + EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); - // Suppose the original renderer navigates now, while the beforeunload request - // is in flight. We must cancel the pending navigation and show this new - // page, because the beforeunload handler might return false. - orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo")); + // Suppose the first navigation tries to commit now, with a + // ViewMsg_Stop in flight. This should not cancel the pending navigation, + // but it should act as if the beforeunload ack arrived. + orig_rvh->SendNavigate(1, GURL("chrome://newtab")); + EXPECT_TRUE(contents()->cross_navigation_pending()); + EXPECT_EQ(orig_rvh, contents()->render_view_host()); + EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); - // Verify that the pending navigation is cancelled. - SiteInstance* instance2 = contents()->GetSiteInstance(); + // The pending navigation should be able to commit successfully. + ViewHostMsg_FrameNavigate_Params params2; + InitNavigateParams(¶ms2, 1, url2, PageTransition::TYPED); + contents()->TestDidNavigate(pending_rvh, params2); EXPECT_FALSE(contents()->cross_navigation_pending()); - EXPECT_EQ(orig_rvh, rvh()); - EXPECT_EQ(instance1, instance2); - EXPECT_TRUE(contents()->pending_rvh() == NULL); - - // Make sure the beforeunload ack doesn't cause problems if it arrives here. - orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); + EXPECT_EQ(pending_rvh, contents()->render_view_host()); } // Test that the original renderer cannot preempt a cross-site navigation once |