| 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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 | 1640 |
| 1641 // Normal navigation will preserve redirects in the committed entry. | 1641 // Normal navigation will preserve redirects in the committed entry. |
| 1642 main_test_rfh()->PrepareForCommitWithServerRedirect(url2); | 1642 main_test_rfh()->PrepareForCommitWithServerRedirect(url2); |
| 1643 main_test_rfh()->SendNavigateWithModificationCallback(entry_id, true, url1, | 1643 main_test_rfh()->SendNavigateWithModificationCallback(entry_id, true, url1, |
| 1644 set_redirects_callback); | 1644 set_redirects_callback); |
| 1645 NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry(); | 1645 NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry(); |
| 1646 ASSERT_EQ(1U, committed_entry->GetRedirectChain().size()); | 1646 ASSERT_EQ(1U, committed_entry->GetRedirectChain().size()); |
| 1647 EXPECT_EQ(url2, committed_entry->GetRedirectChain()[0]); | 1647 EXPECT_EQ(url2, committed_entry->GetRedirectChain()[0]); |
| 1648 } | 1648 } |
| 1649 | 1649 |
| 1650 // Tests that webkit preferences are updated when user agent override changes. |
| 1651 TEST_F(NavigationControllerTest, GoBackWithUserAgentOverrideChange) { |
| 1652 NavigationControllerImpl& controller = controller_impl(); |
| 1653 |
| 1654 // Set up a simple NavigationEntry stack of two pages. |
| 1655 const GURL url1("http://foo/1"); |
| 1656 const GURL url2("http://foo/2"); |
| 1657 |
| 1658 controller.LoadURL(url1, Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 1659 std::string()); |
| 1660 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 1661 EXPECT_FALSE(controller.GetPendingEntry()->GetIsOverridingUserAgent()); |
| 1662 main_test_rfh()->PrepareForCommit(); |
| 1663 main_test_rfh()->SendNavigate(entry_id, true, url1); |
| 1664 |
| 1665 controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 1666 std::string()); |
| 1667 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 1668 EXPECT_FALSE(controller.GetPendingEntry()->GetIsOverridingUserAgent()); |
| 1669 main_test_rfh()->PrepareForCommit(); |
| 1670 main_test_rfh()->SendNavigate(entry_id, true, url2); |
| 1671 |
| 1672 // Simulate the behavior of "Request Desktop Site" being checked in |
| 1673 // NavigationControllerAndroid::SetUseDesktopUserAgent. |
| 1674 controller.GetVisibleEntry()->SetIsOverridingUserAgent(true); |
| 1675 controller.Reload(ReloadType::ORIGINAL_REQUEST_URL, true); |
| 1676 EXPECT_TRUE(controller.GetLastCommittedEntry()->GetIsOverridingUserAgent()); |
| 1677 |
| 1678 // Test that OnWebkitPreferencesChanged is called when going back to propagate |
| 1679 // change in viewport_meta WebSetting. |
| 1680 int change_counter = 0; |
| 1681 test_rvh()->set_webkit_preferences_changed_counter(&change_counter); |
| 1682 |
| 1683 controller.GoBack(); |
| 1684 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 1685 EXPECT_FALSE(controller.GetPendingEntry()->GetIsOverridingUserAgent()); |
| 1686 main_test_rfh()->PrepareForCommit(); |
| 1687 main_test_rfh()->SendNavigate(entry_id, false, url1); |
| 1688 |
| 1689 EXPECT_EQ(1, change_counter); |
| 1690 } |
| 1691 |
| 1650 // Tests what happens when we navigate back successfully | 1692 // Tests what happens when we navigate back successfully |
| 1651 TEST_F(NavigationControllerTest, Back) { | 1693 TEST_F(NavigationControllerTest, Back) { |
| 1652 NavigationControllerImpl& controller = controller_impl(); | 1694 NavigationControllerImpl& controller = controller_impl(); |
| 1653 TestNotificationTracker notifications; | 1695 TestNotificationTracker notifications; |
| 1654 RegisterForAllNavNotifications(¬ifications, &controller); | 1696 RegisterForAllNavNotifications(¬ifications, &controller); |
| 1655 | 1697 |
| 1656 const GURL url1("http://foo1"); | 1698 const GURL url1("http://foo1"); |
| 1657 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url1); | 1699 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url1); |
| 1658 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1700 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1659 navigation_entry_committed_counter_ = 0; | 1701 navigation_entry_committed_counter_ = 0; |
| (...skipping 3629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5289 main_test_rfh()->SimulateNavigationStart(url_1); | 5331 main_test_rfh()->SimulateNavigationStart(url_1); |
| 5290 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); | 5332 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); |
| 5291 EXPECT_EQ(ReloadType::NONE, last_reload_type_); | 5333 EXPECT_EQ(ReloadType::NONE, last_reload_type_); |
| 5292 | 5334 |
| 5293 main_test_rfh()->SimulateNavigationCommit(url_2); | 5335 main_test_rfh()->SimulateNavigationCommit(url_2); |
| 5294 main_test_rfh()->SimulateNavigationCommit(url_1); | 5336 main_test_rfh()->SimulateNavigationCommit(url_1); |
| 5295 main_test_rfh()->SimulateNavigationCommit(url_1); | 5337 main_test_rfh()->SimulateNavigationCommit(url_1); |
| 5296 } | 5338 } |
| 5297 | 5339 |
| 5298 } // namespace content | 5340 } // namespace content |
| OLD | NEW |