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

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

Issue 761013003: PlzNavigate: add support in several navigation controller unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the functions to the TestRenderFrameHost Created 6 years 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/command_line.h"
7 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/stl_util.h" 10 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "content/browser/frame_host/cross_site_transferring_request.h" 14 #include "content/browser/frame_host/cross_site_transferring_request.h"
14 #include "content/browser/frame_host/navigation_controller_impl.h" 15 #include "content/browser/frame_host/navigation_controller_impl.h"
15 #include "content/browser/frame_host/navigation_entry_impl.h" 16 #include "content/browser/frame_host/navigation_entry_impl.h"
16 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" 17 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
17 #include "content/browser/frame_host/navigator.h" 18 #include "content/browser/frame_host/navigator.h"
18 #include "content/browser/site_instance_impl.h" 19 #include "content/browser/site_instance_impl.h"
19 #include "content/browser/web_contents/web_contents_impl.h" 20 #include "content/browser/web_contents/web_contents_impl.h"
20 #include "content/common/frame_messages.h" 21 #include "content/common/frame_messages.h"
21 #include "content/common/view_messages.h" 22 #include "content/common/view_messages.h"
22 #include "content/public/browser/navigation_details.h" 23 #include "content/public/browser/navigation_details.h"
23 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/web_contents_delegate.h" 27 #include "content/public/browser/web_contents_delegate.h"
27 #include "content/public/browser/web_contents_observer.h" 28 #include "content/public/browser/web_contents_observer.h"
29 #include "content/public/common/content_switches.h"
28 #include "content/public/common/page_state.h" 30 #include "content/public/common/page_state.h"
29 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
30 #include "content/public/test/mock_render_process_host.h" 32 #include "content/public/test/mock_render_process_host.h"
31 #include "content/public/test/test_notification_tracker.h" 33 #include "content/public/test/test_notification_tracker.h"
32 #include "content/public/test/test_utils.h" 34 #include "content/public/test/test_utils.h"
33 #include "content/test/test_render_frame_host.h" 35 #include "content/test/test_render_frame_host.h"
34 #include "content/test/test_render_view_host.h" 36 #include "content/test/test_render_view_host.h"
35 #include "content/test/test_web_contents.h" 37 #include "content/test/test_web_contents.h"
36 #include "net/base/net_util.h" 38 #include "net/base/net_util.h"
37 #include "skia/ext/platform_canvas.h" 39 #include "skia/ext/platform_canvas.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry()); 409 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry());
408 // TODO(darin): maybe this should really be true? 410 // TODO(darin): maybe this should really be true?
409 EXPECT_FALSE(controller.CanGoBack()); 411 EXPECT_FALSE(controller.CanGoBack());
410 EXPECT_FALSE(controller.CanGoForward()); 412 EXPECT_FALSE(controller.CanGoForward());
411 EXPECT_EQ(contents()->GetMaxPageID(), 0); 413 EXPECT_EQ(contents()->GetMaxPageID(), 0);
412 414
413 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null()); 415 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null());
414 416
415 // Simulate the beforeunload ack for the cross-site transition, and then the 417 // Simulate the beforeunload ack for the cross-site transition, and then the
416 // commit. 418 // commit.
417 main_test_rfh()->SendBeforeUnloadACK(true); 419 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
nasko 2014/12/16 01:40:26 This code pattern appears few times in this file.
clamy 2014/12/17 15:47:57 Done.
420 switches::kEnableBrowserSideNavigation)) {
421 main_test_rfh()->SimulateIOThread(controller.GetPendingEntry()->GetURL());
422 } else {
423 main_test_rfh()->SendBeforeUnloadACK(true);
424 }
418 contents()->GetPendingMainFrame()->SendNavigate(1, url2); 425 contents()->GetPendingMainFrame()->SendNavigate(1, url2);
419 EXPECT_EQ(1U, navigation_entry_committed_counter_); 426 EXPECT_EQ(1U, navigation_entry_committed_counter_);
420 navigation_entry_committed_counter_ = 0; 427 navigation_entry_committed_counter_ = 0;
421 428
422 // The load should now be committed. 429 // The load should now be committed.
423 EXPECT_EQ(controller.GetEntryCount(), 2); 430 EXPECT_EQ(controller.GetEntryCount(), 2);
424 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); 431 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1);
425 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); 432 EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
426 EXPECT_TRUE(controller.GetLastCommittedEntry()); 433 EXPECT_TRUE(controller.GetLastCommittedEntry());
427 EXPECT_FALSE(controller.GetPendingEntry()); 434 EXPECT_FALSE(controller.GetPendingEntry());
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 EXPECT_EQ(1U, navigation_entry_committed_counter_); 752 EXPECT_EQ(1U, navigation_entry_committed_counter_);
746 navigation_entry_committed_counter_ = 0; 753 navigation_entry_committed_counter_ = 0;
747 754
748 // Make a pending entry to somewhere new. 755 // Make a pending entry to somewhere new.
749 const GURL kExistingURL2("http://bee"); 756 const GURL kExistingURL2("http://bee");
750 controller.LoadURL( 757 controller.LoadURL(
751 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 758 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
752 EXPECT_EQ(0U, notifications.size()); 759 EXPECT_EQ(0U, notifications.size());
753 760
754 // After the beforeunload but before it commits, do a new navigation. 761 // After the beforeunload but before it commits, do a new navigation.
755 main_test_rfh()->SendBeforeUnloadACK(true); 762 main_test_rfh()->SendRendererResponseToNavigation(true, kExistingURL2);
756 const GURL kNewURL("http://see"); 763 const GURL kNewURL("http://see");
757 contents()->GetPendingMainFrame()->SendNavigate(3, kNewURL); 764 contents()->GetMainFrame()->SendNavigate(3, kNewURL);
clamy 2014/12/15 17:01:39 I modified this line because the description of th
Charlie Reis 2014/12/16 23:17:34 Yes, I appear to have broken this in https://coder
758 765
759 // There should no longer be any pending entry, and the third navigation we 766 // There should no longer be any pending entry, and the third navigation we
760 // just made should be committed. 767 // just made should be committed.
761 EXPECT_EQ(1U, navigation_entry_committed_counter_); 768 EXPECT_EQ(1U, navigation_entry_committed_counter_);
762 navigation_entry_committed_counter_ = 0; 769 navigation_entry_committed_counter_ = 0;
763 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 770 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
764 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 771 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
765 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); 772 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL());
766 } 773 }
767 774
(...skipping 22 matching lines...) Expand all
790 797
791 // Now make a pending back/forward navigation. The zeroth entry should be 798 // Now make a pending back/forward navigation. The zeroth entry should be
792 // pending. 799 // pending.
793 controller.GoBack(); 800 controller.GoBack();
794 EXPECT_EQ(0U, notifications.size()); 801 EXPECT_EQ(0U, notifications.size());
795 EXPECT_EQ(0, controller.GetPendingEntryIndex()); 802 EXPECT_EQ(0, controller.GetPendingEntryIndex());
796 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 803 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
797 804
798 // Before that commits, do a new navigation. 805 // Before that commits, do a new navigation.
799 const GURL kNewURL("http://foo/see"); 806 const GURL kNewURL("http://foo/see");
800 LoadCommittedDetails details;
801 main_test_rfh()->SendNavigate(3, kNewURL); 807 main_test_rfh()->SendNavigate(3, kNewURL);
802 808
803 // There should no longer be any pending entry, and the third navigation we 809 // There should no longer be any pending entry, and the third navigation we
804 // just made should be committed. 810 // just made should be committed.
805 EXPECT_EQ(1U, navigation_entry_committed_counter_); 811 EXPECT_EQ(1U, navigation_entry_committed_counter_);
806 navigation_entry_committed_counter_ = 0; 812 navigation_entry_committed_counter_ = 0;
807 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 813 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
808 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 814 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
809 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); 815 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL());
810 } 816 }
(...skipping 13 matching lines...) Expand all
824 // Pretend it has bindings so we can tell if we incorrectly copy it. 830 // Pretend it has bindings so we can tell if we incorrectly copy it.
825 main_test_rfh()->GetRenderViewHost()->AllowBindings(2); 831 main_test_rfh()->GetRenderViewHost()->AllowBindings(2);
826 main_test_rfh()->SendNavigate(0, kExistingURL1); 832 main_test_rfh()->SendNavigate(0, kExistingURL1);
827 EXPECT_EQ(1U, navigation_entry_committed_counter_); 833 EXPECT_EQ(1U, navigation_entry_committed_counter_);
828 navigation_entry_committed_counter_ = 0; 834 navigation_entry_committed_counter_ = 0;
829 835
830 // Navigate cross-process to a second URL. 836 // Navigate cross-process to a second URL.
831 const GURL kExistingURL2("http://foo/eh"); 837 const GURL kExistingURL2("http://foo/eh");
832 controller.LoadURL( 838 controller.LoadURL(
833 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 839 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
834 main_test_rfh()->SendBeforeUnloadACK(true); 840 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
841 switches::kEnableBrowserSideNavigation)) {
842 main_test_rfh()->SimulateIOThread(kExistingURL2);
843 } else {
844 main_test_rfh()->SendBeforeUnloadACK(true);
845 }
835 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); 846 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame();
836 foo_rfh->SendNavigate(1, kExistingURL2); 847 foo_rfh->SendNavigate(1, kExistingURL2);
837 EXPECT_EQ(1U, navigation_entry_committed_counter_); 848 EXPECT_EQ(1U, navigation_entry_committed_counter_);
838 navigation_entry_committed_counter_ = 0; 849 navigation_entry_committed_counter_ = 0;
839 850
840 // Now make a pending back/forward navigation to a privileged entry. 851 // Now make a pending back/forward navigation to a privileged entry.
841 // The zeroth entry should be pending. 852 // The zeroth entry should be pending.
842 controller.GoBack(); 853 controller.GoBack();
843 foo_rfh->SendBeforeUnloadACK(true); 854 foo_rfh->SendBeforeUnloadACK(true);
844 EXPECT_EQ(0U, notifications.size()); 855 EXPECT_EQ(0U, notifications.size());
845 EXPECT_EQ(0, controller.GetPendingEntryIndex()); 856 EXPECT_EQ(0, controller.GetPendingEntryIndex());
846 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 857 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
847 EXPECT_EQ(2, NavigationEntryImpl::FromNavigationEntry( 858 EXPECT_EQ(2, NavigationEntryImpl::FromNavigationEntry(
848 controller.GetPendingEntry())->bindings()); 859 controller.GetPendingEntry())->bindings());
849 860
850 // Before that commits, do a new navigation. 861 // Before that commits, do a new navigation.
851 const GURL kNewURL("http://foo/bee"); 862 const GURL kNewURL("http://foo/bee");
852 LoadCommittedDetails details;
853 foo_rfh->SendNavigate(3, kNewURL); 863 foo_rfh->SendNavigate(3, kNewURL);
854 864
855 // There should no longer be any pending entry, and the third navigation we 865 // There should no longer be any pending entry, and the third navigation we
856 // just made should be committed. 866 // just made should be committed.
857 EXPECT_EQ(1U, navigation_entry_committed_counter_); 867 EXPECT_EQ(1U, navigation_entry_committed_counter_);
858 navigation_entry_committed_counter_ = 0; 868 navigation_entry_committed_counter_ = 0;
859 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 869 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
860 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 870 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
861 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); 871 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL());
862 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( 872 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry(
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 // that orig_rfh belongs to, to prevent it from being destroyed when 1105 // that orig_rfh belongs to, to prevent it from being destroyed when
1096 // it gets swapped out, so that we can reuse orig_rfh when the 1106 // it gets swapped out, so that we can reuse orig_rfh when the
1097 // controller goes back. 1107 // controller goes back.
1098 orig_rfh->GetSiteInstance()->increment_active_frame_count(); 1108 orig_rfh->GetSiteInstance()->increment_active_frame_count();
1099 1109
1100 // Navigate to a second URL, simulate the beforeunload ack for the cross-site 1110 // Navigate to a second URL, simulate the beforeunload ack for the cross-site
1101 // transition, and set bindings on the pending RenderViewHost to simulate a 1111 // transition, and set bindings on the pending RenderViewHost to simulate a
1102 // privileged url. 1112 // privileged url.
1103 controller.LoadURL( 1113 controller.LoadURL(
1104 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1114 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1105 orig_rfh->SendBeforeUnloadACK(true); 1115 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1116 switches::kEnableBrowserSideNavigation)) {
1117 orig_rfh->SimulateIOThread(url2);
1118 } else {
1119 orig_rfh->SendBeforeUnloadACK(true);
1120 }
1106 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); 1121 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame();
1107 new_rfh->GetRenderViewHost()->AllowBindings(1); 1122 new_rfh->GetRenderViewHost()->AllowBindings(1);
1108 new_rfh->SendNavigate(1, url2); 1123 new_rfh->SendNavigate(1, url2);
1109 1124
1110 // The second load should be committed, and bindings should be remembered. 1125 // The second load should be committed, and bindings should be remembered.
1111 EXPECT_EQ(controller.GetEntryCount(), 2); 1126 EXPECT_EQ(controller.GetEntryCount(), 2);
1112 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 1127 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
1113 EXPECT_TRUE(controller.CanGoBack()); 1128 EXPECT_TRUE(controller.CanGoBack());
1114 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry( 1129 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry(
1115 controller.GetLastCommittedEntry())->bindings()); 1130 controller.GetLastCommittedEntry())->bindings());
(...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after
3888 NavigationControllerImpl& controller = controller_impl(); 3903 NavigationControllerImpl& controller = controller_impl();
3889 const GURL url1("http://foo/1"); 3904 const GURL url1("http://foo/1");
3890 const GURL url2("http://foo/2"); 3905 const GURL url2("http://foo/2");
3891 const GURL url3("http://foo/3"); 3906 const GURL url3("http://foo/3");
3892 3907
3893 NavigateAndCommit(url1); 3908 NavigateAndCommit(url1);
3894 NavigateAndCommit(url2); 3909 NavigateAndCommit(url2);
3895 NavigateAndCommit(url3); 3910 NavigateAndCommit(url3);
3896 controller.GoBack(); 3911 controller.GoBack();
3897 contents()->CommitPendingNavigation(); 3912 contents()->CommitPendingNavigation();
3913 process()->sink().ClearMessages();
3898 3914
3899 // Simulate the page calling history.back(). It should create a pending entry. 3915 // Simulate the page calling history.back(). It should create a pending entry.
3900 contents()->OnGoToEntryAtOffset(-1); 3916 contents()->OnGoToEntryAtOffset(-1);
3901 EXPECT_EQ(0, controller.GetPendingEntryIndex()); 3917 EXPECT_EQ(0, controller.GetPendingEntryIndex());
3902 // The actual cross-navigation is suspended until the current RVH tells us 3918 // The actual cross-navigation is suspended until the current RVH tells us
3903 // it unloaded, simulate that. 3919 // it unloaded, simulate that.
3904 contents()->ProceedWithCrossSiteNavigation(); 3920 contents()->ProceedWithCrossSiteNavigation();
3905 // Also make sure we told the page to navigate. 3921 // Also make sure we told the page to navigate.
3906 const IPC::Message* message = 3922 GURL nav_url;
3907 process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); 3923 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
3908 ASSERT_TRUE(message != NULL); 3924 switches::kEnableBrowserSideNavigation)) {
3909 Tuple1<FrameMsg_Navigate_Params> nav_params; 3925 const IPC::Message* message = process()->sink().GetFirstMessageMatching(
nasko 2014/12/16 01:40:26 It seems that this branching logic can be put in a
clamy 2014/12/17 15:47:57 Done.
3910 FrameMsg_Navigate::Read(message, &nav_params); 3926 FrameMsg_RequestNavigation::ID);
3911 EXPECT_EQ(url1, nav_params.a.common_params.url); 3927 ASSERT_TRUE(message != NULL);
3928 Tuple2<CommonNavigationParams, RequestNavigationParams> nav_params;
3929 FrameMsg_RequestNavigation::Read(message, &nav_params);
3930 nav_url = nav_params.a.url;
3931 } else {
3932 const IPC::Message* message =
3933 process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
3934 ASSERT_TRUE(message != NULL);
3935 Tuple1<FrameMsg_Navigate_Params> nav_params;
3936 FrameMsg_Navigate::Read(message, &nav_params);
3937 nav_url = nav_params.a.common_params.url;
3938 }
3939 EXPECT_EQ(url1, nav_url);
3912 process()->sink().ClearMessages(); 3940 process()->sink().ClearMessages();
3913 3941
3914 // Now test history.forward() 3942 // Now test history.forward()
3915 contents()->OnGoToEntryAtOffset(2); 3943 contents()->OnGoToEntryAtOffset(2);
3916 EXPECT_EQ(2, controller.GetPendingEntryIndex()); 3944 EXPECT_EQ(2, controller.GetPendingEntryIndex());
3917 // The actual cross-navigation is suspended until the current RVH tells us 3945 // The actual cross-navigation is suspended until the current RVH tells us
3918 // it unloaded, simulate that. 3946 // it unloaded, simulate that.
3919 contents()->ProceedWithCrossSiteNavigation(); 3947 contents()->ProceedWithCrossSiteNavigation();
3920 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); 3948 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
3921 ASSERT_TRUE(message != NULL); 3949 switches::kEnableBrowserSideNavigation)) {
3922 FrameMsg_Navigate::Read(message, &nav_params); 3950 const IPC::Message* message = process()->sink().GetFirstMessageMatching(
3923 EXPECT_EQ(url3, nav_params.a.common_params.url); 3951 FrameMsg_RequestNavigation::ID);
3952 ASSERT_TRUE(message != NULL);
3953 Tuple2<CommonNavigationParams, RequestNavigationParams> nav_params;
3954 FrameMsg_RequestNavigation::Read(message, &nav_params);
3955 nav_url = nav_params.a.url;
3956 } else {
3957 const IPC::Message* message =
3958 process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
3959 ASSERT_TRUE(message != NULL);
3960 Tuple1<FrameMsg_Navigate_Params> nav_params;
3961 FrameMsg_Navigate::Read(message, &nav_params);
3962 nav_url = nav_params.a.common_params.url;
3963 }
3964 EXPECT_EQ(url3, nav_url);
3924 process()->sink().ClearMessages(); 3965 process()->sink().ClearMessages();
3925 3966
3926 controller.DiscardNonCommittedEntries(); 3967 controller.DiscardNonCommittedEntries();
3927 3968
3928 // Make sure an extravagant history.go() doesn't break. 3969 // Make sure an extravagant history.go() doesn't break.
3929 contents()->OnGoToEntryAtOffset(120); // Out of bounds. 3970 contents()->OnGoToEntryAtOffset(120); // Out of bounds.
3930 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 3971 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
3931 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); 3972 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
3932 EXPECT_TRUE(message == NULL); 3973 switches::kEnableBrowserSideNavigation)) {
3974 const IPC::Message* message = process()->sink().GetFirstMessageMatching(
3975 FrameMsg_RequestNavigation::ID);
3976 EXPECT_TRUE(message == NULL);
3977 } else {
3978 const IPC::Message* message =
3979 process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID);
3980 EXPECT_TRUE(message == NULL);
3981 }
3933 } 3982 }
3934 3983
3935 // Test call to PruneAllButLastCommitted for the only entry. 3984 // Test call to PruneAllButLastCommitted for the only entry.
3936 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { 3985 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) {
3937 NavigationControllerImpl& controller = controller_impl(); 3986 NavigationControllerImpl& controller = controller_impl();
3938 const GURL url1("http://foo1"); 3987 const GURL url1("http://foo1");
3939 NavigateAndCommit(url1); 3988 NavigateAndCommit(url1);
3940 3989
3941 contents()->ExpectSetHistoryOffsetAndLength(0, 1); 3990 contents()->ExpectSetHistoryOffsetAndLength(0, 1);
3942 3991
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
4308 4357
4309 // Verify that the pending entry correctly indicates that the session history 4358 // Verify that the pending entry correctly indicates that the session history
4310 // should be cleared. 4359 // should be cleared.
4311 NavigationEntryImpl* entry = 4360 NavigationEntryImpl* entry =
4312 NavigationEntryImpl::FromNavigationEntry( 4361 NavigationEntryImpl::FromNavigationEntry(
4313 controller.GetPendingEntry()); 4362 controller.GetPendingEntry());
4314 ASSERT_TRUE(entry); 4363 ASSERT_TRUE(entry);
4315 EXPECT_TRUE(entry->should_clear_history_list()); 4364 EXPECT_TRUE(entry->should_clear_history_list());
4316 4365
4317 // Assume that the RF correctly cleared its history and commit the navigation. 4366 // Assume that the RF correctly cleared its history and commit the navigation.
4367 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
4368 switches::kEnableBrowserSideNavigation)) {
4369 contents()->GetMainFrame()->SimulateIOThread(entry->GetURL());
4370 }
4318 contents()->GetPendingMainFrame()-> 4371 contents()->GetPendingMainFrame()->
4319 set_simulate_history_list_was_cleared(true); 4372 set_simulate_history_list_was_cleared(true);
4320 contents()->CommitPendingNavigation(); 4373 contents()->CommitPendingNavigation();
4321 4374
4322 // Verify that the NavigationController's session history was correctly 4375 // Verify that the NavigationController's session history was correctly
4323 // cleared. 4376 // cleared.
4324 EXPECT_EQ(1, controller.GetEntryCount()); 4377 EXPECT_EQ(1, controller.GetEntryCount());
4325 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 4378 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
4326 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 4379 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
4327 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 4380 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4360 params.post_id = -1; 4413 params.post_id = -1;
4361 contents()->GetMainFrame()->SendNavigateWithParams(&params); 4414 contents()->GetMainFrame()->SendNavigateWithParams(&params);
4362 4415
4363 // Now reload. replaceState overrides the POST, so we should not show a 4416 // Now reload. replaceState overrides the POST, so we should not show a
4364 // repost warning dialog. 4417 // repost warning dialog.
4365 controller_impl().Reload(true); 4418 controller_impl().Reload(true);
4366 EXPECT_EQ(0, delegate->repost_form_warning_count()); 4419 EXPECT_EQ(0, delegate->repost_form_warning_count());
4367 } 4420 }
4368 4421
4369 } // namespace content 4422 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_request.h » ('j') | content/browser/frame_host/navigation_request.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698