OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mock_content_browser_client.h" | 7 #include "content/browser/mock_content_browser_client.h" |
8 #include "content/browser/renderer_host/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
9 #include "content/browser/renderer_host/render_widget_host_view.h" | 9 #include "content/browser/renderer_host/render_widget_host_view.h" |
10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // DidNavigate from the pending page | 363 // DidNavigate from the pending page |
364 contents()->TestDidNavigate( | 364 contents()->TestDidNavigate( |
365 pending_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); | 365 pending_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); |
366 SiteInstance* instance2 = contents()->GetSiteInstance(); | 366 SiteInstance* instance2 = contents()->GetSiteInstance(); |
367 | 367 |
368 EXPECT_FALSE(contents()->cross_navigation_pending()); | 368 EXPECT_FALSE(contents()->cross_navigation_pending()); |
369 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); | 369 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); |
370 EXPECT_NE(instance1, instance2); | 370 EXPECT_NE(instance1, instance2); |
371 EXPECT_TRUE(contents()->pending_rvh() == NULL); | 371 EXPECT_TRUE(contents()->pending_rvh() == NULL); |
372 // We keep the original RVH around, swapped out. | 372 // We keep the original RVH around, swapped out. |
373 EXPECT_TRUE(contents()->render_manager_for_testing()->IsSwappedOut(orig_rvh)); | 373 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsSwappedOut(orig_rvh)); |
374 EXPECT_EQ(orig_rvh_delete_count, 0); | 374 EXPECT_EQ(orig_rvh_delete_count, 0); |
375 | 375 |
376 // Going back should switch SiteInstances again. The first SiteInstance is | 376 // Going back should switch SiteInstances again. The first SiteInstance is |
377 // stored in the NavigationEntry, so it should be the same as at the start. | 377 // stored in the NavigationEntry, so it should be the same as at the start. |
378 // We should use the same RVH as before, swapping it back in. | 378 // We should use the same RVH as before, swapping it back in. |
379 controller().GoBack(); | 379 controller().GoBack(); |
380 TestRenderViewHost* goback_rvh = contents()->pending_rvh(); | 380 TestRenderViewHost* goback_rvh = contents()->pending_rvh(); |
381 EXPECT_EQ(orig_rvh, goback_rvh); | 381 EXPECT_EQ(orig_rvh, goback_rvh); |
382 EXPECT_TRUE(contents()->cross_navigation_pending()); | 382 EXPECT_TRUE(contents()->cross_navigation_pending()); |
383 | 383 |
384 // Navigations should be suspended in goback_rvh until ShouldCloseACK. | 384 // Navigations should be suspended in goback_rvh until ShouldCloseACK. |
385 EXPECT_TRUE(goback_rvh->are_navigations_suspended()); | 385 EXPECT_TRUE(goback_rvh->are_navigations_suspended()); |
386 pending_rvh->SendShouldCloseACK(true); | 386 pending_rvh->SendShouldCloseACK(true); |
387 EXPECT_FALSE(goback_rvh->are_navigations_suspended()); | 387 EXPECT_FALSE(goback_rvh->are_navigations_suspended()); |
388 | 388 |
389 // DidNavigate from the back action | 389 // DidNavigate from the back action |
390 contents()->TestDidNavigate( | 390 contents()->TestDidNavigate( |
391 goback_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); | 391 goback_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); |
392 EXPECT_FALSE(contents()->cross_navigation_pending()); | 392 EXPECT_FALSE(contents()->cross_navigation_pending()); |
393 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); | 393 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); |
394 EXPECT_EQ(instance1, contents()->GetSiteInstance()); | 394 EXPECT_EQ(instance1, contents()->GetSiteInstance()); |
395 // The pending RVH should now be swapped out, not deleted. | 395 // The pending RVH should now be swapped out, not deleted. |
396 EXPECT_TRUE(contents()->render_manager_for_testing()-> | 396 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
397 IsSwappedOut(pending_rvh)); | 397 IsSwappedOut(pending_rvh)); |
398 EXPECT_EQ(pending_rvh_delete_count, 0); | 398 EXPECT_EQ(pending_rvh_delete_count, 0); |
399 | 399 |
400 // Close tab and ensure RVHs are deleted. | 400 // Close tab and ensure RVHs are deleted. |
401 DeleteContents(); | 401 DeleteContents(); |
402 EXPECT_EQ(orig_rvh_delete_count, 1); | 402 EXPECT_EQ(orig_rvh_delete_count, 1); |
403 EXPECT_EQ(pending_rvh_delete_count, 1); | 403 EXPECT_EQ(pending_rvh_delete_count, 1); |
404 } | 404 } |
405 | 405 |
406 // Test that navigating across a site boundary after a crash creates a new | 406 // Test that navigating across a site boundary after a crash creates a new |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 const GURL url2("http://www.yahoo.com"); | 827 const GURL url2("http://www.yahoo.com"); |
828 controller().LoadURL( | 828 controller().LoadURL( |
829 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 829 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
830 orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); | 830 orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); |
831 EXPECT_TRUE(contents()->cross_navigation_pending()); | 831 EXPECT_TRUE(contents()->cross_navigation_pending()); |
832 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( | 832 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( |
833 contents()->pending_rvh()); | 833 contents()->pending_rvh()); |
834 | 834 |
835 // Simulate the pending renderer's response, which leads to an unload request | 835 // Simulate the pending renderer's response, which leads to an unload request |
836 // being sent to orig_rvh. | 836 // being sent to orig_rvh. |
837 contents()->render_manager_for_testing()->OnCrossSiteResponse(0, 0); | 837 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(0, 0); |
838 | 838 |
839 // Suppose the original renderer navigates now, while the unload request is in | 839 // Suppose the original renderer navigates now, while the unload request is in |
840 // flight. We should ignore it, wait for the unload ack, and let the pending | 840 // flight. We should ignore it, wait for the unload ack, and let the pending |
841 // request continue. Otherwise, the tab may close spontaneously or stop | 841 // request continue. Otherwise, the tab may close spontaneously or stop |
842 // responding to navigation requests. (See bug 23942.) | 842 // responding to navigation requests. (See bug 23942.) |
843 ViewHostMsg_FrameNavigate_Params params1a; | 843 ViewHostMsg_FrameNavigate_Params params1a; |
844 InitNavigateParams(¶ms1a, 2, GURL("http://www.google.com/foo"), | 844 InitNavigateParams(¶ms1a, 2, GURL("http://www.google.com/foo"), |
845 content::PAGE_TRANSITION_TYPED); | 845 content::PAGE_TRANSITION_TYPED); |
846 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo")); | 846 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo")); |
847 | 847 |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 | 1800 |
1801 // It should have a transient entry. | 1801 // It should have a transient entry. |
1802 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1802 EXPECT_TRUE(other_controller.GetTransientEntry()); |
1803 | 1803 |
1804 // And the interstitial should be showing. | 1804 // And the interstitial should be showing. |
1805 EXPECT_TRUE(other_contents->showing_interstitial_page()); | 1805 EXPECT_TRUE(other_contents->showing_interstitial_page()); |
1806 | 1806 |
1807 // And the interstitial should do a reload on don't proceed. | 1807 // And the interstitial should do a reload on don't proceed. |
1808 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); | 1808 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); |
1809 } | 1809 } |
OLD | NEW |