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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 params.method = "GET"; | 309 params.method = "GET"; |
310 params.http_status_code = response_code; | 310 params.http_status_code = response_code; |
311 params.socket_address.set_host("2001:db8::1"); | 311 params.socket_address.set_host("2001:db8::1"); |
312 params.socket_address.set_port(80); | 312 params.socket_address.set_port(80); |
313 params.history_list_was_cleared = simulate_history_list_was_cleared_; | 313 params.history_list_was_cleared = simulate_history_list_was_cleared_; |
314 params.original_request_url = url_copy; | 314 params.original_request_url = url_copy; |
315 | 315 |
316 // Simulate Blink assigning an item sequence number to the navigation. | 316 // Simulate Blink assigning an item sequence number to the navigation. |
317 params.item_sequence_number = base::Time::Now().ToDoubleT() * 1000000; | 317 params.item_sequence_number = base::Time::Now().ToDoubleT() * 1000000; |
318 | 318 |
319 // When the user hits enter in the Omnibox without changing the URL, Blink | |
320 // behaves similarly to a reload and does not change the item and document | |
321 // sequence numbers. Simulate this behavior here too. | |
322 // TODO(nasko): If/when NAVIGATION_TYPE_SAME_PAGE is removed from the | |
323 // codebase, ensure this code is updated to account for it. | |
Charlie Reis
2016/08/08 22:06:15
I don't think we actually need the TODO, since Bli
nasko
2016/08/08 22:39:47
Acknowledged.
| |
324 if (transition == ui::PAGE_TRANSITION_TYPED) { | |
325 const NavigationEntryImpl* entry = | |
326 static_cast<NavigationEntryImpl*>(frame_tree_node() | |
327 ->navigator() | |
328 ->GetController() | |
329 ->GetLastCommittedEntry()); | |
330 if (entry && entry->GetURL() == url) { | |
331 FrameNavigationEntry* frame_entry = | |
332 entry->GetFrameEntry(frame_tree_node()); | |
333 if (frame_entry) { | |
334 params.item_sequence_number = frame_entry->item_sequence_number(); | |
335 params.document_sequence_number = | |
336 frame_entry->document_sequence_number(); | |
337 } | |
338 } | |
339 } | |
340 | |
319 // In most cases, the origin will match the URL's origin. Tests that need to | 341 // In most cases, the origin will match the URL's origin. Tests that need to |
320 // check corner cases (like about:blank) should specify the origin param | 342 // check corner cases (like about:blank) should specify the origin param |
321 // manually. | 343 // manually. |
322 url::Origin origin(url_copy); | 344 url::Origin origin(url_copy); |
323 params.origin = origin; | 345 params.origin = origin; |
324 | 346 |
325 url::Replacements<char> replacements; | 347 url::Replacements<char> replacements; |
326 replacements.ClearRef(); | 348 replacements.ClearRef(); |
327 params.was_within_same_page = | 349 params.was_within_same_page = |
328 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && | 350 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 void TestRenderFrameHost::SimulateWillStartRequest( | 478 void TestRenderFrameHost::SimulateWillStartRequest( |
457 ui::PageTransition transition) { | 479 ui::PageTransition transition) { |
458 if (!navigation_handle()) | 480 if (!navigation_handle()) |
459 return; | 481 return; |
460 navigation_handle()->CallWillStartRequestForTesting( | 482 navigation_handle()->CallWillStartRequestForTesting( |
461 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), | 483 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), |
462 true /* user_gesture */, transition, false /* is_external_protocol */); | 484 true /* user_gesture */, transition, false /* is_external_protocol */); |
463 } | 485 } |
464 | 486 |
465 } // namespace content | 487 } // namespace content |
OLD | NEW |