Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2368183004: Move redirect_chain from NavigationEntry to FrameNavigationEntry. (Closed)
Patch Set: Add tests + bugfix. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 4178 matching lines...) Expand 10 before | Expand all | Expand 10 after
4189 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 4189 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4190 4190
4191 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe); 4191 subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe);
4192 int64_t isn_4 = subframe_entry->item_sequence_number(); 4192 int64_t isn_4 = subframe_entry->item_sequence_number();
4193 int64_t dsn_4 = subframe_entry->document_sequence_number(); 4193 int64_t dsn_4 = subframe_entry->document_sequence_number();
4194 EXPECT_NE(-1, isn_4); 4194 EXPECT_NE(-1, isn_4);
4195 EXPECT_NE(isn_3, isn_4); 4195 EXPECT_NE(isn_3, isn_4);
4196 EXPECT_EQ(dsn_3, dsn_4); 4196 EXPECT_EQ(dsn_3, dsn_4);
4197 } 4197 }
4198 4198
4199 // Verifies that the FrameNavigationEntry's redirect chain is created for the
4200 // main frame.
4201 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4202 FrameNavigationEntry_MainFrameRedirectChain) {
4203 const NavigationControllerImpl& controller =
4204 static_cast<const NavigationControllerImpl&>(
4205 shell()->web_contents()->GetController());
4206
4207 // Navigate the main frame to a redirecting URL (server-side)
4208 GURL final_url(embedded_test_server()->GetURL("/simple_page.html"));
4209 GURL redirecting_url(
4210 embedded_test_server()->GetURL("/server-redirect?/simple_page.html"));
4211 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
4212
4213 // Check last committed NavigationEntry's redirects.
4214 EXPECT_EQ(1, controller.GetEntryCount());
4215 content::NavigationEntry* entry = controller.GetLastCommittedEntry();
4216 EXPECT_EQ(entry->GetRedirectChain().size(), 2u);
4217 EXPECT_EQ(entry->GetRedirectChain()[0], redirecting_url);
4218 EXPECT_EQ(entry->GetRedirectChain()[1], final_url);
4219 }
4220
4221 // Verifies that FrameNavigationEntry's redirect chain is created and stored on
4222 // the right subframe (AUTO_SUBFRAME navigation).
4223 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4224 FrameNavigationEntry_AutoSubFrameRedirectChain) {
4225 const NavigationControllerImpl& controller =
4226 static_cast<const NavigationControllerImpl&>(
4227 shell()->web_contents()->GetController());
4228
4229 GURL main_url(embedded_test_server()->GetURL(
4230 "/navigation_controller/page_with_iframe_redirect.html"));
4231 GURL iframe_redirect_url(
4232 embedded_test_server()->GetURL("/server-redirect?/simple_page.html"));
4233 GURL iframe_final_url(embedded_test_server()->GetURL("/simple_page.html"));
4234
4235 // Navigate to a page with an redirecting iframe.
4236 NavigateToURL(shell(), main_url);
4237
4238 // Check that the main frame redirect chain contains only one url.
4239 EXPECT_EQ(1, controller.GetEntryCount());
4240 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
4241 EXPECT_EQ(entry->GetRedirectChain().size(), 1u);
4242 EXPECT_EQ(entry->GetRedirectChain()[0], main_url);
4243
4244 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
4245 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4246 // Check that the FrameNavigationEntry's redirect chain contains 2 urls.
4247 ASSERT_EQ(1U, entry->root_node()->children.size());
4248 FrameNavigationEntry* frame_entry =
4249 entry->root_node()->children[0]->frame_entry.get();
4250 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u);
4251 EXPECT_EQ(frame_entry->redirect_chain()[0], iframe_redirect_url);
4252 EXPECT_EQ(frame_entry->redirect_chain()[1], iframe_final_url);
4253 }
4254 }
4255
4256 // Verifies that FrameNavigationEntry's redirect chain is created and stored on
4257 // the right subframe (NEW_SUBFRAME navigation).
4258 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4259 FrameNavigationEntry_NewSubFrameRedirectChain) {
4260 const NavigationControllerImpl& controller =
4261 static_cast<const NavigationControllerImpl&>(
4262 shell()->web_contents()->GetController());
4263 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
4264 ->GetFrameTree()
4265 ->root();
4266
4267 // 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.
4268 GURL main_url(embedded_test_server()->GetURL(
4269 "/navigation_controller/page_with_data_iframe.html"));
4270 NavigateToURL(shell(), main_url);
4271 EXPECT_EQ(1, controller.GetEntryCount());
4272
4273 // 2. Navigate in the subframe with a redirection.
4274 GURL frame_final_url(embedded_test_server()->GetURL("/simple_page.html"));
4275 GURL frame_redirect_url(
4276 embedded_test_server()->GetURL("/server-redirect?/simple_page.html"));
4277 NavigateFrameToURL(root->child_at(0), frame_redirect_url);
4278
4279 // Check that the main frame redirect chain contains only the main_url.
4280 EXPECT_EQ(2, controller.GetEntryCount());
4281 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
4282 EXPECT_EQ(entry->GetRedirectChain().size(), 1u);
4283 EXPECT_EQ(entry->GetRedirectChain()[0], main_url);
4284
4285 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
4286 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4287 // Check that the FrameNavigationEntry's redirect chain contains 2 urls.
4288 ASSERT_EQ(1U, entry->root_node()->children.size());
4289 FrameNavigationEntry* frame_entry =
4290 entry->root_node()->children[0]->frame_entry.get();
4291 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u);
4292 EXPECT_EQ(frame_entry->redirect_chain()[0], frame_redirect_url);
4293 EXPECT_EQ(frame_entry->redirect_chain()[1], frame_final_url);
4294 }
4295 }
4296
4199 // Support a set of tests that isolate only a subset of sites with 4297 // Support a set of tests that isolate only a subset of sites with
4200 // out-of-process iframes (OOPIFs). 4298 // out-of-process iframes (OOPIFs).
4201 class NavigationControllerOopifBrowserTest 4299 class NavigationControllerOopifBrowserTest
4202 : public NavigationControllerBrowserTest { 4300 : public NavigationControllerBrowserTest {
4203 public: 4301 public:
4204 NavigationControllerOopifBrowserTest() {} 4302 NavigationControllerOopifBrowserTest() {}
4205 4303
4206 void SetUpCommandLine(base::CommandLine* command_line) override { 4304 void SetUpCommandLine(base::CommandLine* command_line) override {
4207 // Enable the OOPIF framework but only isolate sites from a single TLD. 4305 // Enable the OOPIF framework but only isolate sites from a single TLD.
4208 command_line->AppendSwitchASCII(switches::kIsolateSitesForTesting, "*.is"); 4306 command_line->AppendSwitchASCII(switches::kIsolateSitesForTesting, "*.is");
(...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after
6446 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); 6544 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4);
6447 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); 6545 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3);
6448 6546
6449 controller.ReloadToRefreshContent(false); 6547 controller.ReloadToRefreshContent(false);
6450 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 6548 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
6451 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); 6549 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4);
6452 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); 6550 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3);
6453 } 6551 }
6454 6552
6455 } // namespace content 6553 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698