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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 12330151: Merge 183730 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h" 7 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/renderer_host/test_render_view_host.h" 8 #include "content/browser/renderer_host/test_render_view_host.h"
9 #include "content/browser/site_instance_impl.h" 9 #include "content/browser/site_instance_impl.h"
10 #include "content/browser/web_contents/interstitial_page_impl.h" 10 #include "content/browser/web_contents/interstitial_page_impl.h"
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // is now covered by the CrossSiteBoundariesAfterCrash test. 577 // is now covered by the CrossSiteBoundariesAfterCrash test.
578 contents2->TestDidNavigate( 578 contents2->TestDidNavigate(
579 pending_rvh_b, 2, url2b, PAGE_TRANSITION_TYPED); 579 pending_rvh_b, 2, url2b, PAGE_TRANSITION_TYPED);
580 SiteInstance* instance2b = contents2->GetSiteInstance(); 580 SiteInstance* instance2b = contents2->GetSiteInstance();
581 EXPECT_NE(instance1, instance2b); 581 EXPECT_NE(instance1, instance2b);
582 582
583 // Both contentses should now be in the same SiteInstance. 583 // Both contentses should now be in the same SiteInstance.
584 EXPECT_EQ(instance2a, instance2b); 584 EXPECT_EQ(instance2a, instance2b);
585 } 585 }
586 586
587 // Test that we can find an opener RVH even if it's pending.
588 // http://crbug.com/176252.
589 TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) {
590 contents()->transition_cross_site = true;
591 TestRenderViewHost* orig_rvh = test_rvh();
592
593 // Navigate to a URL.
594 const GURL url("http://www.google.com");
595 controller().LoadURL(
596 url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
597 contents()->TestDidNavigate(orig_rvh, 1, url, PAGE_TRANSITION_TYPED);
598
599 // Start to navigate first tab to a new site, so that it has a pending RVH.
600 const GURL url2("http://www.yahoo.com");
601 controller().LoadURL(
602 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
603 orig_rvh->SendShouldCloseACK(true);
604 TestRenderViewHost* pending_rvh =
605 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost());
606
607 // While it is still pending, simulate opening a new tab with the first tab
608 // as its opener. This will call WebContentsImpl::CreateOpenerRenderViews
609 // on the opener to ensure that an RVH exists.
610 int opener_routing_id = contents()->CreateOpenerRenderViews(
611 pending_rvh->GetSiteInstance());
612
613 // We should find the pending RVH and not create a new one.
614 EXPECT_EQ(pending_rvh->GetRoutingID(), opener_routing_id);
615 }
616
587 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site, 617 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site,
588 // to determine whether a navigation is cross-site. 618 // to determine whether a navigation is cross-site.
589 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { 619 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
590 contents()->transition_cross_site = true; 620 contents()->transition_cross_site = true;
591 RenderViewHost* orig_rvh = rvh(); 621 RenderViewHost* orig_rvh = rvh();
592 SiteInstance* instance1 = contents()->GetSiteInstance(); 622 SiteInstance* instance1 = contents()->GetSiteInstance();
593 623
594 // Navigate to URL. 624 // Navigate to URL.
595 const GURL url("http://www.google.com"); 625 const GURL url("http://www.google.com");
596 controller().LoadURL( 626 controller().LoadURL(
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 1973
1944 // And the interstitial should be showing. 1974 // And the interstitial should be showing.
1945 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); 1975 EXPECT_TRUE(other_contents->ShowingInterstitialPage());
1946 1976
1947 // And the interstitial should do a reload on don't proceed. 1977 // And the interstitial should do a reload on don't proceed.
1948 EXPECT_TRUE(static_cast<InterstitialPageImpl*>( 1978 EXPECT_TRUE(static_cast<InterstitialPageImpl*>(
1949 other_contents->GetInterstitialPage())->reload_on_dont_proceed()); 1979 other_contents->GetInterstitialPage())->reload_on_dont_proceed());
1950 } 1980 }
1951 1981
1952 } // namespace content 1982 } // namespace content
OLDNEW
« 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