OLD | NEW |
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/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 NavigationControllerImpl& controller = controller_impl(); | 1042 NavigationControllerImpl& controller = controller_impl(); |
1043 TestNotificationTracker notifications; | 1043 TestNotificationTracker notifications; |
1044 RegisterForAllNavNotifications(¬ifications, &controller); | 1044 RegisterForAllNavNotifications(¬ifications, &controller); |
1045 | 1045 |
1046 // First make some history, starting with a privileged URL. | 1046 // First make some history, starting with a privileged URL. |
1047 const GURL kExistingURL1("http://privileged"); | 1047 const GURL kExistingURL1("http://privileged"); |
1048 controller.LoadURL( | 1048 controller.LoadURL( |
1049 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1049 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1050 int entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1050 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
1051 // Pretend it has bindings so we can tell if we incorrectly copy it. | 1051 // Pretend it has bindings so we can tell if we incorrectly copy it. |
1052 main_test_rfh()->GetRenderViewHost()->AllowBindings(2); | 1052 main_test_rfh()->AllowBindings(2); |
1053 main_test_rfh()->PrepareForCommit(); | 1053 main_test_rfh()->PrepareForCommit(); |
1054 main_test_rfh()->SendNavigate(entry_id, true, kExistingURL1); | 1054 main_test_rfh()->SendNavigate(entry_id, true, kExistingURL1); |
1055 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1055 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1056 navigation_entry_committed_counter_ = 0; | 1056 navigation_entry_committed_counter_ = 0; |
1057 | 1057 |
1058 // Navigate cross-process to a second URL. | 1058 // Navigate cross-process to a second URL. |
1059 const GURL kExistingURL2("http://foo/eh"); | 1059 const GURL kExistingURL2("http://foo/eh"); |
1060 controller.LoadURL( | 1060 controller.LoadURL( |
1061 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1061 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1062 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1062 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 orig_rfh->GetSiteInstance()->IncrementActiveFrameCount(); | 1335 orig_rfh->GetSiteInstance()->IncrementActiveFrameCount(); |
1336 | 1336 |
1337 // Navigate to a second URL, simulate the beforeunload ack for the cross-site | 1337 // Navigate to a second URL, simulate the beforeunload ack for the cross-site |
1338 // transition, and set bindings on the pending RenderViewHost to simulate a | 1338 // transition, and set bindings on the pending RenderViewHost to simulate a |
1339 // privileged url. | 1339 // privileged url. |
1340 controller.LoadURL( | 1340 controller.LoadURL( |
1341 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1341 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1342 int entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1342 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
1343 orig_rfh->PrepareForCommit(); | 1343 orig_rfh->PrepareForCommit(); |
1344 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); | 1344 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); |
1345 new_rfh->GetRenderViewHost()->AllowBindings(1); | 1345 new_rfh->AllowBindings(1); |
1346 new_rfh->SendNavigate(entry_id, true, url2); | 1346 new_rfh->SendNavigate(entry_id, true, url2); |
1347 | 1347 |
1348 // The second load should be committed, and bindings should be remembered. | 1348 // The second load should be committed, and bindings should be remembered. |
1349 EXPECT_EQ(controller.GetEntryCount(), 2); | 1349 EXPECT_EQ(controller.GetEntryCount(), 2); |
1350 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1350 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1351 EXPECT_TRUE(controller.CanGoBack()); | 1351 EXPECT_TRUE(controller.CanGoBack()); |
1352 EXPECT_EQ(1, controller.GetLastCommittedEntry()->bindings()); | 1352 EXPECT_EQ(1, controller.GetLastCommittedEntry()->bindings()); |
1353 | 1353 |
1354 // Going back, the first entry should still appear unprivileged. | 1354 // Going back, the first entry should still appear unprivileged. |
1355 controller.GoBack(); | 1355 controller.GoBack(); |
(...skipping 3923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5279 main_test_rfh()->SimulateNavigationStart(url_1); | 5279 main_test_rfh()->SimulateNavigationStart(url_1); |
5280 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); | 5280 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
5281 EXPECT_EQ(ReloadType::NONE, last_reload_type_); | 5281 EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
5282 | 5282 |
5283 main_test_rfh()->SimulateNavigationCommit(url_2); | 5283 main_test_rfh()->SimulateNavigationCommit(url_2); |
5284 main_test_rfh()->SimulateNavigationCommit(url_1); | 5284 main_test_rfh()->SimulateNavigationCommit(url_1); |
5285 main_test_rfh()->SimulateNavigationCommit(url_1); | 5285 main_test_rfh()->SimulateNavigationCommit(url_1); |
5286 } | 5286 } |
5287 | 5287 |
5288 } // namespace content | 5288 } // namespace content |
OLD | NEW |