OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 | 1770 |
1771 // Ensure the URLS are correct. | 1771 // Ensure the URLS are correct. |
1772 EXPECT_EQ(controller().entry_count(), 5); | 1772 EXPECT_EQ(controller().entry_count(), 5); |
1773 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url0); | 1773 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url0); |
1774 EXPECT_EQ(controller().GetEntryAtIndex(1)->url(), url1); | 1774 EXPECT_EQ(controller().GetEntryAtIndex(1)->url(), url1); |
1775 EXPECT_EQ(controller().GetEntryAtIndex(2)->url(), url2); | 1775 EXPECT_EQ(controller().GetEntryAtIndex(2)->url(), url2); |
1776 EXPECT_EQ(controller().GetEntryAtIndex(3)->url(), url3); | 1776 EXPECT_EQ(controller().GetEntryAtIndex(3)->url(), url3); |
1777 EXPECT_EQ(controller().GetEntryAtIndex(4)->url(), url4); | 1777 EXPECT_EQ(controller().GetEntryAtIndex(4)->url(), url4); |
1778 } | 1778 } |
1779 | 1779 |
| 1780 // Tests that the URLs for renderer-initiated navigations are not displayed to |
| 1781 // the user until the navigation commits, to prevent URL spoof attacks. |
| 1782 // See http://crbug.com/99016. |
| 1783 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { |
| 1784 TestNotificationTracker notifications; |
| 1785 RegisterForAllNavNotifications(¬ifications, &controller()); |
| 1786 |
| 1787 const GURL url0("http://foo/0"); |
| 1788 const GURL url1("http://foo/1"); |
| 1789 |
| 1790 // For typed navigations (browser-initiated), both active and visible entries |
| 1791 // should update before commit. |
| 1792 controller().LoadURL(url0, GURL(), PageTransition::TYPED, std::string()); |
| 1793 EXPECT_EQ(url0, controller().GetActiveEntry()->url()); |
| 1794 EXPECT_EQ(url0, controller().GetVisibleEntry()->url()); |
| 1795 rvh()->SendNavigate(0, url0); |
| 1796 |
| 1797 // For link clicks (renderer-initiated navigations), the active entry should |
| 1798 // update before commit but the visible should not. |
| 1799 controller().LoadURL(url1, GURL(), PageTransition::LINK, std::string()); |
| 1800 EXPECT_EQ(url1, controller().GetActiveEntry()->url()); |
| 1801 EXPECT_EQ(url0, controller().GetVisibleEntry()->url()); |
| 1802 rvh()->SendNavigate(1, url1); |
| 1803 // After commit, both should be updated. |
| 1804 EXPECT_EQ(url1, controller().GetActiveEntry()->url()); |
| 1805 EXPECT_EQ(url1, controller().GetVisibleEntry()->url()); |
| 1806 |
| 1807 notifications.Reset(); |
| 1808 } |
| 1809 |
1780 // Tests that IsInPageNavigation returns appropriate results. Prevents | 1810 // Tests that IsInPageNavigation returns appropriate results. Prevents |
1781 // regression for bug 1126349. | 1811 // regression for bug 1126349. |
1782 TEST_F(NavigationControllerTest, IsInPageNavigation) { | 1812 TEST_F(NavigationControllerTest, IsInPageNavigation) { |
1783 // Navigate to URL with no refs. | 1813 // Navigate to URL with no refs. |
1784 const GURL url("http://www.google.com/home.html"); | 1814 const GURL url("http://www.google.com/home.html"); |
1785 rvh()->SendNavigate(0, url); | 1815 rvh()->SendNavigate(0, url); |
1786 | 1816 |
1787 // Reloading the page is not an in-page navigation. | 1817 // Reloading the page is not an in-page navigation. |
1788 EXPECT_FALSE(controller().IsURLInPageNavigation(url)); | 1818 EXPECT_FALSE(controller().IsURLInPageNavigation(url)); |
1789 const GURL other_url("http://www.google.com/add.html"); | 1819 const GURL other_url("http://www.google.com/add.html"); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2314 TabNavigation nav(0, url0, GURL(), string16(), | 2344 TabNavigation nav(0, url0, GURL(), string16(), |
2315 webkit_glue::CreateHistoryStateForURL(url0), | 2345 webkit_glue::CreateHistoryStateForURL(url0), |
2316 PageTransition::LINK); | 2346 PageTransition::LINK); |
2317 session_helper_.AssertNavigationEquals(nav, | 2347 session_helper_.AssertNavigationEquals(nav, |
2318 windows_[0]->tabs[0]->navigations[0]); | 2348 windows_[0]->tabs[0]->navigations[0]); |
2319 nav.set_url(url2); | 2349 nav.set_url(url2); |
2320 session_helper_.AssertNavigationEquals(nav, | 2350 session_helper_.AssertNavigationEquals(nav, |
2321 windows_[0]->tabs[0]->navigations[1]); | 2351 windows_[0]->tabs[0]->navigations[1]); |
2322 } | 2352 } |
2323 */ | 2353 */ |
OLD | NEW |