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

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

Issue 101573003: Add the navigation redirect-chain to Sync sessions proto for offline analysis. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Brett's comment on patch set 46, and rebase. Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 std::vector<GURL> redirects; 1313 std::vector<GURL> redirects;
1314 redirects.push_back(GURL("http://foo2")); 1314 redirects.push_back(GURL("http://foo2"));
1315 1315
1316 // Set non-persisted values on the pending entry. 1316 // Set non-persisted values on the pending entry.
1317 NavigationEntryImpl* pending_entry = 1317 NavigationEntryImpl* pending_entry =
1318 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry()); 1318 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry());
1319 pending_entry->SetBrowserInitiatedPostData(post_data.get()); 1319 pending_entry->SetBrowserInitiatedPostData(post_data.get());
1320 pending_entry->set_is_renderer_initiated(true); 1320 pending_entry->set_is_renderer_initiated(true);
1321 pending_entry->set_transferred_global_request_id(transfer_id); 1321 pending_entry->set_transferred_global_request_id(transfer_id);
1322 pending_entry->set_should_replace_entry(true); 1322 pending_entry->set_should_replace_entry(true);
1323 pending_entry->set_redirect_chain(redirects);
1324 pending_entry->set_should_clear_history_list(true); 1323 pending_entry->set_should_clear_history_list(true);
1325 EXPECT_EQ(post_data.get(), pending_entry->GetBrowserInitiatedPostData()); 1324 EXPECT_EQ(post_data.get(), pending_entry->GetBrowserInitiatedPostData());
1326 EXPECT_TRUE(pending_entry->is_renderer_initiated()); 1325 EXPECT_TRUE(pending_entry->is_renderer_initiated());
1327 EXPECT_EQ(transfer_id, pending_entry->transferred_global_request_id()); 1326 EXPECT_EQ(transfer_id, pending_entry->transferred_global_request_id());
1328 EXPECT_TRUE(pending_entry->should_replace_entry()); 1327 EXPECT_TRUE(pending_entry->should_replace_entry());
1329 EXPECT_EQ(1U, pending_entry->redirect_chain().size());
1330 EXPECT_TRUE(pending_entry->should_clear_history_list()); 1328 EXPECT_TRUE(pending_entry->should_clear_history_list());
1331 1329
1332 main_test_rfh()->SendNavigate(0, url1); 1330 main_test_rfh()->SendNavigate(0, url1);
1333 1331
1334 // Certain values that are only used for pending entries get reset after 1332 // Certain values that are only used for pending entries get reset after
1335 // commit. 1333 // commit.
1336 NavigationEntryImpl* committed_entry = 1334 NavigationEntryImpl* committed_entry =
1337 NavigationEntryImpl::FromNavigationEntry( 1335 NavigationEntryImpl::FromNavigationEntry(
1338 controller.GetLastCommittedEntry()); 1336 controller.GetLastCommittedEntry());
1339 EXPECT_FALSE(committed_entry->GetBrowserInitiatedPostData()); 1337 EXPECT_FALSE(committed_entry->GetBrowserInitiatedPostData());
1340 EXPECT_FALSE(committed_entry->is_renderer_initiated()); 1338 EXPECT_FALSE(committed_entry->is_renderer_initiated());
1341 EXPECT_EQ(GlobalRequestID(-1, -1), 1339 EXPECT_EQ(GlobalRequestID(-1, -1),
1342 committed_entry->transferred_global_request_id()); 1340 committed_entry->transferred_global_request_id());
1343 EXPECT_FALSE(committed_entry->should_replace_entry()); 1341 EXPECT_FALSE(committed_entry->should_replace_entry());
1344 EXPECT_EQ(0U, committed_entry->redirect_chain().size());
1345 EXPECT_FALSE(committed_entry->should_clear_history_list()); 1342 EXPECT_FALSE(committed_entry->should_clear_history_list());
1346 } 1343 }
1347 1344
1345 // Test that Redirects are preserved after a commit.
1346 TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
1347 NavigationControllerImpl& controller = controller_impl();
1348 const GURL url1("http://foo1");
1349 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
1350
1351 // Set up some redirect values.
1352 std::vector<GURL> redirects;
1353 redirects.push_back(GURL("http://foo2"));
1354
1355 // Set redirects on the pending entry.
1356 NavigationEntryImpl* pending_entry =
1357 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry());
1358 pending_entry->SetRedirectChain(redirects);
1359 EXPECT_EQ(1U, pending_entry->GetRedirectChain().size());
1360 EXPECT_EQ(GURL("http://foo2"), pending_entry->GetRedirectChain()[0]);
1361
1362 // Normal navigation will preserve redirects in the committed entry.
1363 main_test_rfh()->SendNavigateWithRedirects(0, url1, redirects);
1364 NavigationEntryImpl* committed_entry =
1365 NavigationEntryImpl::FromNavigationEntry(
1366 controller.GetLastCommittedEntry());
1367 ASSERT_EQ(1U, committed_entry->GetRedirectChain().size());
1368 EXPECT_EQ(GURL("http://foo2"), committed_entry->GetRedirectChain()[0]);
1369 }
1370
1348 // Tests what happens when we navigate back successfully 1371 // Tests what happens when we navigate back successfully
1349 TEST_F(NavigationControllerTest, Back) { 1372 TEST_F(NavigationControllerTest, Back) {
1350 NavigationControllerImpl& controller = controller_impl(); 1373 NavigationControllerImpl& controller = controller_impl();
1351 TestNotificationTracker notifications; 1374 TestNotificationTracker notifications;
1352 RegisterForAllNavNotifications(&notifications, &controller); 1375 RegisterForAllNavNotifications(&notifications, &controller);
1353 1376
1354 const GURL url1("http://foo1"); 1377 const GURL url1("http://foo1");
1355 main_test_rfh()->SendNavigate(0, url1); 1378 main_test_rfh()->SendNavigate(0, url1);
1356 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1379 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1357 navigation_entry_committed_counter_ = 0; 1380 navigation_entry_committed_counter_ = 0;
(...skipping 2681 matching lines...) Expand 10 before | Expand all | Expand 10 after
4039 EXPECT_EQ(1, controller.GetEntryCount()); 4062 EXPECT_EQ(1, controller.GetEntryCount());
4040 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 4063 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
4041 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 4064 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
4042 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 4065 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
4043 EXPECT_FALSE(controller.CanGoBack()); 4066 EXPECT_FALSE(controller.CanGoBack());
4044 EXPECT_FALSE(controller.CanGoForward()); 4067 EXPECT_FALSE(controller.CanGoForward());
4045 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); 4068 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
4046 } 4069 }
4047 4070
4048 } // namespace content 4071 } // 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