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

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

Issue 12319035: Avoid creating an extra RVH for a tab's opener when one is pending. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial patch Created 7 years, 10 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') | no next file » | 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 1e7da49baf20e620256cee4394ec71caadb2fab8..1820d7ae47c940424e94782bb1cc02be64c63c1b 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -579,6 +579,36 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
EXPECT_EQ(instance2a, instance2b);
}
+// Test that we can find an opener RVH even if it's pending.
+// http://crbug.com/176252.
+TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) {
+ contents()->transition_cross_site = true;
+ TestRenderViewHost* orig_rvh = test_rvh();
+
+ // Navigate to a URL.
+ const GURL url("http://www.google.com");
+ controller().LoadURL(
+ url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
+ contents()->TestDidNavigate(orig_rvh, 1, url, PAGE_TRANSITION_TYPED);
+
+ // Start to navigate first tab to a new site, so that it has a pending RVH.
+ const GURL url2("http://www.yahoo.com");
+ controller().LoadURL(
+ url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
+ orig_rvh->SendShouldCloseACK(true);
+ TestRenderViewHost* pending_rvh =
+ static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost());
+
+ // While it is still pending, simulate opening a new tab with the first tab
+ // as its opener. This will call WebContentsImpl::CreateOpenerRenderViews
+ // on the opener to ensure that an RVH exists.
+ int opener_routing_id = contents()->CreateOpenerRenderViews(
+ pending_rvh->GetSiteInstance());
+
+ // We should find the pending RVH and not create a new one.
+ EXPECT_EQ(pending_rvh->GetRoutingID(), opener_routing_id);
+}
+
// Tests that WebContentsImpl uses the current URL, not the SiteInstance's site,
// to determine whether a navigation is cross-site.
TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698