Chromium Code Reviews| 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" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, | 192 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, |
| 193 has_user_gesture); | 193 has_user_gesture); |
| 194 CommonNavigationParams common_params; | 194 CommonNavigationParams common_params; |
| 195 common_params.url = url; | 195 common_params.url = url; |
| 196 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); | 196 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); |
| 197 common_params.transition = ui::PAGE_TRANSITION_LINK; | 197 common_params.transition = ui::PAGE_TRANSITION_LINK; |
| 198 OnBeginNavigation(common_params, begin_params, | 198 OnBeginNavigation(common_params, begin_params, |
| 199 scoped_refptr<ResourceRequestBody>()); | 199 scoped_refptr<ResourceRequestBody>()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void TestRenderFrameHost::RendererRequestIfPlzNavigate(const GURL& url, | |
| 203 bool has_user_gesture) { | |
| 204 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 205 switches::kEnableBrowserSideNavigation)) { | |
| 206 SendBeginNavigationWithURL(url, has_user_gesture); | |
| 207 } | |
| 208 } | |
| 209 | |
| 202 void TestRenderFrameHost::DidDisownOpener() { | 210 void TestRenderFrameHost::DidDisownOpener() { |
| 203 OnDidDisownOpener(); | 211 OnDidDisownOpener(); |
| 204 } | 212 } |
| 205 | 213 |
| 206 void TestRenderFrameHost::PrepareForCommit(const GURL& url) { | 214 void TestRenderFrameHost::PrepareForCommit(const GURL& url) { |
|
clamy
2015/02/23 10:52:34
Now that url is not used in that function, it shou
carlosk
2015/03/04 19:42:40
Change was moved to another CL.
| |
| 207 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 215 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 208 switches::kEnableBrowserSideNavigation)) { | 216 switches::kEnableBrowserSideNavigation)) { |
| 209 SendBeforeUnloadACK(true); | 217 SendBeforeUnloadACK(true); |
| 210 return; | 218 return; |
| 211 } | 219 } |
| 212 | 220 |
| 213 // PlzNavigate | 221 // PlzNavigate |
| 214 // Simulate the network stack commit without any redirects. | 222 // Simulate the network stack commit without any redirects. |
| 215 NavigationRequest* request = | 223 NavigationRequest* request = |
| 216 static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) | 224 static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) |
| 217 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); | 225 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); |
| 218 | 226 CHECK(request && request->common_params().url == url) |
| 219 // We are simulating a renderer-initiated user-initiated navigation. | 227 << " Request URL: " |
| 220 if (!request) { | 228 << (request ? request->common_params().url.possibly_invalid_spec() |
| 221 SendBeginNavigationWithURL(url, true); | 229 : "<NO REQUEST>") << ", commit URL: " << url; |
| 222 request = static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) | |
| 223 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); | |
| 224 } | |
| 225 ASSERT_TRUE(request); | |
| 226 | 230 |
| 227 // We may not have simulated the renderer response to the navigation request. | 231 // We may not have simulated the renderer response to the navigation request. |
| 228 // Do that now. | 232 // Do that now. |
| 229 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) | 233 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) |
| 230 SendBeforeUnloadACK(true); | 234 SendBeforeUnloadACK(true); |
| 231 | 235 |
| 232 // We have already simulated the IO thread commit. Only the | 236 // We have already simulated the IO thread commit. Only the |
| 233 // DidCommitProvisionalLoad from the renderer is missing. | 237 // DidCommitProvisionalLoad from the renderer is missing. |
| 234 if (request->state() == NavigationRequest::RESPONSE_STARTED) | 238 if (request->state() == NavigationRequest::RESPONSE_STARTED) |
| 235 return; | 239 return; |
| 236 | 240 |
| 237 ASSERT_TRUE(request->state() == NavigationRequest::STARTED); | 241 CHECK(request->state() == NavigationRequest::STARTED); |
| 238 TestNavigationURLLoader* url_loader = | 242 TestNavigationURLLoader* url_loader = |
| 239 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); | 243 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); |
| 240 ASSERT_TRUE(url_loader); | 244 CHECK(url_loader); |
|
carlosk
2015/02/20 19:16:51
These two replacements with CHECK are a bugfix as
| |
| 241 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 245 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
| 242 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); | 246 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); |
| 243 } | 247 } |
| 244 | 248 |
| 245 void TestRenderFrameHost::SendBeforeUnloadHandlersPresent(bool present) { | 249 void TestRenderFrameHost::SendBeforeUnloadHandlersPresent(bool present) { |
| 246 OnBeforeUnloadHandlersPresent(present); | 250 OnBeforeUnloadHandlersPresent(present); |
| 247 } | 251 } |
| 248 | 252 |
| 249 void TestRenderFrameHost::SendUnloadHandlersPresent(bool present) { | 253 void TestRenderFrameHost::SendUnloadHandlersPresent(bool present) { |
| 250 OnUnloadHandlersPresent(present); | 254 OnUnloadHandlersPresent(present); |
| 251 } | 255 } |
| 252 | 256 |
| 253 } // namespace content | 257 } // namespace content |
| OLD | NEW |