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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 NavigationControllerImpl& controller = controller_impl(); | 1040 NavigationControllerImpl& controller = controller_impl(); |
1041 TestNotificationTracker notifications; | 1041 TestNotificationTracker notifications; |
1042 RegisterForAllNavNotifications(¬ifications, &controller); | 1042 RegisterForAllNavNotifications(¬ifications, &controller); |
1043 | 1043 |
1044 // First make some history, starting with a privileged URL. | 1044 // First make some history, starting with a privileged URL. |
1045 const GURL kExistingURL1("http://privileged"); | 1045 const GURL kExistingURL1("http://privileged"); |
1046 controller.LoadURL( | 1046 controller.LoadURL( |
1047 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1047 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1048 int entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1048 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
1049 // Pretend it has bindings so we can tell if we incorrectly copy it. | 1049 // Pretend it has bindings so we can tell if we incorrectly copy it. |
1050 main_test_rfh()->GetRenderViewHost()->AllowBindings(2); | 1050 main_test_rfh()->AllowBindings(2); |
1051 main_test_rfh()->PrepareForCommit(); | 1051 main_test_rfh()->PrepareForCommit(); |
1052 main_test_rfh()->SendNavigate(entry_id, true, kExistingURL1); | 1052 main_test_rfh()->SendNavigate(entry_id, true, kExistingURL1); |
1053 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1053 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
1054 navigation_entry_committed_counter_ = 0; | 1054 navigation_entry_committed_counter_ = 0; |
1055 | 1055 |
1056 // Navigate cross-process to a second URL. | 1056 // Navigate cross-process to a second URL. |
1057 const GURL kExistingURL2("http://foo/eh"); | 1057 const GURL kExistingURL2("http://foo/eh"); |
1058 controller.LoadURL( | 1058 controller.LoadURL( |
1059 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1059 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1060 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1060 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 orig_rfh->GetSiteInstance()->IncrementActiveFrameCount(); | 1333 orig_rfh->GetSiteInstance()->IncrementActiveFrameCount(); |
1334 | 1334 |
1335 // Navigate to a second URL, simulate the beforeunload ack for the cross-site | 1335 // Navigate to a second URL, simulate the beforeunload ack for the cross-site |
1336 // transition, and set bindings on the pending RenderViewHost to simulate a | 1336 // transition, and set bindings on the pending RenderViewHost to simulate a |
1337 // privileged url. | 1337 // privileged url. |
1338 controller.LoadURL( | 1338 controller.LoadURL( |
1339 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1339 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1340 int entry_id = controller.GetPendingEntry()->GetUniqueID(); | 1340 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
1341 orig_rfh->PrepareForCommit(); | 1341 orig_rfh->PrepareForCommit(); |
1342 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); | 1342 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); |
1343 new_rfh->GetRenderViewHost()->AllowBindings(1); | 1343 new_rfh->AllowBindings(1); |
1344 new_rfh->SendNavigate(entry_id, true, url2); | 1344 new_rfh->SendNavigate(entry_id, true, url2); |
1345 | 1345 |
1346 // The second load should be committed, and bindings should be remembered. | 1346 // The second load should be committed, and bindings should be remembered. |
1347 EXPECT_EQ(controller.GetEntryCount(), 2); | 1347 EXPECT_EQ(controller.GetEntryCount(), 2); |
1348 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1348 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1349 EXPECT_TRUE(controller.CanGoBack()); | 1349 EXPECT_TRUE(controller.CanGoBack()); |
1350 EXPECT_EQ(1, controller.GetLastCommittedEntry()->bindings()); | 1350 EXPECT_EQ(1, controller.GetLastCommittedEntry()->bindings()); |
1351 | 1351 |
1352 // Going back, the first entry should still appear unprivileged. | 1352 // Going back, the first entry should still appear unprivileged. |
1353 controller.GoBack(); | 1353 controller.GoBack(); |
(...skipping 3851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5205 // means that occasionally a navigation conflict will end up with one entry | 5205 // means that occasionally a navigation conflict will end up with one entry |
5206 // bubbling to the end of the entry list, but that's the least-bad option. | 5206 // bubbling to the end of the entry list, but that's the least-bad option. |
5207 EXPECT_EQ(3, controller.GetEntryCount()); | 5207 EXPECT_EQ(3, controller.GetEntryCount()); |
5208 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 5208 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
5209 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); | 5209 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); |
5210 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); | 5210 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); |
5211 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); | 5211 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); |
5212 } | 5212 } |
5213 | 5213 |
5214 } // namespace content | 5214 } // namespace content |
OLD | NEW |