| 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/frame_tree_node.h" | 7 #include "content/browser/renderer_host/frame_tree_node.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
| 10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
| 11 #include "content/browser/web_contents/interstitial_page_impl.h" | 11 #include "content/browser/web_contents/interstitial_page_impl.h" |
| 12 #include "content/browser/web_contents/navigation_entry_impl.h" | 12 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 13 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 13 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 14 #include "content/common/view_messages.h" | 14 #include "content/common/view_messages.h" |
| 15 #include "content/public/browser/global_request_id.h" |
| 15 #include "content/public/browser/interstitial_page_delegate.h" | 16 #include "content/public/browser/interstitial_page_delegate.h" |
| 16 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
| 17 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 20 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
| 21 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 22 #include "content/public/browser/web_ui_controller.h" | 23 #include "content/public/browser/web_ui_controller.h" |
| 23 #include "content/public/common/bindings_policy.h" | 24 #include "content/public/common/bindings_policy.h" |
| 24 #include "content/public/common/content_constants.h" | 25 #include "content/public/common/content_constants.h" |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 701 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 701 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); | 702 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); |
| 702 now = base::TimeTicks::Now(); | 703 now = base::TimeTicks::Now(); |
| 703 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); | 704 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); |
| 704 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); | 705 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); |
| 705 EXPECT_TRUE(contents()->cross_navigation_pending()); | 706 EXPECT_TRUE(contents()->cross_navigation_pending()); |
| 706 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( | 707 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( |
| 707 contents()->GetPendingRenderViewHost()); | 708 contents()->GetPendingRenderViewHost()); |
| 708 | 709 |
| 709 // We won't hear DidNavigate until the onunload handler has finished running. | 710 // We won't hear DidNavigate until the onunload handler has finished running. |
| 710 // (No way to simulate that here, but it involves a call from RDH to | |
| 711 // WebContentsImpl::OnCrossSiteResponse.) | |
| 712 | 711 |
| 713 // DidNavigate from the pending page | 712 // DidNavigate from the pending page. |
| 714 contents()->TestDidNavigate( | 713 contents()->TestDidNavigate( |
| 715 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED); | 714 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED); |
| 716 SiteInstance* instance2 = contents()->GetSiteInstance(); | 715 SiteInstance* instance2 = contents()->GetSiteInstance(); |
| 717 EXPECT_FALSE(contents()->cross_navigation_pending()); | 716 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 718 EXPECT_EQ(pending_rvh, rvh()); | 717 EXPECT_EQ(pending_rvh, rvh()); |
| 719 EXPECT_NE(instance1, instance2); | 718 EXPECT_NE(instance1, instance2); |
| 720 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); | 719 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); |
| 721 } | 720 } |
| 722 | 721 |
| 723 // Test that during a slow cross-site navigation, the original renderer can | 722 // Test that during a slow cross-site navigation, the original renderer can |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 controller().LoadURL( | 948 controller().LoadURL( |
| 950 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 949 url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 951 base::TimeTicks now = base::TimeTicks::Now(); | 950 base::TimeTicks now = base::TimeTicks::Now(); |
| 952 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); | 951 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); |
| 953 EXPECT_TRUE(contents()->cross_navigation_pending()); | 952 EXPECT_TRUE(contents()->cross_navigation_pending()); |
| 954 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( | 953 TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( |
| 955 contents()->GetPendingRenderViewHost()); | 954 contents()->GetPendingRenderViewHost()); |
| 956 | 955 |
| 957 // Simulate the pending renderer's response, which leads to an unload request | 956 // Simulate the pending renderer's response, which leads to an unload request |
| 958 // being sent to orig_rvh. | 957 // being sent to orig_rvh. |
| 959 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(0, 0); | 958 contents()->OnCrossSiteResponse(pending_rvh, GlobalRequestID(0, 0)); |
| 960 | 959 |
| 961 // Suppose the original renderer navigates now, while the unload request is in | 960 // Suppose the original renderer navigates now, while the unload request is in |
| 962 // flight. We should ignore it, wait for the unload ack, and let the pending | 961 // flight. We should ignore it, wait for the unload ack, and let the pending |
| 963 // request continue. Otherwise, the contents may close spontaneously or stop | 962 // request continue. Otherwise, the contents may close spontaneously or stop |
| 964 // responding to navigation requests. (See bug 23942.) | 963 // responding to navigation requests. (See bug 23942.) |
| 965 ViewHostMsg_FrameNavigate_Params params1a; | 964 ViewHostMsg_FrameNavigate_Params params1a; |
| 966 InitNavigateParams(¶ms1a, 2, GURL("http://www.google.com/foo"), | 965 InitNavigateParams(¶ms1a, 2, GURL("http://www.google.com/foo"), |
| 967 PAGE_TRANSITION_TYPED); | 966 PAGE_TRANSITION_TYPED); |
| 968 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo")); | 967 orig_rvh->SendNavigate(2, GURL("http://www.google.com/foo")); |
| 969 | 968 |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 EXPECT_EQ(0UL, deep_tree->child_at(0)->child_at(0)->child_count()); | 2109 EXPECT_EQ(0UL, deep_tree->child_at(0)->child_at(0)->child_count()); |
| 2111 | 2110 |
| 2112 contents()->OnFrameDetached(16, 265); | 2111 contents()->OnFrameDetached(16, 265); |
| 2113 EXPECT_EQ(4UL, root->child_at(2)->child_count()); | 2112 EXPECT_EQ(4UL, root->child_at(2)->child_count()); |
| 2114 | 2113 |
| 2115 contents()->OnFrameDetached(5, 15); | 2114 contents()->OnFrameDetached(5, 15); |
| 2116 EXPECT_EQ(2UL, root->child_count()); | 2115 EXPECT_EQ(2UL, root->child_count()); |
| 2117 } | 2116 } |
| 2118 | 2117 |
| 2119 } // namespace content | 2118 } // namespace content |
| OLD | NEW |