OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/public/test/navigation_simulator.h" | 5 #include "content/public/test/navigation_simulator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/frame_host/navigation_handle_impl.h" | 10 #include "content/browser/frame_host/navigation_handle_impl.h" |
11 #include "content/browser/frame_host/navigation_request.h" | 11 #include "content/browser/frame_host/navigation_request.h" |
12 #include "content/common/frame_messages.h" | 12 #include "content/common/frame_messages.h" |
13 #include "content/public/browser/global_request_id.h" | |
13 #include "content/public/browser/navigation_throttle.h" | 14 #include "content/public/browser/navigation_throttle.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/common/browser_side_navigation_policy.h" | 16 #include "content/public/common/browser_side_navigation_policy.h" |
16 #include "content/test/test_navigation_url_loader.h" | 17 #include "content/test/test_navigation_url_loader.h" |
17 #include "content/test/test_render_frame_host.h" | 18 #include "content/test/test_render_frame_host.h" |
18 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
19 #include "net/url_request/redirect_info.h" | 20 #include "net/url_request/redirect_info.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 if (!handle_) { | 245 if (!handle_) { |
245 state_ = FAILED; | 246 state_ = FAILED; |
246 return; | 247 return; |
247 } | 248 } |
248 } | 249 } |
249 | 250 |
250 // Call NavigationHandle::WillProcessResponse if needed. | 251 // Call NavigationHandle::WillProcessResponse if needed. |
251 // Note that the handle's state can be CANCELING if a throttle cancelled it | 252 // Note that the handle's state can be CANCELING if a throttle cancelled it |
252 // synchronously in PrepareForCommit. | 253 // synchronously in PrepareForCommit. |
253 if (handle_->state_for_testing() < NavigationHandleImpl::CANCELING) { | 254 if (handle_->state_for_testing() < NavigationHandleImpl::CANCELING) { |
255 // Start the request_ids at 1000 to avoid collisions with request ids from | |
256 // network resoures (it should be rare to compare these in unit tests). | |
arthursonzogni
2017/05/16 09:16:04
Nit: s/resoures/resources
Charlie Harrison
2017/05/16 12:23:39
Done.
| |
257 static int request_id = 1000; | |
258 GlobalRequestID global_id(render_frame_host_->GetProcess()->GetID(), | |
259 ++request_id); | |
260 DCHECK(!IsBrowserSideNavigationEnabled()); | |
254 handle_->WillProcessResponse( | 261 handle_->WillProcessResponse( |
255 render_frame_host_, scoped_refptr<net::HttpResponseHeaders>(), | 262 render_frame_host_, scoped_refptr<net::HttpResponseHeaders>(), |
256 net::HttpResponseInfo::ConnectionInfo(), SSLStatus(), GlobalRequestID(), | 263 net::HttpResponseInfo::ConnectionInfo(), SSLStatus(), global_id, |
257 false /* should_replace_current_entry */, false /* is_download */, | 264 false /* should_replace_current_entry */, false /* is_download */, |
258 false /* is_stream */, base::Closure(), | 265 false /* is_stream */, base::Closure(), |
259 base::Callback<void(NavigationThrottle::ThrottleCheckResult)>()); | 266 base::Callback<void(NavigationThrottle::ThrottleCheckResult)>()); |
260 } | 267 } |
261 | 268 |
262 WaitForThrottleChecksComplete(); | 269 WaitForThrottleChecksComplete(); |
263 | 270 |
264 if (GetLastThrottleCheckResult() != NavigationThrottle::PROCEED) { | 271 if (GetLastThrottleCheckResult() != NavigationThrottle::PROCEED) { |
265 FailFromThrottleCheck(GetLastThrottleCheckResult()); | 272 FailFromThrottleCheck(GetLastThrottleCheckResult()); |
266 return; | 273 return; |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 if (!should_result_in_error_page) { | 616 if (!should_result_in_error_page) { |
610 render_frame_host_->OnMessageReceived( | 617 render_frame_host_->OnMessageReceived( |
611 FrameHostMsg_DidStopLoading(render_frame_host_->GetRoutingID())); | 618 FrameHostMsg_DidStopLoading(render_frame_host_->GetRoutingID())); |
612 CHECK_EQ(1, num_did_finish_navigation_called_); | 619 CHECK_EQ(1, num_did_finish_navigation_called_); |
613 } else { | 620 } else { |
614 CHECK_EQ(0, num_did_finish_navigation_called_); | 621 CHECK_EQ(0, num_did_finish_navigation_called_); |
615 } | 622 } |
616 } | 623 } |
617 | 624 |
618 } // namespace content | 625 } // namespace content |
OLD | NEW |