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

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: Nit 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 NavigateToURLBlockUntilNavigationsComplete(shell(), redirecting_url, 1);
4212 EXPECT_TRUE(IsLastCommittedEntryOfPageType(shell()->web_contents(),
4213 PAGE_TYPE_NORMAL));
4214 EXPECT_TRUE(shell()->web_contents()->GetLastCommittedURL() == final_url);
4215
4216 // Check last committed NavigationEntry's redirects.
4217 EXPECT_EQ(1, controller.GetEntryCount());
4218 content::NavigationEntry* entry = controller.GetLastCommittedEntry();
4219 EXPECT_EQ(entry->GetRedirectChain().size(), 2u);
4220 EXPECT_EQ(entry->GetRedirectChain()[0], redirecting_url);
4221 EXPECT_EQ(entry->GetRedirectChain()[1], final_url);
4222 }
4223
4224 // Verifies that FrameNavigationEntry's redirect chain is created and stored on
4225 // the right subframe (AUTO_SUBFRAME navigation).
4226 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4227 FrameNavigationEntry_AutoSubFrameRedirectChain) {
4228 const NavigationControllerImpl& controller =
4229 static_cast<const NavigationControllerImpl&>(
4230 shell()->web_contents()->GetController());
4231
4232 GURL main_url(embedded_test_server()->GetURL(
4233 "/navigation_controller/page_with_iframe_redirect.html"));
4234 GURL iframe_redirect_url(
4235 embedded_test_server()->GetURL("/server-redirect?/simple_page.html"));
4236 GURL iframe_final_url(embedded_test_server()->GetURL("/simple_page.html"));
4237
4238 // Navigate to a page with an redirecting iframe.
4239 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4240
4241 // Check that the main frame redirect chain contains only one url.
4242 EXPECT_EQ(1, controller.GetEntryCount());
4243 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
4244 EXPECT_EQ(entry->GetRedirectChain().size(), 1u);
4245 EXPECT_EQ(entry->GetRedirectChain()[0], main_url);
4246
4247 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
4248 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4249 // Check that the FrameNavigationEntry's redirect chain contains 2 urls.
4250 ASSERT_EQ(1U, entry->root_node()->children.size());
4251 FrameNavigationEntry* frame_entry =
4252 entry->root_node()->children[0]->frame_entry.get();
4253 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u);
4254 EXPECT_EQ(frame_entry->redirect_chain()[0], iframe_redirect_url);
4255 EXPECT_EQ(frame_entry->redirect_chain()[1], iframe_final_url);
4256 }
4257 }
4258
4259 // Verifies that FrameNavigationEntry's redirect chain is created and stored on
4260 // the right subframe (NEW_SUBFRAME navigation).
4261 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
4262 FrameNavigationEntry_NewSubFrameRedirectChain) {
4263 const NavigationControllerImpl& controller =
4264 static_cast<const NavigationControllerImpl&>(
4265 shell()->web_contents()->GetController());
4266 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
4267 ->GetFrameTree()
4268 ->root();
4269
4270 // 1. Navigate to a page with an iframe.
4271 GURL main_url(embedded_test_server()->GetURL(
4272 "/navigation_controller/page_with_data_iframe.html"));
4273 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4274 EXPECT_EQ(1, controller.GetEntryCount());
4275
4276 // 2. Navigate in the subframe with a redirection.
4277 GURL frame_final_url(embedded_test_server()->GetURL("/simple_page.html"));
4278 GURL frame_redirect_url(
4279 embedded_test_server()->GetURL("/server-redirect?/simple_page.html"));
4280 NavigateFrameToURL(root->child_at(0), frame_redirect_url);
4281
4282 // Check that the main frame redirect chain contains only the main_url.
4283 EXPECT_EQ(2, controller.GetEntryCount());
4284 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
4285 EXPECT_EQ(entry->GetRedirectChain().size(), 1u);
4286 EXPECT_EQ(entry->GetRedirectChain()[0], main_url);
4287
4288 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
4289 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4290 // Check that the FrameNavigationEntry's redirect chain contains 2 urls.
4291 ASSERT_EQ(1U, entry->root_node()->children.size());
4292 FrameNavigationEntry* frame_entry =
4293 entry->root_node()->children[0]->frame_entry.get();
4294 EXPECT_EQ(frame_entry->redirect_chain().size(), 2u);
4295 EXPECT_EQ(frame_entry->redirect_chain()[0], frame_redirect_url);
4296 EXPECT_EQ(frame_entry->redirect_chain()[1], frame_final_url);
4297 }
4298 }
4299
4199 // Support a set of tests that isolate only a subset of sites with 4300 // Support a set of tests that isolate only a subset of sites with
4200 // out-of-process iframes (OOPIFs). 4301 // out-of-process iframes (OOPIFs).
4201 class NavigationControllerOopifBrowserTest 4302 class NavigationControllerOopifBrowserTest
4202 : public NavigationControllerBrowserTest { 4303 : public NavigationControllerBrowserTest {
4203 public: 4304 public:
4204 NavigationControllerOopifBrowserTest() {} 4305 NavigationControllerOopifBrowserTest() {}
4205 4306
4206 void SetUpCommandLine(base::CommandLine* command_line) override { 4307 void SetUpCommandLine(base::CommandLine* command_line) override {
4207 // Enable the OOPIF framework but only isolate sites from a single TLD. 4308 // Enable the OOPIF framework but only isolate sites from a single TLD.
4208 command_line->AppendSwitchASCII(switches::kIsolateSitesForTesting, "*.is"); 4309 command_line->AppendSwitchASCII(switches::kIsolateSitesForTesting, "*.is");
(...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after
6446 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); 6547 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4);
6447 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); 6548 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3);
6448 6549
6449 controller.ReloadToRefreshContent(false); 6550 controller.ReloadToRefreshContent(false);
6450 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 6551 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
6451 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); 6552 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4);
6452 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); 6553 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3);
6453 } 6554 }
6454 6555
6455 } // namespace content 6556 } // 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