| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_view_host.h" | 5 #include "content/test/test_render_view_host.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 8 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 9 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 9 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
| 11 #include "content/common/dom_storage/dom_storage_types.h" | 11 #include "content/common/dom_storage/dom_storage_types.h" |
| 12 #include "content/common/frame_messages.h" |
| 12 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
| 13 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
| 15 #include "content/public/browser/storage_partition.h" | 16 #include "content/public/browser/storage_partition.h" |
| 16 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
| 17 #include "content/public/common/page_state.h" | 18 #include "content/public/common/page_state.h" |
| 18 #include "content/test/test_backing_store.h" | 19 #include "content/test/test_backing_store.h" |
| 19 #include "content/test/test_web_contents.h" | 20 #include "content/test/test_web_contents.h" |
| 20 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 22 #include "webkit/common/webpreferences.h" | 23 #include "webkit/common/webpreferences.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 const int64 kFrameId = 13UL; | 29 const int64 kFrameId = 13UL; |
| 29 | 30 |
| 30 } // namespace | 31 } // namespace |
| 31 | 32 |
| 32 | 33 |
| 33 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, | 34 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, |
| 34 int page_id, | 35 int page_id, |
| 35 const GURL& url, | 36 const GURL& url, |
| 36 PageTransition transition) { | 37 PageTransition transition) { |
| 37 params->page_id = page_id; | 38 params->page_id = page_id; |
| 38 params->url = url; | 39 params->url = url; |
| 39 params->referrer = Referrer(); | 40 params->referrer = Referrer(); |
| 40 params->transition = transition; | 41 params->transition = transition; |
| 41 params->redirects = std::vector<GURL>(); | 42 params->redirects = std::vector<GURL>(); |
| 42 params->should_update_history = false; | 43 params->should_update_history = false; |
| 43 params->searchable_form_url = GURL(); | 44 params->searchable_form_url = GURL(); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 original_request_url, 200, 0); | 296 original_request_url, 200, 0); |
| 296 } | 297 } |
| 297 | 298 |
| 298 void TestRenderViewHost::SendNavigateWithFile( | 299 void TestRenderViewHost::SendNavigateWithFile( |
| 299 int page_id, const GURL& url, const base::FilePath& file_path) { | 300 int page_id, const GURL& url, const base::FilePath& file_path) { |
| 300 SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, | 301 SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, |
| 301 url, 200, &file_path); | 302 url, 200, &file_path); |
| 302 } | 303 } |
| 303 | 304 |
| 304 void TestRenderViewHost::SendNavigateWithParams( | 305 void TestRenderViewHost::SendNavigateWithParams( |
| 305 ViewHostMsg_FrameNavigate_Params* params) { | 306 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { |
| 306 params->frame_id = kFrameId; | 307 params->frame_id = kFrameId; |
| 307 ViewHostMsg_FrameNavigate msg(1, *params); | 308 FrameHostMsg_DidCommitProvisionalLoad msg(1, *params); |
| 308 OnNavigate(msg); | 309 main_render_frame_host()->OnNavigate(msg); |
| 309 } | 310 } |
| 310 | 311 |
| 311 void TestRenderViewHost::SendNavigateWithTransitionAndResponseCode( | 312 void TestRenderViewHost::SendNavigateWithTransitionAndResponseCode( |
| 312 int page_id, const GURL& url, PageTransition transition, | 313 int page_id, const GURL& url, PageTransition transition, |
| 313 int response_code) { | 314 int response_code) { |
| 314 // DidStartProvisionalLoad may delete the pending entry that holds |url|, | 315 // DidStartProvisionalLoad may delete the pending entry that holds |url|, |
| 315 // so we keep a copy of it to use in SendNavigateWithParameters. | 316 // so we keep a copy of it to use in SendNavigateWithParameters. |
| 316 GURL url_copy(url); | 317 GURL url_copy(url); |
| 317 main_render_frame_host()->OnDidStartProvisionalLoadForFrame( | 318 main_render_frame_host()->OnDidStartProvisionalLoadForFrame( |
| 318 kFrameId, -1, true, url_copy); | 319 kFrameId, -1, true, url_copy); |
| 319 SendNavigateWithParameters(page_id, url_copy, transition, url_copy, | 320 SendNavigateWithParameters(page_id, url_copy, transition, url_copy, |
| 320 response_code, 0); | 321 response_code, 0); |
| 321 } | 322 } |
| 322 | 323 |
| 323 void TestRenderViewHost::SendNavigateWithParameters( | 324 void TestRenderViewHost::SendNavigateWithParameters( |
| 324 int page_id, const GURL& url, PageTransition transition, | 325 int page_id, const GURL& url, PageTransition transition, |
| 325 const GURL& original_request_url, int response_code, | 326 const GURL& original_request_url, int response_code, |
| 326 const base::FilePath* file_path_for_history_item) { | 327 const base::FilePath* file_path_for_history_item) { |
| 327 ViewHostMsg_FrameNavigate_Params params; | 328 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 328 params.page_id = page_id; | 329 params.page_id = page_id; |
| 329 params.frame_id = kFrameId; | 330 params.frame_id = kFrameId; |
| 330 params.url = url; | 331 params.url = url; |
| 331 params.referrer = Referrer(); | 332 params.referrer = Referrer(); |
| 332 params.transition = transition; | 333 params.transition = transition; |
| 333 params.redirects = std::vector<GURL>(); | 334 params.redirects = std::vector<GURL>(); |
| 334 params.should_update_history = true; | 335 params.should_update_history = true; |
| 335 params.searchable_form_url = GURL(); | 336 params.searchable_form_url = GURL(); |
| 336 params.searchable_form_encoding = std::string(); | 337 params.searchable_form_encoding = std::string(); |
| 337 params.security_info = std::string(); | 338 params.security_info = std::string(); |
| 338 params.gesture = NavigationGestureUser; | 339 params.gesture = NavigationGestureUser; |
| 339 params.contents_mime_type = contents_mime_type_; | 340 params.contents_mime_type = contents_mime_type_; |
| 340 params.is_post = false; | 341 params.is_post = false; |
| 341 params.was_within_same_page = false; | 342 params.was_within_same_page = false; |
| 342 params.http_status_code = response_code; | 343 params.http_status_code = response_code; |
| 343 params.socket_address.set_host("2001:db8::1"); | 344 params.socket_address.set_host("2001:db8::1"); |
| 344 params.socket_address.set_port(80); | 345 params.socket_address.set_port(80); |
| 345 params.was_fetched_via_proxy = simulate_fetch_via_proxy_; | 346 params.was_fetched_via_proxy = simulate_fetch_via_proxy_; |
| 346 params.history_list_was_cleared = simulate_history_list_was_cleared_; | 347 params.history_list_was_cleared = simulate_history_list_was_cleared_; |
| 347 params.original_request_url = original_request_url; | 348 params.original_request_url = original_request_url; |
| 348 | 349 |
| 349 params.page_state = PageState::CreateForTesting( | 350 params.page_state = PageState::CreateForTesting( |
| 350 url, | 351 url, |
| 351 false, | 352 false, |
| 352 file_path_for_history_item ? "data" : NULL, | 353 file_path_for_history_item ? "data" : NULL, |
| 353 file_path_for_history_item); | 354 file_path_for_history_item); |
| 354 | 355 |
| 355 ViewHostMsg_FrameNavigate msg(1, params); | 356 FrameHostMsg_DidCommitProvisionalLoad msg(1, params); |
| 356 OnNavigate(msg); | 357 main_render_frame_host()->OnNavigate(msg); |
| 357 } | 358 } |
| 358 | 359 |
| 359 void TestRenderViewHost::SendShouldCloseACK(bool proceed) { | 360 void TestRenderViewHost::SendShouldCloseACK(bool proceed) { |
| 360 base::TimeTicks now = base::TimeTicks::Now(); | 361 base::TimeTicks now = base::TimeTicks::Now(); |
| 361 OnShouldCloseACK(proceed, now, now); | 362 OnShouldCloseACK(proceed, now, now); |
| 362 } | 363 } |
| 363 | 364 |
| 364 void TestRenderViewHost::SetContentsMimeType(const std::string& mime_type) { | 365 void TestRenderViewHost::SetContentsMimeType(const std::string& mime_type) { |
| 365 contents_mime_type_ = mime_type; | 366 contents_mime_type_ = mime_type; |
| 366 } | 367 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 428 |
| 428 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { | 429 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { |
| 429 return static_cast<TestRenderFrameHost*>(main_rfh()); | 430 return static_cast<TestRenderFrameHost*>(main_rfh()); |
| 430 } | 431 } |
| 431 | 432 |
| 432 TestWebContents* RenderViewHostImplTestHarness::contents() { | 433 TestWebContents* RenderViewHostImplTestHarness::contents() { |
| 433 return static_cast<TestWebContents*>(web_contents()); | 434 return static_cast<TestWebContents*>(web_contents()); |
| 434 } | 435 } |
| 435 | 436 |
| 436 } // namespace content | 437 } // namespace content |
| OLD | NEW |