OLD | NEW |
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/test/test_render_frame_host.h" | 5 #include "content/test/test_render_frame_host.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
9 #include "content/browser/frame_host/navigation_handle_impl.h" | 9 #include "content/browser/frame_host/navigation_handle_impl.h" |
10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 void TestRenderFrameHost::SendBeforeUnloadACK(bool proceed) { | 225 void TestRenderFrameHost::SendBeforeUnloadACK(bool proceed) { |
226 base::TimeTicks now = base::TimeTicks::Now(); | 226 base::TimeTicks now = base::TimeTicks::Now(); |
227 OnBeforeUnloadACK(proceed, now, now); | 227 OnBeforeUnloadACK(proceed, now, now); |
228 } | 228 } |
229 | 229 |
230 void TestRenderFrameHost::SimulateSwapOutACK() { | 230 void TestRenderFrameHost::SimulateSwapOutACK() { |
231 OnSwappedOut(); | 231 OnSwappedOut(); |
232 } | 232 } |
233 | 233 |
| 234 void TestRenderFrameHost::NavigateAndCommitRendererInitiated( |
| 235 int page_id, |
| 236 bool did_create_new_entry, |
| 237 const GURL& url) { |
| 238 SendRendererInitiatedNavigationRequest(url, false); |
| 239 // PlzNavigate: If no network request is needed by the navigation, then there |
| 240 // will be no NavigationRequest, nor is it necessary to simulate the network |
| 241 // stack commit. |
| 242 if (frame_tree_node()->navigation_request()) |
| 243 PrepareForCommit(); |
| 244 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
| 245 CHECK(!browser_side_navigation || is_loading()); |
| 246 CHECK(!browser_side_navigation || !frame_tree_node()->navigation_request()); |
| 247 SendNavigate(page_id, 0, did_create_new_entry, url); |
| 248 } |
| 249 |
234 void TestRenderFrameHost::SendNavigate(int page_id, | 250 void TestRenderFrameHost::SendNavigate(int page_id, |
235 int nav_entry_id, | 251 int nav_entry_id, |
236 bool did_create_new_entry, | 252 bool did_create_new_entry, |
237 const GURL& url) { | 253 const GURL& url) { |
238 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, false, | 254 SendNavigateWithParameters(page_id, nav_entry_id, did_create_new_entry, false, |
239 url, ui::PAGE_TRANSITION_LINK, 200, | 255 url, ui::PAGE_TRANSITION_LINK, 200, |
240 ModificationCallback()); | 256 ModificationCallback()); |
241 } | 257 } |
242 | 258 |
243 void TestRenderFrameHost::SendFailedNavigate(int page_id, | 259 void TestRenderFrameHost::SendFailedNavigate(int page_id, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 374 |
359 SendNavigateWithParams(¶ms); | 375 SendNavigateWithParams(¶ms); |
360 } | 376 } |
361 | 377 |
362 void TestRenderFrameHost::SendNavigateWithParams( | 378 void TestRenderFrameHost::SendNavigateWithParams( |
363 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { | 379 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { |
364 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params); | 380 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params); |
365 OnDidCommitProvisionalLoad(msg); | 381 OnDidCommitProvisionalLoad(msg); |
366 } | 382 } |
367 | 383 |
368 void TestRenderFrameHost::NavigateAndCommitRendererInitiated( | |
369 int page_id, | |
370 bool did_create_new_entry, | |
371 const GURL& url) { | |
372 SendRendererInitiatedNavigationRequest(url, false); | |
373 // PlzNavigate: If no network request is needed by the navigation, then there | |
374 // will be no NavigationRequest, nor is it necessary to simulate the network | |
375 // stack commit. | |
376 if (frame_tree_node()->navigation_request()) | |
377 PrepareForCommit(); | |
378 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | |
379 CHECK(!browser_side_navigation || is_loading()); | |
380 CHECK(!browser_side_navigation || !frame_tree_node()->navigation_request()); | |
381 SendNavigate(page_id, 0, did_create_new_entry, url); | |
382 } | |
383 | |
384 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( | 384 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( |
385 const GURL& url, | 385 const GURL& url, |
386 bool has_user_gesture) { | 386 bool has_user_gesture) { |
387 // Since this is renderer-initiated navigation, the RenderFrame must be | 387 // Since this is renderer-initiated navigation, the RenderFrame must be |
388 // initialized. Do it if it hasn't happened yet. | 388 // initialized. Do it if it hasn't happened yet. |
389 InitializeRenderFrameIfNeeded(); | 389 InitializeRenderFrameIfNeeded(); |
390 | 390 |
391 if (IsBrowserSideNavigationEnabled()) { | 391 if (IsBrowserSideNavigationEnabled()) { |
392 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, | 392 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, |
393 has_user_gesture, false, | 393 has_user_gesture, false, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at | 485 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at |
486 // this point. | 486 // this point. |
487 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) | 487 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) |
488 return; | 488 return; |
489 navigation_handle()->CallWillStartRequestForTesting( | 489 navigation_handle()->CallWillStartRequestForTesting( |
490 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), | 490 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), |
491 true /* user_gesture */, transition, false /* is_external_protocol */); | 491 true /* user_gesture */, transition, false /* is_external_protocol */); |
492 } | 492 } |
493 | 493 |
494 } // namespace content | 494 } // namespace content |
OLD | NEW |