| Index: content/browser/tab_contents/navigation_controller_unittest.cc
|
| diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc
|
| index 900acb5453a99f1597f84f67b5789d60323bcae2..2d66b2f28a7eb92a45a83d219df7c8081453aea2 100644
|
| --- a/content/browser/tab_contents/navigation_controller_unittest.cc
|
| +++ b/content/browser/tab_contents/navigation_controller_unittest.cc
|
| @@ -1777,6 +1777,36 @@ TEST_F(NavigationControllerTest, TransientEntry) {
|
| EXPECT_EQ(controller().GetEntryAtIndex(4)->url(), url4);
|
| }
|
|
|
| +// Tests that the URLs for renderer-initiated navigations are not displayed to
|
| +// the user until the navigation commits, to prevent URL spoof attacks.
|
| +// See http://crbug.com/99016.
|
| +TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
|
| + TestNotificationTracker notifications;
|
| + RegisterForAllNavNotifications(¬ifications, &controller());
|
| +
|
| + const GURL url0("http://foo/0");
|
| + const GURL url1("http://foo/1");
|
| +
|
| + // For typed navigations (browser-initiated), both active and visible entries
|
| + // should update before commit.
|
| + controller().LoadURL(url0, GURL(), PageTransition::TYPED, std::string());
|
| + EXPECT_EQ(url0, controller().GetActiveEntry()->url());
|
| + EXPECT_EQ(url0, controller().GetVisibleEntry()->url());
|
| + rvh()->SendNavigate(0, url0);
|
| +
|
| + // For link clicks (renderer-initiated navigations), the active entry should
|
| + // update before commit but the visible should not.
|
| + controller().LoadURL(url1, GURL(), PageTransition::LINK, std::string());
|
| + EXPECT_EQ(url1, controller().GetActiveEntry()->url());
|
| + EXPECT_EQ(url0, controller().GetVisibleEntry()->url());
|
| + rvh()->SendNavigate(1, url1);
|
| + // After commit, both should be updated.
|
| + EXPECT_EQ(url1, controller().GetActiveEntry()->url());
|
| + EXPECT_EQ(url1, controller().GetVisibleEntry()->url());
|
| +
|
| + notifications.Reset();
|
| +}
|
| +
|
| // Tests that IsInPageNavigation returns appropriate results. Prevents
|
| // regression for bug 1126349.
|
| TEST_F(NavigationControllerTest, IsInPageNavigation) {
|
|
|