| 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/navigation_throttle.h" | 13 #include "content/public/browser/navigation_throttle.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/browser_side_navigation_policy.h" | 15 #include "content/public/common/browser_side_navigation_policy.h" |
| 16 #include "content/public/common/resource_request_body.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 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 class NavigationThrottleCallbackRunner : public NavigationThrottle { | 26 class NavigationThrottleCallbackRunner : public NavigationThrottle { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return; | 139 return; |
| 139 DCHECK_EQ(handle_, request->navigation_handle()); | 140 DCHECK_EQ(handle_, request->navigation_handle()); |
| 140 } else { | 141 } else { |
| 141 render_frame_host_->OnMessageReceived( | 142 render_frame_host_->OnMessageReceived( |
| 142 FrameHostMsg_DidStartLoading(render_frame_host_->GetRoutingID(), true)); | 143 FrameHostMsg_DidStartLoading(render_frame_host_->GetRoutingID(), true)); |
| 143 render_frame_host_->OnMessageReceived(FrameHostMsg_DidStartProvisionalLoad( | 144 render_frame_host_->OnMessageReceived(FrameHostMsg_DidStartProvisionalLoad( |
| 144 render_frame_host_->GetRoutingID(), navigation_url_, | 145 render_frame_host_->GetRoutingID(), navigation_url_, |
| 145 std::vector<GURL>(), base::TimeTicks::Now())); | 146 std::vector<GURL>(), base::TimeTicks::Now())); |
| 146 DCHECK_EQ(handle_, render_frame_host_->navigation_handle()); | 147 DCHECK_EQ(handle_, render_frame_host_->navigation_handle()); |
| 147 handle_->WillStartRequest( | 148 handle_->WillStartRequest( |
| 148 "GET", scoped_refptr<content::ResourceRequestBodyImpl>(), referrer_, | 149 "GET", scoped_refptr<content::ResourceRequestBody>(), referrer_, |
| 149 true /* user_gesture */, transition_, false /* is_external_protocol */, | 150 true /* user_gesture */, transition_, false /* is_external_protocol */, |
| 150 REQUEST_CONTEXT_TYPE_LOCATION, | 151 REQUEST_CONTEXT_TYPE_LOCATION, |
| 151 blink::WebMixedContentContextType::kNotMixedContent, | 152 blink::WebMixedContentContextType::kNotMixedContent, |
| 152 base::Callback<void(NavigationThrottle::ThrottleCheckResult)>()); | 153 base::Callback<void(NavigationThrottle::ThrottleCheckResult)>()); |
| 153 } | 154 } |
| 154 | 155 |
| 155 CHECK(handle_); | 156 CHECK(handle_); |
| 156 WaitForThrottleChecksComplete(); | 157 WaitForThrottleChecksComplete(); |
| 157 | 158 |
| 158 CHECK_EQ(1, num_did_start_navigation_called_); | 159 CHECK_EQ(1, num_did_start_navigation_called_); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 if (!should_result_in_error_page) { | 640 if (!should_result_in_error_page) { |
| 640 render_frame_host_->OnMessageReceived( | 641 render_frame_host_->OnMessageReceived( |
| 641 FrameHostMsg_DidStopLoading(render_frame_host_->GetRoutingID())); | 642 FrameHostMsg_DidStopLoading(render_frame_host_->GetRoutingID())); |
| 642 CHECK_EQ(1, num_did_finish_navigation_called_); | 643 CHECK_EQ(1, num_did_finish_navigation_called_); |
| 643 } else { | 644 } else { |
| 644 CHECK_EQ(0, num_did_finish_navigation_called_); | 645 CHECK_EQ(0, num_did_finish_navigation_called_); |
| 645 } | 646 } |
| 646 } | 647 } |
| 647 | 648 |
| 648 } // namespace content | 649 } // namespace content |
| OLD | NEW |