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

Side by Side Diff: content/test/test_render_frame_host.cc

Issue 2373273002: Run unload handlers when navigating to about:blank using PlzNavigate. (Closed)
Patch Set: undo incorrect change that broke chrome://crash 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (!IsBrowserSideNavigationEnabled()) { 418 if (!IsBrowserSideNavigationEnabled()) {
419 // Non PlzNavigate 419 // Non PlzNavigate
420 if (is_waiting_for_beforeunload_ack()) 420 if (is_waiting_for_beforeunload_ack())
421 SendBeforeUnloadACK(true); 421 SendBeforeUnloadACK(true);
422 return; 422 return;
423 } 423 }
424 424
425 // PlzNavigate 425 // PlzNavigate
426 NavigationRequest* request = frame_tree_node_->navigation_request(); 426 NavigationRequest* request = frame_tree_node_->navigation_request();
427 CHECK(request); 427 CHECK(request);
428 bool have_to_make_network_request = ShouldMakeNetworkRequestForURL(
429 request->common_params().url);
428 430
429 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for 431 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for
430 // it. If it runs it will update the request state. 432 // it. If it runs it will update the request state.
431 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) { 433 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) {
432 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host()) 434 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host())
433 ->SendBeforeUnloadACK(true); 435 ->SendBeforeUnloadACK(true);
434 } 436 }
435 437
438 if (!have_to_make_network_request)
439 return; // |request| is destructed by now.
440
436 CHECK(request->state() == NavigationRequest::STARTED); 441 CHECK(request->state() == NavigationRequest::STARTED);
437 442
438 TestNavigationURLLoader* url_loader = 443 TestNavigationURLLoader* url_loader =
439 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); 444 static_cast<TestNavigationURLLoader*>(request->loader_for_testing());
440 CHECK(url_loader); 445 CHECK(url_loader);
441 446
442 // If a non-empty |redirect_url| was provided, simulate a server redirect. 447 // If a non-empty |redirect_url| was provided, simulate a server redirect.
443 if (!redirect_url.is_empty()) 448 if (!redirect_url.is_empty())
444 url_loader->SimulateServerRedirect(redirect_url); 449 url_loader->SimulateServerRedirect(redirect_url);
445 450
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at 490 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at
486 // this point. 491 // this point.
487 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) 492 if (!navigation_handle() || IsBrowserSideNavigationEnabled())
488 return; 493 return;
489 navigation_handle()->CallWillStartRequestForTesting( 494 navigation_handle()->CallWillStartRequestForTesting(
490 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), 495 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault),
491 true /* user_gesture */, transition, false /* is_external_protocol */); 496 true /* user_gesture */, transition, false /* is_external_protocol */);
492 } 497 }
493 498
494 } // namespace content 499 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698