Chromium Code Reviews| Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| index 5e91cccc414b761646daab7389c76148150b996a..5e1acfce1c97876270e4f5ee86c86ec5a38edbb1 100644 |
| --- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| +++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| @@ -4196,6 +4196,104 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| EXPECT_EQ(dsn_3, dsn_4); |
| } |
| +// Verifies that the FrameNavigationEntry's redirect chain is created for the |
| +// main frame. |
| +IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| + FrameNavigationEntry_MainFrameRedirectChain) { |
| + const NavigationControllerImpl& controller = |
| + static_cast<const NavigationControllerImpl&>( |
| + shell()->web_contents()->GetController()); |
| + |
| + // Navigate the main frame to a redirecting URL (server-side) |
| + GURL final_url(embedded_test_server()->GetURL("/simple_page.html")); |
| + GURL redirecting_url( |
| + embedded_test_server()->GetURL("/server-redirect?/simple_page.html")); |
| + NavigateToURL(shell(), redirecting_url); |
|
Charlie Reis
2016/10/03 18:37:22
nit: EXPECT_TRUE (same in the other NavigateToURL
arthursonzogni
2016/10/04 08:44:03
Done.
Nevertheless, NavigateToURL returns false fo
|
| + |
| + // Check last committed NavigationEntry's redirects. |
| + EXPECT_EQ(1, controller.GetEntryCount()); |
| + content::NavigationEntry* entry = controller.GetLastCommittedEntry(); |
| + EXPECT_EQ(entry->GetRedirectChain().size(), 2u); |
| + EXPECT_EQ(entry->GetRedirectChain()[0], redirecting_url); |
| + EXPECT_EQ(entry->GetRedirectChain()[1], final_url); |
| +} |
| + |
| +// Verifies that FrameNavigationEntry's redirect chain is created and stored on |
| +// the right subframe (AUTO_SUBFRAME navigation). |
| +IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| + FrameNavigationEntry_AutoSubFrameRedirectChain) { |
| + const NavigationControllerImpl& controller = |
| + static_cast<const NavigationControllerImpl&>( |
| + shell()->web_contents()->GetController()); |
| + |
| + GURL main_url(embedded_test_server()->GetURL( |
| + "/navigation_controller/page_with_iframe_redirect.html")); |
| + GURL iframe_redirect_url( |
| + embedded_test_server()->GetURL("/server-redirect?/simple_page.html")); |
| + GURL iframe_final_url(embedded_test_server()->GetURL("/simple_page.html")); |
| + |
| + // Navigate to a page with an redirecting iframe. |
| + NavigateToURL(shell(), main_url); |
| + |
| + // Check that the main frame redirect chain contains only one url. |
| + EXPECT_EQ(1, controller.GetEntryCount()); |
| + NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| + EXPECT_EQ(entry->GetRedirectChain().size(), 1u); |
| + EXPECT_EQ(entry->GetRedirectChain()[0], main_url); |
| + |
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| + // Check that the FrameNavigationEntry's redirect chain contains 2 urls. |
| + ASSERT_EQ(1U, entry->root_node()->children.size()); |
| + FrameNavigationEntry* frame_entry = |
| + entry->root_node()->children[0]->frame_entry.get(); |
| + EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); |
| + EXPECT_EQ(frame_entry->redirect_chain()[0], iframe_redirect_url); |
| + EXPECT_EQ(frame_entry->redirect_chain()[1], iframe_final_url); |
| + } |
| +} |
| + |
| +// Verifies that FrameNavigationEntry's redirect chain is created and stored on |
| +// the right subframe (NEW_SUBFRAME navigation). |
| +IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| + FrameNavigationEntry_NewSubFrameRedirectChain) { |
| + const NavigationControllerImpl& controller = |
| + static_cast<const NavigationControllerImpl&>( |
| + shell()->web_contents()->GetController()); |
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + ->GetFrameTree() |
| + ->root(); |
| + |
| + // 1. Navigate to a page with an iframe |
|
Charlie Reis
2016/10/03 18:37:22
nit: End with period.
arthursonzogni
2016/10/04 08:44:03
Done.
|
| + GURL main_url(embedded_test_server()->GetURL( |
| + "/navigation_controller/page_with_data_iframe.html")); |
| + NavigateToURL(shell(), main_url); |
| + EXPECT_EQ(1, controller.GetEntryCount()); |
| + |
| + // 2. Navigate in the subframe with a redirection. |
| + GURL frame_final_url(embedded_test_server()->GetURL("/simple_page.html")); |
| + GURL frame_redirect_url( |
| + embedded_test_server()->GetURL("/server-redirect?/simple_page.html")); |
| + NavigateFrameToURL(root->child_at(0), frame_redirect_url); |
| + |
| + // Check that the main frame redirect chain contains only the main_url. |
| + EXPECT_EQ(2, controller.GetEntryCount()); |
| + NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| + EXPECT_EQ(entry->GetRedirectChain().size(), 1u); |
| + EXPECT_EQ(entry->GetRedirectChain()[0], main_url); |
| + |
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process). |
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| + // Check that the FrameNavigationEntry's redirect chain contains 2 urls. |
| + ASSERT_EQ(1U, entry->root_node()->children.size()); |
| + FrameNavigationEntry* frame_entry = |
| + entry->root_node()->children[0]->frame_entry.get(); |
| + EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); |
| + EXPECT_EQ(frame_entry->redirect_chain()[0], frame_redirect_url); |
| + EXPECT_EQ(frame_entry->redirect_chain()[1], frame_final_url); |
| + } |
| +} |
| + |
| // Support a set of tests that isolate only a subset of sites with |
| // out-of-process iframes (OOPIFs). |
| class NavigationControllerOopifBrowserTest |