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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 // DidNavigate from the pending page | 431 // DidNavigate from the pending page |
432 contents()->TestDidNavigate( | 432 contents()->TestDidNavigate( |
433 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED); | 433 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED); |
434 SiteInstance* instance2 = contents()->GetSiteInstance(); | 434 SiteInstance* instance2 = contents()->GetSiteInstance(); |
435 | 435 |
436 EXPECT_FALSE(contents()->cross_navigation_pending()); | 436 EXPECT_FALSE(contents()->cross_navigation_pending()); |
437 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); | 437 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); |
438 EXPECT_NE(instance1, instance2); | 438 EXPECT_NE(instance1, instance2); |
439 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); | 439 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); |
440 // We keep the original RVH around, swapped out. | 440 // We keep the original RVH around, swapped out. |
441 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsSwappedOut(orig_rvh)); | 441 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( |
| 442 orig_rvh)); |
442 EXPECT_EQ(orig_rvh_delete_count, 0); | 443 EXPECT_EQ(orig_rvh_delete_count, 0); |
443 | 444 |
444 // Going back should switch SiteInstances again. The first SiteInstance is | 445 // Going back should switch SiteInstances again. The first SiteInstance is |
445 // stored in the NavigationEntry, so it should be the same as at the start. | 446 // stored in the NavigationEntry, so it should be the same as at the start. |
446 // We should use the same RVH as before, swapping it back in. | 447 // We should use the same RVH as before, swapping it back in. |
447 controller().GoBack(); | 448 controller().GoBack(); |
448 TestRenderViewHost* goback_rvh = | 449 TestRenderViewHost* goback_rvh = |
449 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost()); | 450 static_cast<TestRenderViewHost*>(contents()->GetPendingRenderViewHost()); |
450 EXPECT_EQ(orig_rvh, goback_rvh); | 451 EXPECT_EQ(orig_rvh, goback_rvh); |
451 EXPECT_TRUE(contents()->cross_navigation_pending()); | 452 EXPECT_TRUE(contents()->cross_navigation_pending()); |
452 | 453 |
453 // Navigations should be suspended in goback_rvh until ShouldCloseACK. | 454 // Navigations should be suspended in goback_rvh until ShouldCloseACK. |
454 EXPECT_TRUE(goback_rvh->are_navigations_suspended()); | 455 EXPECT_TRUE(goback_rvh->are_navigations_suspended()); |
455 pending_rvh->SendShouldCloseACK(true); | 456 pending_rvh->SendShouldCloseACK(true); |
456 EXPECT_FALSE(goback_rvh->are_navigations_suspended()); | 457 EXPECT_FALSE(goback_rvh->are_navigations_suspended()); |
457 | 458 |
458 // DidNavigate from the back action | 459 // DidNavigate from the back action |
459 contents()->TestDidNavigate( | 460 contents()->TestDidNavigate( |
460 goback_rvh, 1, url2, PAGE_TRANSITION_TYPED); | 461 goback_rvh, 1, url2, PAGE_TRANSITION_TYPED); |
461 EXPECT_FALSE(contents()->cross_navigation_pending()); | 462 EXPECT_FALSE(contents()->cross_navigation_pending()); |
462 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); | 463 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); |
463 EXPECT_EQ(instance1, contents()->GetSiteInstance()); | 464 EXPECT_EQ(instance1, contents()->GetSiteInstance()); |
464 // The pending RVH should now be swapped out, not deleted. | 465 // The pending RVH should now be swapped out, not deleted. |
465 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 466 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
466 IsSwappedOut(pending_rvh)); | 467 IsOnSwappedOutList(pending_rvh)); |
467 EXPECT_EQ(pending_rvh_delete_count, 0); | 468 EXPECT_EQ(pending_rvh_delete_count, 0); |
468 | 469 |
469 // Close contents and ensure RVHs are deleted. | 470 // Close contents and ensure RVHs are deleted. |
470 DeleteContents(); | 471 DeleteContents(); |
471 EXPECT_EQ(orig_rvh_delete_count, 1); | 472 EXPECT_EQ(orig_rvh_delete_count, 1); |
472 EXPECT_EQ(pending_rvh_delete_count, 1); | 473 EXPECT_EQ(pending_rvh_delete_count, 1); |
473 } | 474 } |
474 | 475 |
475 // Test that navigating across a site boundary after a crash creates a new | 476 // Test that navigating across a site boundary after a crash creates a new |
476 // RVH without requiring a cross-site transition (i.e., PENDING state). | 477 // RVH without requiring a cross-site transition (i.e., PENDING state). |
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 TEST_F(WebContentsImplTest, PendingContents) { | 2043 TEST_F(WebContentsImplTest, PendingContents) { |
2043 scoped_ptr<TestWebContents> other_contents( | 2044 scoped_ptr<TestWebContents> other_contents( |
2044 static_cast<TestWebContents*>(CreateTestWebContents())); | 2045 static_cast<TestWebContents*>(CreateTestWebContents())); |
2045 contents()->AddPendingContents(other_contents.get()); | 2046 contents()->AddPendingContents(other_contents.get()); |
2046 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); | 2047 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); |
2047 other_contents.reset(); | 2048 other_contents.reset(); |
2048 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); | 2049 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); |
2049 } | 2050 } |
2050 | 2051 |
2051 } // namespace content | 2052 } // namespace content |
OLD | NEW |