diff options
author | tkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 03:01:41 +0000 |
---|---|---|
committer | tkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 03:01:41 +0000 |
commit | d5a49e5ad3e6eb962cc026c9fd5c945f89ea9b0c (patch) | |
tree | 4a480151337d8ca63a7afec813a48a544b4e901b /chrome/browser/tab_contents/navigation_controller_unittest.cc | |
parent | 4c3046b09abd049562d543fa8dba1cba63c62b5a (diff) | |
download | chromium_src-d5a49e5ad3e6eb962cc026c9fd5c945f89ea9b0c.zip chromium_src-d5a49e5ad3e6eb962cc026c9fd5c945f89ea9b0c.tar.gz chromium_src-d5a49e5ad3e6eb962cc026c9fd5c945f89ea9b0c.tar.bz2 |
Fix a bug of unnecessary "Confirm form resubmission" dialog.
If a URL is requested by the POST method and then the page is
redirected to another URL, NavigationEntry::has_post_data_ is not
cleared correctly with the prior code. So "Confirm form resubmission"
dialog is shown when a user asks reloading the redirected page.
TEST=Add a unit test
BUG=21245
Review URL: http://codereview.chromium.org/524057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/navigation_controller_unittest.cc')
-rw-r--r-- | chrome/browser/tab_contents/navigation_controller_unittest.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/navigation_controller_unittest.cc b/chrome/browser/tab_contents/navigation_controller_unittest.cc index 36344b0..a585829 100644 --- a/chrome/browser/tab_contents/navigation_controller_unittest.cc +++ b/chrome/browser/tab_contents/navigation_controller_unittest.cc @@ -767,6 +767,62 @@ TEST_F(NavigationControllerTest, Redirect) { EXPECT_FALSE(controller().CanGoForward()); } +// Similar to Redirect above, but the first URL is requested by POST, +// the second URL is requested by GET. NavigationEntry::has_post_data_ +// must be cleared. http://crbug.com/21245 +TEST_F(NavigationControllerTest, PostThenRedirect) { + TestNotificationTracker notifications; + RegisterForAllNavNotifications(¬ifications, &controller()); + + const GURL url1("http://foo1"); + const GURL url2("http://foo2"); // Redirection target + + // First request as POST + controller().LoadURL(url1, GURL(), PageTransition::TYPED); + controller().GetActiveEntry()->set_has_post_data(true); + + EXPECT_EQ(0U, notifications.size()); + rvh()->SendNavigate(0, url2); + EXPECT_TRUE(notifications.Check1AndReset( + NotificationType::NAV_ENTRY_COMMITTED)); + + // Second request + controller().LoadURL(url1, GURL(), PageTransition::TYPED); + + EXPECT_TRUE(controller().pending_entry()); + EXPECT_EQ(controller().pending_entry_index(), -1); + EXPECT_EQ(url1, controller().GetActiveEntry()->url()); + + ViewHostMsg_FrameNavigate_Params params = {0}; + params.page_id = 0; + params.url = url2; + params.transition = PageTransition::SERVER_REDIRECT; + params.redirects.push_back(GURL("http://foo1")); + params.redirects.push_back(GURL("http://foo2")); + params.should_update_history = false; + params.gesture = NavigationGestureAuto; + params.is_post = false; + + NavigationController::LoadCommittedDetails details; + + EXPECT_EQ(0U, notifications.size()); + EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(notifications.Check1AndReset( + NotificationType::NAV_ENTRY_COMMITTED)); + + EXPECT_TRUE(details.type == NavigationType::SAME_PAGE); + EXPECT_EQ(controller().entry_count(), 1); + EXPECT_EQ(controller().last_committed_entry_index(), 0); + EXPECT_TRUE(controller().GetLastCommittedEntry()); + EXPECT_EQ(controller().pending_entry_index(), -1); + EXPECT_FALSE(controller().pending_entry()); + EXPECT_EQ(url2, controller().GetActiveEntry()->url()); + EXPECT_FALSE(controller().GetActiveEntry()->has_post_data()); + + EXPECT_FALSE(controller().CanGoBack()); + EXPECT_FALSE(controller().CanGoForward()); +} + // A redirect right off the bat should be a NEW_PAGE. TEST_F(NavigationControllerTest, ImmediateRedirect) { TestNotificationTracker notifications; |