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/command_line.h" | 7 #include "base/command_line.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_request.h" | 9 #include "content/browser/frame_host/navigation_request.h" |
10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
11 #include "content/browser/frame_host/navigator_impl.h" | 11 #include "content/browser/frame_host/navigator_impl.h" |
12 #include "content/browser/frame_host/render_frame_host_delegate.h" | 12 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 13 #include "content/common/frame_messages.h" |
13 #include "content/public/browser/stream_handle.h" | 14 #include "content/public/browser/stream_handle.h" |
14 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
15 #include "content/test/browser_side_navigation_test_utils.h" | 16 #include "content/test/browser_side_navigation_test_utils.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_view_host.h" | 18 #include "content/test/test_render_view_host.h" |
18 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
19 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" | 20 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" |
20 #include "ui/base/page_transition_types.h" | 21 #include "ui/base/page_transition_types.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 url, | 181 url, |
181 false, | 182 false, |
182 file_path_for_history_item ? "data" : NULL, | 183 file_path_for_history_item ? "data" : NULL, |
183 file_path_for_history_item); | 184 file_path_for_history_item); |
184 | 185 |
185 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params); | 186 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params); |
186 OnDidCommitProvisionalLoad(msg); | 187 OnDidCommitProvisionalLoad(msg); |
187 } | 188 } |
188 | 189 |
189 void TestRenderFrameHost::SendBeginNavigationWithURL(const GURL& url) { | 190 void TestRenderFrameHost::SendBeginNavigationWithURL(const GURL& url) { |
190 FrameHostMsg_BeginNavigation_Params begin_params; | 191 BeginNavigationParams begin_params( |
| 192 "GET", std::string(), net::LOAD_NORMAL, false); |
191 CommonNavigationParams common_params; | 193 CommonNavigationParams common_params; |
192 begin_params.method = "GET"; | |
193 begin_params.load_flags = net::LOAD_NORMAL; | |
194 begin_params.has_user_gesture = false; | |
195 common_params.url = url; | 194 common_params.url = url; |
196 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); | 195 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); |
197 common_params.transition = ui::PAGE_TRANSITION_LINK; | 196 common_params.transition = ui::PAGE_TRANSITION_LINK; |
198 OnBeginNavigation(begin_params, common_params); | 197 OnBeginNavigation(common_params, begin_params, |
| 198 scoped_refptr<ResourceRequestBody>()); |
199 } | 199 } |
200 | 200 |
201 void TestRenderFrameHost::DidDisownOpener() { | 201 void TestRenderFrameHost::DidDisownOpener() { |
202 OnDidDisownOpener(); | 202 OnDidDisownOpener(); |
203 } | 203 } |
204 | 204 |
205 void TestRenderFrameHost::PrepareForCommit(const GURL& url) { | 205 void TestRenderFrameHost::PrepareForCommit(const GURL& url) { |
206 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 206 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
207 switches::kEnableBrowserSideNavigation)) { | 207 switches::kEnableBrowserSideNavigation)) { |
208 SendBeforeUnloadACK(true); | 208 SendBeforeUnloadACK(true); |
(...skipping 10 matching lines...) Expand all Loading... |
219 if (!request) { | 219 if (!request) { |
220 SendBeginNavigationWithURL(url); | 220 SendBeginNavigationWithURL(url); |
221 request = static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) | 221 request = static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) |
222 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); | 222 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); |
223 } | 223 } |
224 ASSERT_TRUE(request); | 224 ASSERT_TRUE(request); |
225 | 225 |
226 // We may not have simulated the renderer response to the navigation request. | 226 // We may not have simulated the renderer response to the navigation request. |
227 // Do that now. | 227 // Do that now. |
228 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) | 228 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) |
229 SendBeginNavigationWithURL(url); | 229 SendBeforeUnloadACK(true); |
230 | 230 |
231 // We have already simulated the IO thread commit. Only the | 231 // We have already simulated the IO thread commit. Only the |
232 // DidCommitProvisionalLoad from the renderer is missing. | 232 // DidCommitProvisionalLoad from the renderer is missing. |
233 if (request->state() == NavigationRequest::RESPONSE_STARTED) | 233 if (request->state() == NavigationRequest::RESPONSE_STARTED) |
234 return; | 234 return; |
235 | 235 |
236 ASSERT_TRUE(request->state() == NavigationRequest::STARTED); | 236 ASSERT_TRUE(request->state() == NavigationRequest::STARTED); |
237 TestNavigationURLLoader* url_loader = | 237 TestNavigationURLLoader* url_loader = |
238 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); | 238 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); |
239 ASSERT_TRUE(url_loader); | 239 ASSERT_TRUE(url_loader); |
240 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 240 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
241 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); | 241 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); |
242 } | 242 } |
243 | 243 |
244 } // namespace content | 244 } // namespace content |
OLD | NEW |