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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 2403813002: Do not create NavigationHandles for inactive RenderFrameHosts (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 3079 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 commit_params.insecure_request_policy = blink::kLeaveInsecureRequestsAlone; 3090 commit_params.insecure_request_policy = blink::kLeaveInsecureRequestsAlone;
3091 child_host->SendNavigateWithParams(&commit_params); 3091 child_host->SendNavigateWithParams(&commit_params);
3092 EXPECT_NO_FATAL_FAILURE(CheckInsecureRequestPolicyIPC( 3092 EXPECT_NO_FATAL_FAILURE(CheckInsecureRequestPolicyIPC(
3093 main_test_rfh(), blink::kLeaveInsecureRequestsAlone, 3093 main_test_rfh(), blink::kLeaveInsecureRequestsAlone,
3094 proxy_to_parent->GetRoutingID())); 3094 proxy_to_parent->GetRoutingID()));
3095 EXPECT_EQ( 3095 EXPECT_EQ(
3096 blink::kLeaveInsecureRequestsAlone, 3096 blink::kLeaveInsecureRequestsAlone,
3097 root->child_at(0)->current_replication_state().insecure_request_policy); 3097 root->child_at(0)->current_replication_state().insecure_request_policy);
3098 } 3098 }
3099 3099
3100 // Tests that a BeginNavigation IPC from a no longer active RFH is ignored.
3101 TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation,
3102 BeginNavigationIgnoredWhenNotActive) {
3103 const GURL kUrl1("http://www.google.com");
3104 const GURL kUrl2("http://www.chromium.org");
3105 const GURL kUrl3("http://foo.com");
3106
3107 contents()->NavigateAndCommit(kUrl1);
3108
3109 TestRenderFrameHost* initial_rfh = main_test_rfh();
3110 RenderViewHostDeletedObserver delete_observer(
3111 initial_rfh->GetRenderViewHost());
3112
3113 // Navigate cross-site but don't simulate the swap out ACK. The initial RFH
3114 // should be pending delete.
3115 RenderFrameHostManager* manager =
3116 main_test_rfh()->frame_tree_node()->render_manager();
3117 contents()->StartNavigation(kUrl2);
3118 static_cast<TestRenderFrameHost*>(manager->speculative_frame_host())
3119 ->SimulateNavigationCommit(kUrl2);
3120 EXPECT_NE(initial_rfh, main_test_rfh());
3121 ASSERT_FALSE(delete_observer.deleted());
3122 EXPECT_FALSE(initial_rfh->is_active());
3123
3124 // The initial RFH receives a BeginNavigation IPC. The navigation should not
3125 // start.
3126 initial_rfh->SendRendererInitiatedNavigationRequest(kUrl3, true);
3127 EXPECT_FALSE(main_test_rfh()->frame_tree_node()->navigation_request());
3128 }
3129
3130 // Tests that a DidStartProvisionalLoad IPC from a no longer active RFH is
3131 // ignored.
3132 TEST_F(RenderFrameHostManagerTest,
3133 DidStartProvisionalLoadIgnoredWhenNotActive) {
3134 if (IsBrowserSideNavigationEnabled()) {
3135 SUCCEED() << "This test is not applicable to browser side navigation. See "
3136 "RenderFrameHostManagerTestWithBrowserSideNavigation."
3137 "BeginNavigationIgnoredWhenNotActive for a similar case when "
3138 "PlzNavigate is enabled.";
3139 return;
3140 }
3141 const GURL kUrl1("http://www.google.com");
3142 const GURL kUrl2("http://www.chromium.org");
3143 const GURL kUrl3("http://foo.com");
3144
3145 contents()->NavigateAndCommit(kUrl1);
3146
3147 TestRenderFrameHost* initial_rfh = main_test_rfh();
3148 RenderViewHostDeletedObserver delete_observer(
3149 initial_rfh->GetRenderViewHost());
3150
3151 // Navigate cross-site but don't simulate the swap out ACK. The initial RFH
3152 // should be pending delete.
3153 RenderFrameHostManager* manager =
3154 main_test_rfh()->frame_tree_node()->render_manager();
3155 contents()->StartNavigation(kUrl2);
3156 static_cast<TestRenderFrameHost*>(manager->pending_frame_host())
3157 ->SimulateNavigationCommit(kUrl2);
3158 EXPECT_NE(initial_rfh, main_test_rfh());
3159 ASSERT_FALSE(delete_observer.deleted());
3160 EXPECT_FALSE(initial_rfh->is_active());
3161
3162 // The initial RFH receives a DidStartProvisionalLoad IPC. It shoul dnot
nasko 2016/10/10 20:41:11 s/shoul dnot/should not/
clamy 2016/10/11 10:34:27 Done.
3163 // create a NavigationHandle.
3164 initial_rfh->SimulateNavigationStart(kUrl3);
3165 EXPECT_FALSE(initial_rfh->navigation_handle());
3166 }
3167
3100 } // namespace content 3168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698