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

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

Issue 464593003: Don't swap out the old RenderFrameHost until the new one commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase past PlzNavigate CL 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
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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 controller.GetLastCommittedEntry())->bindings()); 1089 controller.GetLastCommittedEntry())->bindings());
1090 1090
1091 // Manually increase the number of active views in the SiteInstance 1091 // Manually increase the number of active views in the SiteInstance
1092 // that orig_rfh belongs to, to prevent it from being destroyed when 1092 // that orig_rfh belongs to, to prevent it from being destroyed when
1093 // it gets swapped out, so that we can reuse orig_rfh when the 1093 // it gets swapped out, so that we can reuse orig_rfh when the
1094 // controller goes back. 1094 // controller goes back.
1095 static_cast<SiteInstanceImpl*>(orig_rfh->GetSiteInstance())-> 1095 static_cast<SiteInstanceImpl*>(orig_rfh->GetSiteInstance())->
1096 increment_active_view_count(); 1096 increment_active_view_count();
1097 1097
1098 // Navigate to a second URL, simulate the beforeunload ack for the cross-site 1098 // Navigate to a second URL, simulate the beforeunload ack for the cross-site
1099 // transition, run the unload handler, and set bindings on the pending 1099 // transition, and set bindings on the pending RenderViewHost to simulate a
1100 // RenderViewHost to simulate a privileged url. 1100 // privileged url.
1101 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 1101 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
1102 orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); 1102 orig_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true);
1103 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
1104 contents()->GetPendingMainFrame(),
1105 GlobalRequestID(0, 0), scoped_ptr<CrossSiteTransferringRequest>(),
1106 url_chain, Referrer(), PAGE_TRANSITION_TYPED, false);
1107 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); 1103 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame();
1108 new_rfh->GetRenderViewHost()->AllowBindings(1); 1104 new_rfh->GetRenderViewHost()->AllowBindings(1);
1109 new_rfh->SendNavigate(1, url2); 1105 new_rfh->SendNavigate(1, url2);
1110 1106
1111 // The second load should be committed, and bindings should be remembered. 1107 // The second load should be committed, and bindings should be remembered.
1112 EXPECT_EQ(controller.GetEntryCount(), 2); 1108 EXPECT_EQ(controller.GetEntryCount(), 2);
1113 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1109 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1114 EXPECT_TRUE(controller.CanGoBack()); 1110 EXPECT_TRUE(controller.CanGoBack());
1115 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry( 1111 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry(
1116 controller.GetLastCommittedEntry())->bindings()); 1112 controller.GetLastCommittedEntry())->bindings());
1117 1113
1118 // Going back, the first entry should still appear unprivileged. 1114 // Going back, the first entry should still appear unprivileged.
1119 controller.GoBack(); 1115 controller.GoBack();
1120 new_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true); 1116 new_rfh->GetRenderViewHost()->SendBeforeUnloadACK(true);
1121 contents()->GetRenderManagerForTesting()->OnCrossSiteResponse(
1122 contents()->GetPendingMainFrame(),
1123 GlobalRequestID(0, 0), scoped_ptr<CrossSiteTransferringRequest>(),
1124 url_chain, Referrer(), PAGE_TRANSITION_TYPED, false);
1125 orig_rfh->SendNavigate(0, url1); 1117 orig_rfh->SendNavigate(0, url1);
1126 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 1118 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
1127 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( 1119 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry(
1128 controller.GetLastCommittedEntry())->bindings()); 1120 controller.GetLastCommittedEntry())->bindings());
1129 } 1121 }
1130 1122
1131 TEST_F(NavigationControllerTest, Reload) { 1123 TEST_F(NavigationControllerTest, Reload) {
1132 NavigationControllerImpl& controller = controller_impl(); 1124 NavigationControllerImpl& controller = controller_impl();
1133 TestNotificationTracker notifications; 1125 TestNotificationTracker notifications;
1134 RegisterForAllNavNotifications(&notifications, &controller); 1126 RegisterForAllNavNotifications(&notifications, &controller);
(...skipping 3207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 params.post_id = -1; 4334 params.post_id = -1;
4343 test_rvh()->SendNavigateWithParams(&params); 4335 test_rvh()->SendNavigateWithParams(&params);
4344 4336
4345 // Now reload. replaceState overrides the POST, so we should not show a 4337 // Now reload. replaceState overrides the POST, so we should not show a
4346 // repost warning dialog. 4338 // repost warning dialog.
4347 controller_impl().Reload(true); 4339 controller_impl().Reload(true);
4348 EXPECT_EQ(0, delegate->repost_form_warning_count()); 4340 EXPECT_EQ(0, delegate->repost_form_warning_count());
4349 } 4341 }
4350 4342
4351 } // namespace content 4343 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/cross_site_transferring_request.h ('k') | content/browser/frame_host/navigator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698