| Index: content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| index 7a77cd69ab39ad3cf036b518383c4fb60f33c76b..10098a5c3ce50a314db973dd41467f04afe3df56 100644
|
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| @@ -1313,13 +1313,13 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
|
| pending_entry->set_is_renderer_initiated(true);
|
| pending_entry->set_transferred_global_request_id(transfer_id);
|
| pending_entry->set_should_replace_entry(true);
|
| - pending_entry->set_redirect_chain(redirects);
|
| + pending_entry->SetRedirectChain(redirects);
|
| pending_entry->set_should_clear_history_list(true);
|
| EXPECT_EQ(post_data.get(), pending_entry->GetBrowserInitiatedPostData());
|
| EXPECT_TRUE(pending_entry->is_renderer_initiated());
|
| EXPECT_EQ(transfer_id, pending_entry->transferred_global_request_id());
|
| EXPECT_TRUE(pending_entry->should_replace_entry());
|
| - EXPECT_EQ(1U, pending_entry->redirect_chain().size());
|
| + EXPECT_EQ(1U, pending_entry->GetRedirectChain().size());
|
| EXPECT_TRUE(pending_entry->should_clear_history_list());
|
|
|
| main_test_rfh()->SendNavigate(0, url1);
|
| @@ -1334,8 +1334,10 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
|
| EXPECT_EQ(GlobalRequestID(-1, -1),
|
| committed_entry->transferred_global_request_id());
|
| EXPECT_FALSE(committed_entry->should_replace_entry());
|
| - EXPECT_EQ(0U, committed_entry->redirect_chain().size());
|
| EXPECT_FALSE(committed_entry->should_clear_history_list());
|
| +
|
| + // Verify new behavior -- redirects are not reset anymore.
|
| + EXPECT_EQ(1U, committed_entry->GetRedirectChain().size());
|
| }
|
|
|
| // Tests what happens when we navigate back successfully
|
| @@ -4023,4 +4025,111 @@ TEST_F(NavigationControllerTest, ClearHistoryList) {
|
| EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
|
| }
|
|
|
| +// Test that GetMergedRedirectChain just returns the navigate params redirects
|
| +// when the user goes to a new page (by typing a URL) and the active entry has
|
| +// no redirects.
|
| +TEST_F(NavigationControllerTest, TestGetMergedRedirectChainNewPage) {
|
| + std::vector<GURL> active_entry_redirects;
|
| + FrameHostMsg_DidCommitProvisionalLoad_Params params;
|
| + std::vector<GURL> redirects;
|
| + redirects.push_back(GURL("http://foo0"));
|
| + params.redirects = redirects;
|
| + NavigationControllerImpl& controller = controller_impl();
|
| + std::vector<GURL> result = controller.GetMergedRedirectChain(
|
| + params, active_entry_redirects);
|
| +
|
| + EXPECT_EQ(1U, result.size());
|
| + EXPECT_EQ(GURL("http://foo0"), result.at(0));
|
| +}
|
| +
|
| +// Test that GetMergedRedirectChain just returns the active entry redirects
|
| +// when revisiting the same page -- the page transition was a reload or
|
| +// forward/back.
|
| +TEST_F(NavigationControllerTest, TestGetMergedRedirectChainSamePage) {
|
| + std::vector<GURL> active_entry_redirects;
|
| + active_entry_redirects.push_back(GURL("http://foo0"));
|
| + FrameHostMsg_DidCommitProvisionalLoad_Params params;
|
| + params.transition = content::PAGE_TRANSITION_RELOAD;
|
| + std::vector<GURL> redirects;
|
| + redirects.push_back(GURL("http://foo1"));
|
| + params.redirects = redirects;
|
| + NavigationControllerImpl& controller = controller_impl();
|
| + std::vector<GURL> result = controller.GetMergedRedirectChain(
|
| + params, active_entry_redirects);
|
| +
|
| + EXPECT_EQ(1U, result.size());
|
| + EXPECT_EQ(GURL("http://foo0"), result.at(0));
|
| +
|
| + params.transition = content::PAGE_TRANSITION_FORWARD_BACK;
|
| + result = controller.GetMergedRedirectChain(params, active_entry_redirects);
|
| +
|
| + EXPECT_EQ(1U, result.size());
|
| + EXPECT_EQ(GURL("http://foo0"), result.at(0));
|
| +}
|
| +
|
| +// Test that GetMergedRedirectChain actually merges redirects from the active
|
| +// entry and the params when they both exist with no overlap.
|
| +TEST_F(NavigationControllerTest, TestGetMergedRedirectChainMergeNoOverlap) {
|
| + std::vector<GURL> active_entry_redirects;
|
| + active_entry_redirects.push_back(GURL("http://foo0"));
|
| + active_entry_redirects.push_back(GURL("http://foo1"));
|
| + FrameHostMsg_DidCommitProvisionalLoad_Params params;
|
| + std::vector<GURL> redirects;
|
| + redirects.push_back(GURL("http://foo2"));
|
| + redirects.push_back(GURL("http://foo3"));
|
| + params.redirects = redirects;
|
| + NavigationControllerImpl& controller = controller_impl();
|
| + std::vector<GURL> result = controller.GetMergedRedirectChain(
|
| + params, active_entry_redirects);
|
| +
|
| + EXPECT_EQ(4U, result.size());
|
| + EXPECT_EQ(GURL("http://foo0"), result.at(0));
|
| + EXPECT_EQ(GURL("http://foo1"), result.at(1));
|
| + EXPECT_EQ(GURL("http://foo2"), result.at(2));
|
| + EXPECT_EQ(GURL("http://foo3"), result.at(3));
|
| +}
|
| +
|
| +// Test that GetMergedRedirectChain actually merges redirects from the active
|
| +// entry and the params when they both exist, and that a single URL overlap
|
| +// is removed.
|
| +TEST_F(NavigationControllerTest, TestGetMergedRedirectChainMergeOneOverlap) {
|
| + std::vector<GURL> active_entry_redirects;
|
| + active_entry_redirects.push_back(GURL("http://foo0"));
|
| + active_entry_redirects.push_back(GURL("http://foo1"));
|
| + FrameHostMsg_DidCommitProvisionalLoad_Params params;
|
| + std::vector<GURL> redirects;
|
| + redirects.push_back(GURL("http://foo1"));
|
| + redirects.push_back(GURL("http://foo2"));
|
| + params.redirects = redirects;
|
| + NavigationControllerImpl& controller = controller_impl();
|
| + std::vector<GURL> result = controller.GetMergedRedirectChain(
|
| + params, active_entry_redirects);
|
| +
|
| + EXPECT_EQ(3U, result.size());
|
| + EXPECT_EQ(GURL("http://foo0"), result.at(0));
|
| + EXPECT_EQ(GURL("http://foo1"), result.at(1));
|
| + EXPECT_EQ(GURL("http://foo2"), result.at(2));
|
| +}
|
| +
|
| +// Test that GetMergedRedirectChain actually merges redirects from the active
|
| +// entry and the params when they both exist, and that multiple URLs that
|
| +// overlap with the end of the active entry are removed.
|
| +TEST_F(NavigationControllerTest, TestGetMergedRedirectChainMergeTwoOverlap) {
|
| + std::vector<GURL> active_entry_redirects;
|
| + active_entry_redirects.push_back(GURL("http://foo0"));
|
| + active_entry_redirects.push_back(GURL("http://foo1"));
|
| + FrameHostMsg_DidCommitProvisionalLoad_Params params;
|
| + std::vector<GURL> redirects;
|
| + redirects.push_back(GURL("http://foo1"));
|
| + redirects.push_back(GURL("http://foo1"));
|
| + params.redirects = redirects;
|
| + NavigationControllerImpl& controller = controller_impl();
|
| + std::vector<GURL> result = controller.GetMergedRedirectChain(
|
| + params, active_entry_redirects);
|
| +
|
| + EXPECT_EQ(2U, result.size());
|
| + EXPECT_EQ(GURL("http://foo0"), result.at(0));
|
| + EXPECT_EQ(GURL("http://foo1"), result.at(1));
|
| +}
|
| +
|
| } // namespace content
|
|
|