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/guid.h" | 7 #include "base/guid.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_handle_impl.h" | 9 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 params.should_replace_current_entry = should_replace_entry; | 318 params.should_replace_current_entry = should_replace_entry; |
| 319 params.gesture = NavigationGestureUser; | 319 params.gesture = NavigationGestureUser; |
| 320 params.contents_mime_type = contents_mime_type_; | 320 params.contents_mime_type = contents_mime_type_; |
| 321 params.method = "GET"; | 321 params.method = "GET"; |
| 322 params.http_status_code = response_code; | 322 params.http_status_code = response_code; |
| 323 params.socket_address.set_host("2001:db8::1"); | 323 params.socket_address.set_host("2001:db8::1"); |
| 324 params.socket_address.set_port(80); | 324 params.socket_address.set_port(80); |
| 325 params.history_list_was_cleared = simulate_history_list_was_cleared_; | 325 params.history_list_was_cleared = simulate_history_list_was_cleared_; |
| 326 params.original_request_url = url_copy; | 326 params.original_request_url = url_copy; |
| 327 | 327 |
| 328 // Simulate Blink assigning an item sequence number to the navigation. | 328 // Simulate Blink assigning an item and document sequence number to the |
| 329 // navigation. | |
| 329 params.item_sequence_number = base::Time::Now().ToDoubleT() * 1000000; | 330 params.item_sequence_number = base::Time::Now().ToDoubleT() * 1000000; |
| 331 static int s_document_sequence_number = 0; | |
| 332 params.document_sequence_number = ++s_document_sequence_number; | |
|
Charlie Reis
2016/11/03 21:05:47
This is probably ok, but you could set it to the i
jam
2016/11/03 21:12:20
Thanks, sure.
| |
| 330 | 333 |
| 331 // When the user hits enter in the Omnibox without changing the URL, Blink | 334 // When the user hits enter in the Omnibox without changing the URL, Blink |
| 332 // behaves similarly to a reload and does not change the item and document | 335 // behaves similarly to a reload and does not change the item and document |
| 333 // sequence numbers. Simulate this behavior here too. | 336 // sequence numbers. Simulate this behavior here too. |
| 334 if (transition == ui::PAGE_TRANSITION_TYPED) { | 337 if (transition == ui::PAGE_TRANSITION_TYPED) { |
| 335 const NavigationEntryImpl* entry = | 338 const NavigationEntryImpl* entry = |
| 336 static_cast<NavigationEntryImpl*>(frame_tree_node() | 339 static_cast<NavigationEntryImpl*>(frame_tree_node() |
| 337 ->navigator() | 340 ->navigator() |
| 338 ->GetController() | 341 ->GetController() |
| 339 ->GetLastCommittedEntry()); | 342 ->GetLastCommittedEntry()); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 361 // same page is not robust, as it will not handle pushState type navigation. | 364 // same page is not robust, as it will not handle pushState type navigation. |
| 362 // Do not use elsewhere! | 365 // Do not use elsewhere! |
| 363 params.was_within_same_page = | 366 params.was_within_same_page = |
| 364 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && | 367 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && |
| 365 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) && | 368 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) && |
| 366 (GetLastCommittedURL().is_valid() && !last_commit_was_error_page_ && | 369 (GetLastCommittedURL().is_valid() && !last_commit_was_error_page_ && |
| 367 url_copy.ReplaceComponents(replacements) == | 370 url_copy.ReplaceComponents(replacements) == |
| 368 GetLastCommittedURL().ReplaceComponents(replacements)); | 371 GetLastCommittedURL().ReplaceComponents(replacements)); |
| 369 | 372 |
| 370 params.page_state = | 373 params.page_state = |
| 371 PageState::CreateForTesting(url_copy, false, nullptr, nullptr); | 374 PageState::CreateForTestingWithSequenceNumbers( |
| 375 url_copy, params.item_sequence_number, | |
| 376 params.document_sequence_number); | |
| 372 | 377 |
| 373 if (!callback.is_null()) | 378 if (!callback.is_null()) |
| 374 callback.Run(¶ms); | 379 callback.Run(¶ms); |
| 375 | 380 |
| 376 SendNavigateWithParams(¶ms); | 381 SendNavigateWithParams(¶ms); |
| 377 } | 382 } |
| 378 | 383 |
| 379 void TestRenderFrameHost::SendNavigateWithParams( | 384 void TestRenderFrameHost::SendNavigateWithParams( |
| 380 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { | 385 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { |
| 381 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params); | 386 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at | 482 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at |
| 478 // this point. | 483 // this point. |
| 479 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) | 484 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) |
| 480 return; | 485 return; |
| 481 navigation_handle()->CallWillStartRequestForTesting( | 486 navigation_handle()->CallWillStartRequestForTesting( |
| 482 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), | 487 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), |
| 483 true /* user_gesture */, transition, false /* is_external_protocol */); | 488 true /* user_gesture */, transition, false /* is_external_protocol */); |
| 484 } | 489 } |
| 485 | 490 |
| 486 } // namespace content | 491 } // namespace content |
| OLD | NEW |