Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: content/test/test_render_frame_host.cc

Issue 2477623002: Don't fire onbeforeunload for same document history navigations with PlzNavigate. (Closed)
Patch Set: review comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 params.document_sequence_number = params.item_sequence_number + 1;
330 332
331 // When the user hits enter in the Omnibox without changing the URL, Blink 333 // 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 334 // behaves similarly to a reload and does not change the item and document
333 // sequence numbers. Simulate this behavior here too. 335 // sequence numbers. Simulate this behavior here too.
334 if (transition == ui::PAGE_TRANSITION_TYPED) { 336 if (transition == ui::PAGE_TRANSITION_TYPED) {
335 const NavigationEntryImpl* entry = 337 const NavigationEntryImpl* entry =
336 static_cast<NavigationEntryImpl*>(frame_tree_node() 338 static_cast<NavigationEntryImpl*>(frame_tree_node()
337 ->navigator() 339 ->navigator()
338 ->GetController() 340 ->GetController()
339 ->GetLastCommittedEntry()); 341 ->GetLastCommittedEntry());
(...skipping 21 matching lines...) Expand all
361 // same page is not robust, as it will not handle pushState type navigation. 363 // same page is not robust, as it will not handle pushState type navigation.
362 // Do not use elsewhere! 364 // Do not use elsewhere!
363 params.was_within_same_page = 365 params.was_within_same_page =
364 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) && 366 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) &&
365 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) && 367 !ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) &&
366 (GetLastCommittedURL().is_valid() && !last_commit_was_error_page_ && 368 (GetLastCommittedURL().is_valid() && !last_commit_was_error_page_ &&
367 url_copy.ReplaceComponents(replacements) == 369 url_copy.ReplaceComponents(replacements) ==
368 GetLastCommittedURL().ReplaceComponents(replacements)); 370 GetLastCommittedURL().ReplaceComponents(replacements));
369 371
370 params.page_state = 372 params.page_state =
371 PageState::CreateForTesting(url_copy, false, nullptr, nullptr); 373 PageState::CreateForTestingWithSequenceNumbers(
374 url_copy, params.item_sequence_number,
375 params.document_sequence_number);
372 376
373 if (!callback.is_null()) 377 if (!callback.is_null())
374 callback.Run(&params); 378 callback.Run(&params);
375 379
376 SendNavigateWithParams(&params); 380 SendNavigateWithParams(&params);
377 } 381 }
378 382
379 void TestRenderFrameHost::SendNavigateWithParams( 383 void TestRenderFrameHost::SendNavigateWithParams(
380 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { 384 FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
381 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params); 385 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), *params);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at 481 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at
478 // this point. 482 // this point.
479 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) 483 if (!navigation_handle() || IsBrowserSideNavigationEnabled())
480 return; 484 return;
481 navigation_handle()->CallWillStartRequestForTesting( 485 navigation_handle()->CallWillStartRequestForTesting(
482 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), 486 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault),
483 true /* user_gesture */, transition, false /* is_external_protocol */); 487 true /* user_gesture */, transition, false /* is_external_protocol */);
484 } 488 }
485 489
486 } // namespace content 490 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698