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

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

Issue 423393008: Keep a copy of page id in RenderViewHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 // redirect and abort. See http://crbug.com/83031. 997 // redirect and abort. See http://crbug.com/83031.
998 TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) { 998 TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) {
999 NavigationControllerImpl& controller = controller_impl(); 999 NavigationControllerImpl& controller = controller_impl();
1000 TestNotificationTracker notifications; 1000 TestNotificationTracker notifications;
1001 RegisterForAllNavNotifications(&notifications, &controller); 1001 RegisterForAllNavNotifications(&notifications, &controller);
1002 1002
1003 // First make an existing committed entry. 1003 // First make an existing committed entry.
1004 const GURL kExistingURL("http://foo/eh"); 1004 const GURL kExistingURL("http://foo/eh");
1005 controller.LoadURL(kExistingURL, content::Referrer(), 1005 controller.LoadURL(kExistingURL, content::Referrer(),
1006 content::PAGE_TRANSITION_TYPED, std::string()); 1006 content::PAGE_TRANSITION_TYPED, std::string());
1007 main_test_rfh()->SendNavigate(0, kExistingURL); 1007 main_test_rfh()->SendNavigate(1, kExistingURL);
1008 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1008 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1009 navigation_entry_committed_counter_ = 0; 1009 navigation_entry_committed_counter_ = 0;
1010 1010
1011 // Set a WebContentsDelegate to listen for state changes. 1011 // Set a WebContentsDelegate to listen for state changes.
1012 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate()); 1012 scoped_ptr<TestWebContentsDelegate> delegate(new TestWebContentsDelegate());
1013 EXPECT_FALSE(contents()->GetDelegate()); 1013 EXPECT_FALSE(contents()->GetDelegate());
1014 contents()->SetDelegate(delegate.get()); 1014 contents()->SetDelegate(delegate.get());
1015 1015
1016 // Now make a pending new navigation, initiated by the renderer. 1016 // Now make a pending new navigation, initiated by the renderer.
1017 const GURL kNewURL("http://foo/bee"); 1017 const GURL kNewURL("http://foo/bee");
1018 NavigationController::LoadURLParams load_url_params(kNewURL); 1018 NavigationController::LoadURLParams load_url_params(kNewURL);
1019 load_url_params.transition_type = PAGE_TRANSITION_TYPED; 1019 load_url_params.transition_type = PAGE_TRANSITION_TYPED;
1020 load_url_params.is_renderer_initiated = true; 1020 load_url_params.is_renderer_initiated = true;
1021 controller.LoadURLWithParams(load_url_params); 1021 controller.LoadURLWithParams(load_url_params);
1022 EXPECT_EQ(0U, notifications.size()); 1022 EXPECT_EQ(0U, notifications.size());
1023 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 1023 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
1024 EXPECT_TRUE(controller.GetPendingEntry()); 1024 EXPECT_TRUE(controller.GetPendingEntry());
1025 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 1025 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
1026 EXPECT_EQ(0, delegate->navigation_state_change_count()); 1026 EXPECT_EQ(0, delegate->navigation_state_change_count());
1027 1027
1028 // The visible entry should be the last committed URL, not the pending one. 1028 // The visible entry should be the last committed URL, not the pending one.
1029 EXPECT_EQ(kExistingURL, controller.GetVisibleEntry()->GetURL()); 1029 EXPECT_EQ(kExistingURL, controller.GetVisibleEntry()->GetURL());
1030 1030
1031 // Now the navigation redirects. 1031 // Now the navigation redirects.
1032 const GURL kRedirectURL("http://foo/see"); 1032 const GURL kRedirectURL("http://foo/see");
1033 main_test_rfh()->OnMessageReceived( 1033 main_test_rfh()->OnMessageReceived(
1034 FrameHostMsg_DidRedirectProvisionalLoad(0, // routing_id 1034 FrameHostMsg_DidRedirectProvisionalLoad(0, // routing_id
1035 -1, // pending page_id 1035 1, // pending page_id
1036 kNewURL, // old url 1036 kNewURL, // old url
1037 kRedirectURL)); // new url 1037 kRedirectURL)); // new url
1038 1038
1039 // We don't want to change the NavigationEntry's url, in case it cancels. 1039 // We don't want to change the NavigationEntry's url, in case it cancels.
1040 // Prevents regression of http://crbug.com/77786. 1040 // Prevents regression of http://crbug.com/77786.
1041 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); 1041 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL());
1042 1042
1043 // It may abort before committing, if it's a download or due to a stop or 1043 // It may abort before committing, if it's a download or due to a stop or
1044 // a new navigation from the user. 1044 // a new navigation from the user.
1045 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; 1045 FrameHostMsg_DidFailProvisionalLoadWithError_Params params;
(...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4338 params.post_id = -1; 4338 params.post_id = -1;
4339 test_rvh()->SendNavigateWithParams(&params); 4339 test_rvh()->SendNavigateWithParams(&params);
4340 4340
4341 // Now reload. replaceState overrides the POST, so we should not show a 4341 // Now reload. replaceState overrides the POST, so we should not show a
4342 // repost warning dialog. 4342 // repost warning dialog.
4343 controller_impl().Reload(true); 4343 controller_impl().Reload(true);
4344 EXPECT_EQ(0, delegate->repost_form_warning_count()); 4344 EXPECT_EQ(0, delegate->repost_form_warning_count());
4345 } 4345 }
4346 4346
4347 } // namespace content 4347 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698