| 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 4579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4590 const GURL url3("http://foo/3"); | 4590 const GURL url3("http://foo/3"); |
| 4591 | 4591 |
| 4592 NavigateAndCommit(url1); | 4592 NavigateAndCommit(url1); |
| 4593 NavigateAndCommit(url2); | 4593 NavigateAndCommit(url2); |
| 4594 NavigateAndCommit(url3); | 4594 NavigateAndCommit(url3); |
| 4595 controller.GoBack(); | 4595 controller.GoBack(); |
| 4596 contents()->CommitPendingNavigation(); | 4596 contents()->CommitPendingNavigation(); |
| 4597 process()->sink().ClearMessages(); | 4597 process()->sink().ClearMessages(); |
| 4598 | 4598 |
| 4599 // Simulate the page calling history.back(). It should create a pending entry. | 4599 // Simulate the page calling history.back(). It should create a pending entry. |
| 4600 contents()->OnGoToEntryAtOffset(-1); | 4600 contents()->OnGoToEntryAtOffset(test_rvh(), -1); |
| 4601 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 4601 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
| 4602 // The actual cross-navigation is suspended until the current RVH tells us | 4602 // The actual cross-navigation is suspended until the current RVH tells us |
| 4603 // it unloaded, simulate that. | 4603 // it unloaded, simulate that. |
| 4604 contents()->ProceedWithCrossSiteNavigation(); | 4604 contents()->ProceedWithCrossSiteNavigation(); |
| 4605 // Also make sure we told the page to navigate. | 4605 // Also make sure we told the page to navigate. |
| 4606 GURL nav_url = GetLastNavigationURL(); | 4606 GURL nav_url = GetLastNavigationURL(); |
| 4607 EXPECT_EQ(url1, nav_url); | 4607 EXPECT_EQ(url1, nav_url); |
| 4608 contents()->CommitPendingNavigation(); | 4608 contents()->CommitPendingNavigation(); |
| 4609 process()->sink().ClearMessages(); | 4609 process()->sink().ClearMessages(); |
| 4610 | 4610 |
| 4611 // Now test history.forward() | 4611 // Now test history.forward() |
| 4612 contents()->OnGoToEntryAtOffset(2); | 4612 contents()->OnGoToEntryAtOffset(test_rvh(), 2); |
| 4613 EXPECT_EQ(2, controller.GetPendingEntryIndex()); | 4613 EXPECT_EQ(2, controller.GetPendingEntryIndex()); |
| 4614 // The actual cross-navigation is suspended until the current RVH tells us | 4614 // The actual cross-navigation is suspended until the current RVH tells us |
| 4615 // it unloaded, simulate that. | 4615 // it unloaded, simulate that. |
| 4616 contents()->ProceedWithCrossSiteNavigation(); | 4616 contents()->ProceedWithCrossSiteNavigation(); |
| 4617 nav_url = GetLastNavigationURL(); | 4617 nav_url = GetLastNavigationURL(); |
| 4618 EXPECT_EQ(url3, nav_url); | 4618 EXPECT_EQ(url3, nav_url); |
| 4619 contents()->CommitPendingNavigation(); | 4619 contents()->CommitPendingNavigation(); |
| 4620 process()->sink().ClearMessages(); | 4620 process()->sink().ClearMessages(); |
| 4621 | 4621 |
| 4622 controller.DiscardNonCommittedEntries(); | 4622 controller.DiscardNonCommittedEntries(); |
| 4623 | 4623 |
| 4624 // Make sure an extravagant history.go() doesn't break. | 4624 // Make sure an extravagant history.go() doesn't break. |
| 4625 contents()->OnGoToEntryAtOffset(120); // Out of bounds. | 4625 contents()->OnGoToEntryAtOffset(test_rvh(), 120); // Out of bounds. |
| 4626 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 4626 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 4627 EXPECT_FALSE(HasNavigationRequest()); | 4627 EXPECT_FALSE(HasNavigationRequest()); |
| 4628 } | 4628 } |
| 4629 | 4629 |
| 4630 // Test call to PruneAllButLastCommitted for the only entry. | 4630 // Test call to PruneAllButLastCommitted for the only entry. |
| 4631 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { | 4631 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { |
| 4632 NavigationControllerImpl& controller = controller_impl(); | 4632 NavigationControllerImpl& controller = controller_impl(); |
| 4633 const GURL url1("http://foo1"); | 4633 const GURL url1("http://foo1"); |
| 4634 NavigateAndCommit(url1); | 4634 NavigateAndCommit(url1); |
| 4635 | 4635 |
| (...skipping 569 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 |