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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Allow renderer-initiated reloads. Created 3 years, 11 months 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
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/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // Tests currently only navigate using main frame FrameNavigationEntries. 424 // Tests currently only navigate using main frame FrameNavigationEntries.
425 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get(); 425 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get();
426 if (IsBrowserSideNavigationEnabled()) { 426 if (IsBrowserSideNavigationEnabled()) {
427 NavigationControllerImpl* controller = 427 NavigationControllerImpl* controller =
428 static_cast<NavigationControllerImpl*>(manager->current_frame_host() 428 static_cast<NavigationControllerImpl*>(manager->current_frame_host()
429 ->frame_tree_node() 429 ->frame_tree_node()
430 ->navigator() 430 ->navigator()
431 ->GetController()); 431 ->GetController());
432 FrameMsg_Navigate_Type::Value navigate_type = 432 FrameMsg_Navigate_Type::Value navigate_type =
433 entry.restore_type() == RestoreType::NONE 433 entry.restore_type() == RestoreType::NONE
434 ? FrameMsg_Navigate_Type::NORMAL 434 ? FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT
435 : FrameMsg_Navigate_Type::RESTORE; 435 : FrameMsg_Navigate_Type::RESTORE;
436 std::unique_ptr<NavigationRequest> navigation_request = 436 std::unique_ptr<NavigationRequest> navigation_request =
437 NavigationRequest::CreateBrowserInitiated( 437 NavigationRequest::CreateBrowserInitiated(
438 manager->frame_tree_node_, frame_entry->url(), 438 manager->frame_tree_node_, frame_entry->url(),
439 frame_entry->referrer(), *frame_entry, entry, navigate_type, 439 frame_entry->referrer(), *frame_entry, entry, navigate_type,
440 PREVIEWS_UNSPECIFIED, false, false, base::TimeTicks::Now(), 440 PREVIEWS_UNSPECIFIED, false, false, base::TimeTicks::Now(),
441 controller); 441 controller);
442 442
443 // Simulates request creation that triggers the 1st internal call to 443 // Simulates request creation that triggers the 1st internal call to
444 // GetFrameHostForNavigation. 444 // GetFrameHostForNavigation.
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 const GURL kUrl("chrome://foo"); 2833 const GURL kUrl("chrome://foo");
2834 NavigationEntryImpl entry(nullptr /* instance */, kUrl, 2834 NavigationEntryImpl entry(nullptr /* instance */, kUrl,
2835 Referrer(), base::string16() /* title */, 2835 Referrer(), base::string16() /* title */,
2836 ui::PAGE_TRANSITION_TYPED, 2836 ui::PAGE_TRANSITION_TYPED,
2837 false /* is_renderer_init */); 2837 false /* is_renderer_init */);
2838 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get(); 2838 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get();
2839 std::unique_ptr<NavigationRequest> navigation_request = 2839 std::unique_ptr<NavigationRequest> navigation_request =
2840 NavigationRequest::CreateBrowserInitiated( 2840 NavigationRequest::CreateBrowserInitiated(
2841 contents()->GetFrameTree()->root(), frame_entry->url(), 2841 contents()->GetFrameTree()->root(), frame_entry->url(),
2842 frame_entry->referrer(), *frame_entry, entry, 2842 frame_entry->referrer(), *frame_entry, entry,
2843 FrameMsg_Navigate_Type::NORMAL, PREVIEWS_UNSPECIFIED, false, false, 2843 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
2844 base::TimeTicks::Now(), 2844 false, false, base::TimeTicks::Now(),
2845 static_cast<NavigationControllerImpl*>(&controller())); 2845 static_cast<NavigationControllerImpl*>(&controller()));
2846 manager->DidCreateNavigationRequest(navigation_request.get()); 2846 manager->DidCreateNavigationRequest(navigation_request.get());
2847 2847
2848 // As the initial RenderFrame was not live, the new RenderFrameHost should be 2848 // As the initial RenderFrame was not live, the new RenderFrameHost should be
2849 // made as active/current immediately along with its WebUI at request time. 2849 // made as active/current immediately along with its WebUI at request time.
2850 RenderFrameHostImpl* host = manager->current_frame_host(); 2850 RenderFrameHostImpl* host = manager->current_frame_host();
2851 ASSERT_TRUE(host); 2851 ASSERT_TRUE(host);
2852 EXPECT_NE(host, initial_host); 2852 EXPECT_NE(host, initial_host);
2853 EXPECT_TRUE(host->IsRenderFrameLive()); 2853 EXPECT_TRUE(host->IsRenderFrameLive());
2854 WebUIImpl* web_ui = host->web_ui(); 2854 WebUIImpl* web_ui = host->web_ui();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2894 const GURL kUrl("chrome://foo/bar"); 2894 const GURL kUrl("chrome://foo/bar");
2895 NavigationEntryImpl entry(nullptr /* instance */, kUrl, 2895 NavigationEntryImpl entry(nullptr /* instance */, kUrl,
2896 Referrer(), base::string16() /* title */, 2896 Referrer(), base::string16() /* title */,
2897 ui::PAGE_TRANSITION_TYPED, 2897 ui::PAGE_TRANSITION_TYPED,
2898 false /* is_renderer_init */); 2898 false /* is_renderer_init */);
2899 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get(); 2899 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get();
2900 std::unique_ptr<NavigationRequest> navigation_request = 2900 std::unique_ptr<NavigationRequest> navigation_request =
2901 NavigationRequest::CreateBrowserInitiated( 2901 NavigationRequest::CreateBrowserInitiated(
2902 contents()->GetFrameTree()->root(), frame_entry->url(), 2902 contents()->GetFrameTree()->root(), frame_entry->url(),
2903 frame_entry->referrer(), *frame_entry, entry, 2903 frame_entry->referrer(), *frame_entry, entry,
2904 FrameMsg_Navigate_Type::NORMAL, PREVIEWS_UNSPECIFIED, false, false, 2904 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
2905 base::TimeTicks::Now(), 2905 false, false, base::TimeTicks::Now(),
2906 static_cast<NavigationControllerImpl*>(&controller())); 2906 static_cast<NavigationControllerImpl*>(&controller()));
2907 manager->DidCreateNavigationRequest(navigation_request.get()); 2907 manager->DidCreateNavigationRequest(navigation_request.get());
2908 2908
2909 // The current WebUI should still be in place and the pending WebUI should be 2909 // The current WebUI should still be in place and the pending WebUI should be
2910 // set to reuse it. 2910 // set to reuse it.
2911 EXPECT_EQ(web_ui, manager->GetNavigatingWebUI()); 2911 EXPECT_EQ(web_ui, manager->GetNavigatingWebUI());
2912 EXPECT_EQ(web_ui, host->web_ui()); 2912 EXPECT_EQ(web_ui, host->web_ui());
2913 EXPECT_EQ(web_ui, host->pending_web_ui()); 2913 EXPECT_EQ(web_ui, host->pending_web_ui());
2914 EXPECT_FALSE(GetPendingFrameHost(manager)); 2914 EXPECT_FALSE(GetPendingFrameHost(manager));
2915 2915
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 const GURL kUrl("chrome://bar"); 2952 const GURL kUrl("chrome://bar");
2953 NavigationEntryImpl entry(nullptr /* instance */, kUrl, 2953 NavigationEntryImpl entry(nullptr /* instance */, kUrl,
2954 Referrer(), base::string16() /* title */, 2954 Referrer(), base::string16() /* title */,
2955 ui::PAGE_TRANSITION_TYPED, 2955 ui::PAGE_TRANSITION_TYPED,
2956 false /* is_renderer_init */); 2956 false /* is_renderer_init */);
2957 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get(); 2957 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get();
2958 std::unique_ptr<NavigationRequest> navigation_request = 2958 std::unique_ptr<NavigationRequest> navigation_request =
2959 NavigationRequest::CreateBrowserInitiated( 2959 NavigationRequest::CreateBrowserInitiated(
2960 contents()->GetFrameTree()->root(), frame_entry->url(), 2960 contents()->GetFrameTree()->root(), frame_entry->url(),
2961 frame_entry->referrer(), *frame_entry, entry, 2961 frame_entry->referrer(), *frame_entry, entry,
2962 FrameMsg_Navigate_Type::NORMAL, PREVIEWS_UNSPECIFIED, false, false, 2962 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
2963 base::TimeTicks::Now(), 2963 false, false, base::TimeTicks::Now(),
2964 static_cast<NavigationControllerImpl*>(&controller())); 2964 static_cast<NavigationControllerImpl*>(&controller()));
2965 manager->DidCreateNavigationRequest(navigation_request.get()); 2965 manager->DidCreateNavigationRequest(navigation_request.get());
2966 2966
2967 // The current WebUI should still be in place and there should be a new 2967 // The current WebUI should still be in place and there should be a new
2968 // active WebUI instance in the speculative RenderFrameHost. 2968 // active WebUI instance in the speculative RenderFrameHost.
2969 EXPECT_TRUE(manager->current_frame_host()->web_ui()); 2969 EXPECT_TRUE(manager->current_frame_host()->web_ui());
2970 EXPECT_FALSE(manager->current_frame_host()->pending_web_ui()); 2970 EXPECT_FALSE(manager->current_frame_host()->pending_web_ui());
2971 RenderFrameHostImpl* speculative_host = GetPendingFrameHost(manager); 2971 RenderFrameHostImpl* speculative_host = GetPendingFrameHost(manager);
2972 EXPECT_TRUE(speculative_host); 2972 EXPECT_TRUE(speculative_host);
2973 WebUIImpl* next_web_ui = manager->GetNavigatingWebUI(); 2973 WebUIImpl* next_web_ui = manager->GetNavigatingWebUI();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3149 ASSERT_FALSE(delete_observer.deleted()); 3149 ASSERT_FALSE(delete_observer.deleted());
3150 EXPECT_FALSE(initial_rfh->is_active()); 3150 EXPECT_FALSE(initial_rfh->is_active());
3151 3151
3152 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not 3152 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not
3153 // create a NavigationHandle. 3153 // create a NavigationHandle.
3154 initial_rfh->SimulateNavigationStart(kUrl3); 3154 initial_rfh->SimulateNavigationStart(kUrl3);
3155 EXPECT_FALSE(initial_rfh->navigation_handle()); 3155 EXPECT_FALSE(initial_rfh->navigation_handle());
3156 } 3156 }
3157 3157
3158 } // namespace content 3158 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698