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

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

Issue 2345053006: Remove IsSynchronous API from NavigationHandle. (Closed)
Patch Set: Fix CaptivePortalTabHelperTest.HttpsTimeout Created 4 years, 1 month 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/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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 render_view_host, 57 render_view_host,
58 delegate, 58 delegate,
59 rwh_delegate, 59 rwh_delegate,
60 frame_tree, 60 frame_tree,
61 frame_tree_node, 61 frame_tree_node,
62 routing_id, 62 routing_id,
63 widget_routing_id, 63 widget_routing_id,
64 flags), 64 flags),
65 child_creation_observer_(delegate ? delegate->GetAsWebContents() : NULL), 65 child_creation_observer_(delegate ? delegate->GetAsWebContents() : NULL),
66 contents_mime_type_("text/html"), 66 contents_mime_type_("text/html"),
67 simulate_history_list_was_cleared_(false) {} 67 simulate_history_list_was_cleared_(false),
68 last_commit_was_error_page_(false) {}
68 69
69 TestRenderFrameHost::~TestRenderFrameHost() { 70 TestRenderFrameHost::~TestRenderFrameHost() {
70 } 71 }
71 72
72 TestRenderViewHost* TestRenderFrameHost::GetRenderViewHost() { 73 TestRenderViewHost* TestRenderFrameHost::GetRenderViewHost() {
73 return static_cast<TestRenderViewHost*>( 74 return static_cast<TestRenderViewHost*>(
74 RenderFrameHostImpl::GetRenderViewHost()); 75 RenderFrameHostImpl::GetRenderViewHost());
75 } 76 }
76 77
77 MockRenderProcessHost* TestRenderFrameHost::GetProcess() { 78 MockRenderProcessHost* TestRenderFrameHost::GetProcess() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 params.method = "GET"; 151 params.method = "GET";
151 params.http_status_code = 200; 152 params.http_status_code = 200;
152 params.socket_address.set_host("2001:db8::1"); 153 params.socket_address.set_host("2001:db8::1");
153 params.socket_address.set_port(80); 154 params.socket_address.set_port(80);
154 params.history_list_was_cleared = simulate_history_list_was_cleared_; 155 params.history_list_was_cleared = simulate_history_list_was_cleared_;
155 params.original_request_url = url; 156 params.original_request_url = url;
156 157
157 url::Replacements<char> replacements; 158 url::Replacements<char> replacements;
158 replacements.ClearRef(); 159 replacements.ClearRef();
159 params.was_within_same_page = 160 params.was_within_same_page =
160 url.ReplaceComponents(replacements) == 161 (GetLastCommittedURL().is_valid() &&
161 GetLastCommittedURL().ReplaceComponents(replacements); 162 !last_commit_was_error_page_ &&
163 url.ReplaceComponents(replacements) ==
164 GetLastCommittedURL().ReplaceComponents(replacements));
Charlie Reis 2016/10/27 20:51:24 This replacements check seems wrong to me, but may
nasko 2016/10/27 21:22:34 Unit tests can definitely use some more love : ).
162 165
163 params.page_state = PageState::CreateForTesting(url, false, nullptr, nullptr); 166 params.page_state = PageState::CreateForTesting(url, false, nullptr, nullptr);
164 167
165 SendNavigateWithParams(&params); 168 SendNavigateWithParams(&params);
166 } 169 }
167 170
168 void TestRenderFrameHost::SimulateNavigationError(const GURL& url, 171 void TestRenderFrameHost::SimulateNavigationError(const GURL& url,
169 int error_code) { 172 int error_code) {
170 if (IsBrowserSideNavigationEnabled()) { 173 if (IsBrowserSideNavigationEnabled()) {
171 NavigationRequest* request = frame_tree_node_->navigation_request(); 174 NavigationRequest* request = frame_tree_node_->navigation_request();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // check corner cases (like about:blank) should specify the origin param 349 // check corner cases (like about:blank) should specify the origin param
347 // manually. 350 // manually.
348 url::Origin origin(url_copy); 351 url::Origin origin(url_copy);
349 params.origin = origin; 352 params.origin = origin;
350 353
351 url::Replacements<char> replacements; 354 url::Replacements<char> replacements;
352 replacements.ClearRef(); 355 replacements.ClearRef();
353 params.was_within_same_page = 356 params.was_within_same_page =
354 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && 357 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) &&
355 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) && 358 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) &&
356 url_copy.ReplaceComponents(replacements) == 359 (GetLastCommittedURL().is_valid() &&
357 GetLastCommittedURL().ReplaceComponents(replacements); 360 !last_commit_was_error_page_ &&
361 url_copy.ReplaceComponents(replacements) ==
362 GetLastCommittedURL().ReplaceComponents(replacements));
358 363
359 params.page_state = 364 params.page_state =
360 PageState::CreateForTesting(url_copy, false, nullptr, nullptr); 365 PageState::CreateForTesting(url_copy, false, nullptr, nullptr);
361 366
362 if (!callback.is_null()) 367 if (!callback.is_null())
363 callback.Run(&params); 368 callback.Run(&params);
364 369
365 SendNavigateWithParams(&params); 370 SendNavigateWithParams(&params);
366 } 371 }
367 372
368 void TestRenderFrameHost::SendNavigateWithParams( 373 void TestRenderFrameHost::SendNavigateWithParams(
369 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { 374 FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
370 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params); 375 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params);
371 OnDidCommitProvisionalLoad(msg); 376 OnDidCommitProvisionalLoad(msg);
377 last_commit_was_error_page_ = params->url_is_unreachable;
372 } 378 }
373 379
374 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( 380 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest(
375 const GURL& url, 381 const GURL& url,
376 bool has_user_gesture) { 382 bool has_user_gesture) {
377 // Since this is renderer-initiated navigation, the RenderFrame must be 383 // Since this is renderer-initiated navigation, the RenderFrame must be
378 // initialized. Do it if it hasn't happened yet. 384 // initialized. Do it if it hasn't happened yet.
379 InitializeRenderFrameIfNeeded(); 385 InitializeRenderFrameIfNeeded();
380 386
381 if (IsBrowserSideNavigationEnabled()) { 387 if (IsBrowserSideNavigationEnabled()) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at 471 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at
466 // this point. 472 // this point.
467 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) 473 if (!navigation_handle() || IsBrowserSideNavigationEnabled())
468 return; 474 return;
469 navigation_handle()->CallWillStartRequestForTesting( 475 navigation_handle()->CallWillStartRequestForTesting(
470 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), 476 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault),
471 true /* user_gesture */, transition, false /* is_external_protocol */); 477 true /* user_gesture */, transition, false /* is_external_protocol */);
472 } 478 }
473 479
474 } // namespace content 480 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698