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

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: Rebase. Created 3 years, 10 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 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 const GURL kUrl("chrome://foo"); 2830 const GURL kUrl("chrome://foo");
2831 NavigationEntryImpl entry(nullptr /* instance */, kUrl, 2831 NavigationEntryImpl entry(nullptr /* instance */, kUrl,
2832 Referrer(), base::string16() /* title */, 2832 Referrer(), base::string16() /* title */,
2833 ui::PAGE_TRANSITION_TYPED, 2833 ui::PAGE_TRANSITION_TYPED,
2834 false /* is_renderer_init */); 2834 false /* is_renderer_init */);
2835 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get(); 2835 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get();
2836 std::unique_ptr<NavigationRequest> navigation_request = 2836 std::unique_ptr<NavigationRequest> navigation_request =
2837 NavigationRequest::CreateBrowserInitiated( 2837 NavigationRequest::CreateBrowserInitiated(
2838 contents()->GetFrameTree()->root(), frame_entry->url(), 2838 contents()->GetFrameTree()->root(), frame_entry->url(),
2839 frame_entry->referrer(), *frame_entry, entry, 2839 frame_entry->referrer(), *frame_entry, entry,
2840 FrameMsg_Navigate_Type::NORMAL, PREVIEWS_UNSPECIFIED, false, false, 2840 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
2841 base::TimeTicks::Now(), 2841 false, false, base::TimeTicks::Now(),
2842 static_cast<NavigationControllerImpl*>(&controller())); 2842 static_cast<NavigationControllerImpl*>(&controller()));
2843 manager->DidCreateNavigationRequest(navigation_request.get()); 2843 manager->DidCreateNavigationRequest(navigation_request.get());
2844 2844
2845 // As the initial RenderFrame was not live, the new RenderFrameHost should be 2845 // As the initial RenderFrame was not live, the new RenderFrameHost should be
2846 // made as active/current immediately along with its WebUI at request time. 2846 // made as active/current immediately along with its WebUI at request time.
2847 RenderFrameHostImpl* host = manager->current_frame_host(); 2847 RenderFrameHostImpl* host = manager->current_frame_host();
2848 ASSERT_TRUE(host); 2848 ASSERT_TRUE(host);
2849 EXPECT_NE(host, initial_host); 2849 EXPECT_NE(host, initial_host);
2850 EXPECT_TRUE(host->IsRenderFrameLive()); 2850 EXPECT_TRUE(host->IsRenderFrameLive());
2851 WebUIImpl* web_ui = host->web_ui(); 2851 WebUIImpl* web_ui = host->web_ui();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 const GURL kUrl("chrome://foo/bar"); 2891 const GURL kUrl("chrome://foo/bar");
2892 NavigationEntryImpl entry(nullptr /* instance */, kUrl, 2892 NavigationEntryImpl entry(nullptr /* instance */, kUrl,
2893 Referrer(), base::string16() /* title */, 2893 Referrer(), base::string16() /* title */,
2894 ui::PAGE_TRANSITION_TYPED, 2894 ui::PAGE_TRANSITION_TYPED,
2895 false /* is_renderer_init */); 2895 false /* is_renderer_init */);
2896 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get(); 2896 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get();
2897 std::unique_ptr<NavigationRequest> navigation_request = 2897 std::unique_ptr<NavigationRequest> navigation_request =
2898 NavigationRequest::CreateBrowserInitiated( 2898 NavigationRequest::CreateBrowserInitiated(
2899 contents()->GetFrameTree()->root(), frame_entry->url(), 2899 contents()->GetFrameTree()->root(), frame_entry->url(),
2900 frame_entry->referrer(), *frame_entry, entry, 2900 frame_entry->referrer(), *frame_entry, entry,
2901 FrameMsg_Navigate_Type::NORMAL, PREVIEWS_UNSPECIFIED, false, false, 2901 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
2902 base::TimeTicks::Now(), 2902 false, false, base::TimeTicks::Now(),
2903 static_cast<NavigationControllerImpl*>(&controller())); 2903 static_cast<NavigationControllerImpl*>(&controller()));
2904 manager->DidCreateNavigationRequest(navigation_request.get()); 2904 manager->DidCreateNavigationRequest(navigation_request.get());
2905 2905
2906 // The current WebUI should still be in place and the pending WebUI should be 2906 // The current WebUI should still be in place and the pending WebUI should be
2907 // set to reuse it. 2907 // set to reuse it.
2908 EXPECT_EQ(web_ui, manager->GetNavigatingWebUI()); 2908 EXPECT_EQ(web_ui, manager->GetNavigatingWebUI());
2909 EXPECT_EQ(web_ui, host->web_ui()); 2909 EXPECT_EQ(web_ui, host->web_ui());
2910 EXPECT_EQ(web_ui, host->pending_web_ui()); 2910 EXPECT_EQ(web_ui, host->pending_web_ui());
2911 EXPECT_FALSE(GetPendingFrameHost(manager)); 2911 EXPECT_FALSE(GetPendingFrameHost(manager));
2912 2912
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 const GURL kUrl("chrome://bar"); 2949 const GURL kUrl("chrome://bar");
2950 NavigationEntryImpl entry(nullptr /* instance */, kUrl, 2950 NavigationEntryImpl entry(nullptr /* instance */, kUrl,
2951 Referrer(), base::string16() /* title */, 2951 Referrer(), base::string16() /* title */,
2952 ui::PAGE_TRANSITION_TYPED, 2952 ui::PAGE_TRANSITION_TYPED,
2953 false /* is_renderer_init */); 2953 false /* is_renderer_init */);
2954 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get(); 2954 FrameNavigationEntry* frame_entry = entry.root_node()->frame_entry.get();
2955 std::unique_ptr<NavigationRequest> navigation_request = 2955 std::unique_ptr<NavigationRequest> navigation_request =
2956 NavigationRequest::CreateBrowserInitiated( 2956 NavigationRequest::CreateBrowserInitiated(
2957 contents()->GetFrameTree()->root(), frame_entry->url(), 2957 contents()->GetFrameTree()->root(), frame_entry->url(),
2958 frame_entry->referrer(), *frame_entry, entry, 2958 frame_entry->referrer(), *frame_entry, entry,
2959 FrameMsg_Navigate_Type::NORMAL, PREVIEWS_UNSPECIFIED, false, false, 2959 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, PREVIEWS_UNSPECIFIED,
2960 base::TimeTicks::Now(), 2960 false, false, base::TimeTicks::Now(),
2961 static_cast<NavigationControllerImpl*>(&controller())); 2961 static_cast<NavigationControllerImpl*>(&controller()));
2962 manager->DidCreateNavigationRequest(navigation_request.get()); 2962 manager->DidCreateNavigationRequest(navigation_request.get());
2963 2963
2964 // The current WebUI should still be in place and there should be a new 2964 // The current WebUI should still be in place and there should be a new
2965 // active WebUI instance in the speculative RenderFrameHost. 2965 // active WebUI instance in the speculative RenderFrameHost.
2966 EXPECT_TRUE(manager->current_frame_host()->web_ui()); 2966 EXPECT_TRUE(manager->current_frame_host()->web_ui());
2967 EXPECT_FALSE(manager->current_frame_host()->pending_web_ui()); 2967 EXPECT_FALSE(manager->current_frame_host()->pending_web_ui());
2968 RenderFrameHostImpl* speculative_host = GetPendingFrameHost(manager); 2968 RenderFrameHostImpl* speculative_host = GetPendingFrameHost(manager);
2969 EXPECT_TRUE(speculative_host); 2969 EXPECT_TRUE(speculative_host);
2970 WebUIImpl* next_web_ui = manager->GetNavigatingWebUI(); 2970 WebUIImpl* next_web_ui = manager->GetNavigatingWebUI();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 ASSERT_FALSE(delete_observer.deleted()); 3146 ASSERT_FALSE(delete_observer.deleted());
3147 EXPECT_FALSE(initial_rfh->is_active()); 3147 EXPECT_FALSE(initial_rfh->is_active());
3148 3148
3149 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not 3149 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not
3150 // create a NavigationHandle. 3150 // create a NavigationHandle.
3151 initial_rfh->SimulateNavigationStart(kUrl3); 3151 initial_rfh->SimulateNavigationStart(kUrl3);
3152 EXPECT_FALSE(initial_rfh->navigation_handle()); 3152 EXPECT_FALSE(initial_rfh->navigation_handle());
3153 } 3153 }
3154 3154
3155 } // namespace content 3155 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698