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

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

Issue 2619063003: Update viewport_meta setting on any navigation. (Closed)
Patch Set: Bring back pending_entry_ null check Created 3 years, 11 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 "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 1640
1641 // Normal navigation will preserve redirects in the committed entry. 1641 // Normal navigation will preserve redirects in the committed entry.
1642 main_test_rfh()->PrepareForCommitWithServerRedirect(url2); 1642 main_test_rfh()->PrepareForCommitWithServerRedirect(url2);
1643 main_test_rfh()->SendNavigateWithModificationCallback(entry_id, true, url1, 1643 main_test_rfh()->SendNavigateWithModificationCallback(entry_id, true, url1,
1644 set_redirects_callback); 1644 set_redirects_callback);
1645 NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry(); 1645 NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry();
1646 ASSERT_EQ(1U, committed_entry->GetRedirectChain().size()); 1646 ASSERT_EQ(1U, committed_entry->GetRedirectChain().size());
1647 EXPECT_EQ(url2, committed_entry->GetRedirectChain()[0]); 1647 EXPECT_EQ(url2, committed_entry->GetRedirectChain()[0]);
1648 } 1648 }
1649 1649
1650 // Tests that webkit preferences are updated when user agent override changes.
1651 TEST_F(NavigationControllerTest, NavigateWithUserAgentOverrideChange) {
1652 NavigationControllerImpl& controller = controller_impl();
1653
1654 int change_counter = 0;
1655 test_rvh()->set_webkit_preferences_changed_counter(&change_counter);
1656
1657 const GURL url1("http://foo/1");
1658 const GURL url2("http://foo/2");
1659
1660 NavigationController::LoadURLParams load_params(url1);
1661 load_params.referrer =
1662 Referrer(GURL("http://referrer"), blink::WebReferrerPolicyDefault);
1663 load_params.transition_type = ui::PAGE_TRANSITION_GENERATED;
1664 load_params.extra_headers = "content-type: text/plain";
1665 load_params.load_type = NavigationController::LOAD_TYPE_DEFAULT;
1666 load_params.is_renderer_initiated = false;
1667 load_params.override_user_agent = NavigationController::UA_OVERRIDE_FALSE;
1668 load_params.transferred_global_request_id = GlobalRequestID(2, 3);
1669 controller.LoadURLWithParams(load_params);
1670 int entry_id = controller.GetPendingEntry()->GetUniqueID();
1671
1672 EXPECT_EQ(false, controller.GetPendingEntry()->GetIsOverridingUserAgent());
1673
1674 main_test_rfh()->PrepareForCommit();
1675 main_test_rfh()->SendNavigate(entry_id, true, url1);
1676
1677 NavigationController::LoadURLParams load_params2(url2);
1678 load_params2.referrer =
1679 Referrer(GURL("http://referrer"), blink::WebReferrerPolicyDefault);
1680 load_params2.transition_type = ui::PAGE_TRANSITION_GENERATED;
1681 load_params2.extra_headers = "content-type: text/plain";
1682 load_params2.load_type = NavigationController::LOAD_TYPE_DEFAULT;
1683 load_params2.is_renderer_initiated = false;
1684 load_params2.override_user_agent = NavigationController::UA_OVERRIDE_TRUE;
1685 load_params2.transferred_global_request_id = GlobalRequestID(4, 5);
1686
1687 controller.LoadURLWithParams(load_params2);
1688 entry_id = controller.GetPendingEntry()->GetUniqueID();
1689 EXPECT_EQ(true, controller.GetPendingEntry()->GetIsOverridingUserAgent());
1690
1691 main_test_rfh()->PrepareForCommit();
1692 main_test_rfh()->SendNavigate(entry_id, true, url2);
1693
1694 EXPECT_EQ(2, change_counter);
Charlie Reis 2017/01/12 19:37:54 Would this test fail without your fix? I thought
aelias_OOO_until_Jul13 2017/01/12 21:19:13 The previous version did fail without the fix, but
1695 }
1696
1650 // Tests what happens when we navigate back successfully 1697 // Tests what happens when we navigate back successfully
1651 TEST_F(NavigationControllerTest, Back) { 1698 TEST_F(NavigationControllerTest, Back) {
1652 NavigationControllerImpl& controller = controller_impl(); 1699 NavigationControllerImpl& controller = controller_impl();
1653 TestNotificationTracker notifications; 1700 TestNotificationTracker notifications;
1654 RegisterForAllNavNotifications(&notifications, &controller); 1701 RegisterForAllNavNotifications(&notifications, &controller);
1655 1702
1656 const GURL url1("http://foo1"); 1703 const GURL url1("http://foo1");
1657 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url1); 1704 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url1);
1658 EXPECT_EQ(1U, navigation_entry_committed_counter_); 1705 EXPECT_EQ(1U, navigation_entry_committed_counter_);
1659 navigation_entry_committed_counter_ = 0; 1706 navigation_entry_committed_counter_ = 0;
(...skipping 3629 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 main_test_rfh()->SimulateNavigationStart(url_1); 5336 main_test_rfh()->SimulateNavigationStart(url_1);
5290 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); 5337 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL());
5291 EXPECT_EQ(ReloadType::NONE, last_reload_type_); 5338 EXPECT_EQ(ReloadType::NONE, last_reload_type_);
5292 5339
5293 main_test_rfh()->SimulateNavigationCommit(url_2); 5340 main_test_rfh()->SimulateNavigationCommit(url_2);
5294 main_test_rfh()->SimulateNavigationCommit(url_1); 5341 main_test_rfh()->SimulateNavigationCommit(url_1);
5295 main_test_rfh()->SimulateNavigationCommit(url_1); 5342 main_test_rfh()->SimulateNavigationCommit(url_1);
5296 } 5343 }
5297 5344
5298 } // namespace content 5345 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698