Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: content/browser/tab_contents/navigation_controller_unittest.cc

Issue 8224023: Don't show URL for pending new navigations initiated by the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 1761
1762 // Ensure the URLS are correct. 1762 // Ensure the URLS are correct.
1763 EXPECT_EQ(controller().entry_count(), 5); 1763 EXPECT_EQ(controller().entry_count(), 5);
1764 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url0); 1764 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url0);
1765 EXPECT_EQ(controller().GetEntryAtIndex(1)->url(), url1); 1765 EXPECT_EQ(controller().GetEntryAtIndex(1)->url(), url1);
1766 EXPECT_EQ(controller().GetEntryAtIndex(2)->url(), url2); 1766 EXPECT_EQ(controller().GetEntryAtIndex(2)->url(), url2);
1767 EXPECT_EQ(controller().GetEntryAtIndex(3)->url(), url3); 1767 EXPECT_EQ(controller().GetEntryAtIndex(3)->url(), url3);
1768 EXPECT_EQ(controller().GetEntryAtIndex(4)->url(), url4); 1768 EXPECT_EQ(controller().GetEntryAtIndex(4)->url(), url4);
1769 } 1769 }
1770 1770
1771 // Tests that the URLs for renderer-initiated navigations are not displayed to
1772 // the user until the navigation commits, to prevent URL spoof attacks.
1773 // See http://crbug.com/99016.
1774 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
1775 TestNotificationTracker notifications;
1776 RegisterForAllNavNotifications(&notifications, &controller());
1777
1778 const GURL url0("http://foo/0");
1779 const GURL url1("http://foo/1");
1780
1781 // For typed navigations (browser-initiated), both active and visible entries
1782 // should update before commit.
1783 controller().LoadURL(url0, GURL(), PageTransition::TYPED, std::string());
1784 EXPECT_EQ(url0, controller().GetActiveEntry()->url());
1785 EXPECT_EQ(url0, controller().GetVisibleEntry()->url());
1786 rvh()->SendNavigate(0, url0);
1787
1788 // For link clicks (renderer-initiated navigations), the active entry should
1789 // update before commit but the visible should not.
1790 controller().LoadURL(url1, GURL(), PageTransition::LINK, std::string());
1791 EXPECT_EQ(url1, controller().GetActiveEntry()->url());
1792 EXPECT_EQ(url0, controller().GetVisibleEntry()->url());
1793 rvh()->SendNavigate(1, url1);
1794 // After commit, both should be updated.
1795 EXPECT_EQ(url1, controller().GetActiveEntry()->url());
1796 EXPECT_EQ(url1, controller().GetVisibleEntry()->url());
1797
1798 notifications.Reset();
1799 }
1800
1771 // Tests that IsInPageNavigation returns appropriate results. Prevents 1801 // Tests that IsInPageNavigation returns appropriate results. Prevents
1772 // regression for bug 1126349. 1802 // regression for bug 1126349.
1773 TEST_F(NavigationControllerTest, IsInPageNavigation) { 1803 TEST_F(NavigationControllerTest, IsInPageNavigation) {
1774 // Navigate to URL with no refs. 1804 // Navigate to URL with no refs.
1775 const GURL url("http://www.google.com/home.html"); 1805 const GURL url("http://www.google.com/home.html");
1776 rvh()->SendNavigate(0, url); 1806 rvh()->SendNavigate(0, url);
1777 1807
1778 // Reloading the page is not an in-page navigation. 1808 // Reloading the page is not an in-page navigation.
1779 EXPECT_FALSE(controller().IsURLInPageNavigation(url)); 1809 EXPECT_FALSE(controller().IsURLInPageNavigation(url));
1780 const GURL other_url("http://www.google.com/add.html"); 1810 const GURL other_url("http://www.google.com/add.html");
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 TabNavigation nav(0, url0, GURL(), string16(), 2335 TabNavigation nav(0, url0, GURL(), string16(),
2306 webkit_glue::CreateHistoryStateForURL(url0), 2336 webkit_glue::CreateHistoryStateForURL(url0),
2307 PageTransition::LINK); 2337 PageTransition::LINK);
2308 session_helper_.AssertNavigationEquals(nav, 2338 session_helper_.AssertNavigationEquals(nav,
2309 windows_[0]->tabs[0]->navigations[0]); 2339 windows_[0]->tabs[0]->navigations[0]);
2310 nav.set_url(url2); 2340 nav.set_url(url2);
2311 session_helper_.AssertNavigationEquals(nav, 2341 session_helper_.AssertNavigationEquals(nav,
2312 windows_[0]->tabs[0]->navigations[1]); 2342 windows_[0]->tabs[0]->navigations[1]);
2313 } 2343 }
2314 */ 2344 */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698