diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-18 17:36:54 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-18 17:36:54 +0000 |
commit | fc60f22835abe2bb65b23c27fc7a15b39e948f8d (patch) | |
tree | 9dcf950b758cdbb06fe389122a9c3b37391c4631 /chrome/browser/navigation_controller_unittest.cc | |
parent | 55c72de49c7b87d77ea440ca7bd7609355370e7a (diff) | |
download | chromium_src-fc60f22835abe2bb65b23c27fc7a15b39e948f8d.zip chromium_src-fc60f22835abe2bb65b23c27fc7a15b39e948f8d.tar.gz chromium_src-fc60f22835abe2bb65b23c27fc7a15b39e948f8d.tar.bz2 |
Don't handle in-page navigations if it's for a subframe. Previously we would
compare the URL with the main frame to see if it was in page. In very rare
cases, these can actually be the same, which will confuse us.
http://crbug.com/5585
Review URL: http://codereview.chromium.org/14824
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7220 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/navigation_controller_unittest.cc')
-rw-r--r-- | chrome/browser/navigation_controller_unittest.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index 08b43a0..7938877 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -1497,6 +1497,37 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) { other_url_with_ref)); } +// Some pages can have subframes with the same base URL (minus the reference) as +// the main page. Even though this is hard, it can happen, and we don't want +// these subframe navigations to affect the toplevel document. They should +// instead be ignored. http://crbug.com/5585 +TEST_F(NavigationControllerTest, SameSubframe) { + // Navigate the main frame. + const GURL url("http://www.google.com/"); + contents->CompleteNavigationAsRenderer(0, url); + + // We should be at the first navigation entry. + EXPECT_EQ(contents->controller()->GetEntryCount(), 1); + EXPECT_EQ(contents->controller()->GetLastCommittedEntryIndex(), 0); + + // Navigate a subframe that would normally count as in-page. + const GURL subframe("http://www.google.com/#"); + ViewHostMsg_FrameNavigate_Params params; + params.page_id = 0; + params.url = subframe; + params.transition = PageTransition::AUTO_SUBFRAME; + params.should_update_history = false; + params.gesture = NavigationGestureAuto; + params.is_post = false; + NavigationController::LoadCommittedDetails details; + EXPECT_FALSE(contents->controller()->RendererDidNavigate(params, false, + &details)); + + // Nothing should have changed. + EXPECT_EQ(contents->controller()->GetEntryCount(), 1); + EXPECT_EQ(contents->controller()->GetLastCommittedEntryIndex(), 0); +} + // A basic test case. Navigates to a single url, and make sure the history // db matches. TEST_F(NavigationControllerHistoryTest, Basic) { |