OLD | NEW |
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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // is now covered by the CrossSiteBoundariesAfterCrash test. | 572 // is now covered by the CrossSiteBoundariesAfterCrash test. |
573 contents2->TestDidNavigate( | 573 contents2->TestDidNavigate( |
574 pending_rvh_b, 2, url2b, PAGE_TRANSITION_TYPED); | 574 pending_rvh_b, 2, url2b, PAGE_TRANSITION_TYPED); |
575 SiteInstance* instance2b = contents2->GetSiteInstance(); | 575 SiteInstance* instance2b = contents2->GetSiteInstance(); |
576 EXPECT_NE(instance1, instance2b); | 576 EXPECT_NE(instance1, instance2b); |
577 | 577 |
578 // Both contentses should now be in the same SiteInstance. | 578 // Both contentses should now be in the same SiteInstance. |
579 EXPECT_EQ(instance2a, instance2b); | 579 EXPECT_EQ(instance2a, instance2b); |
580 } | 580 } |
581 | 581 |
| 582 // Test that we can find an opener RVH even if it's pending. |
| 583 // http://crbug.com/176252. |
| 584 TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) { |
| 585 contents()->transition_cross_site = true; |
| 586 TestRenderViewHost* orig_rvh = test_rvh(); |
| 587 |
| 588 // Navigate to a URL. |
| 589 const GURL url("http://www.google.com"); |
| 590 controller().LoadURL( |
| 591 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 592 contents()->TestDidNavigate(orig_rvh, 1, url, PAGE_TRANSITION_TYPED); |
| 593 |
| 594 // Start to navigate first tab to a new site, so that it has a pending RVH. |
| 595 const GURL url2("http://www.yahoo.com"); |
| 596 controller().LoadURL( |
| 597 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 598 orig_rvh->SendShouldCloseACK(true); |
| 599 TestRenderViewHost* pending_rvh = |
| 600 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost()); |
| 601 |
| 602 // While it is still pending, simulate opening a new tab with the first tab |
| 603 // as its opener. This will call WebContentsImpl::CreateOpenerRenderViews |
| 604 // on the opener to ensure that an RVH exists. |
| 605 int opener_routing_id = contents()->CreateOpenerRenderViews( |
| 606 pending_rvh->GetSiteInstance()); |
| 607 |
| 608 // We should find the pending RVH and not create a new one. |
| 609 EXPECT_EQ(pending_rvh->GetRoutingID(), opener_routing_id); |
| 610 } |
| 611 |
582 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site, | 612 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site, |
583 // to determine whether a navigation is cross-site. | 613 // to determine whether a navigation is cross-site. |
584 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { | 614 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { |
585 contents()->transition_cross_site = true; | 615 contents()->transition_cross_site = true; |
586 RenderViewHost* orig_rvh = rvh(); | 616 RenderViewHost* orig_rvh = rvh(); |
587 SiteInstance* instance1 = contents()->GetSiteInstance(); | 617 SiteInstance* instance1 = contents()->GetSiteInstance(); |
588 | 618 |
589 // Navigate to URL. | 619 // Navigate to URL. |
590 const GURL url("http://www.google.com"); | 620 const GURL url("http://www.google.com"); |
591 controller().LoadURL( | 621 controller().LoadURL( |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 other_contents->NavigateAndCommit(url_normalized); | 2001 other_contents->NavigateAndCommit(url_normalized); |
1972 | 2002 |
1973 // Check that an IPC with about:whatever is correctly normalized. | 2003 // Check that an IPC with about:whatever is correctly normalized. |
1974 other_contents->TestDidFailLoadWithError( | 2004 other_contents->TestDidFailLoadWithError( |
1975 1, url_from_ipc, true, 1, string16()); | 2005 1, url_from_ipc, true, 1, string16()); |
1976 EXPECT_EQ(url_normalized, other_observer.last_url()); | 2006 EXPECT_EQ(url_normalized, other_observer.last_url()); |
1977 } | 2007 } |
1978 | 2008 |
1979 | 2009 |
1980 } // namespace content | 2010 } // namespace content |
OLD | NEW |