OLD | NEW |
---|---|
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 } | 206 } |
205 | 207 |
206 const GURL& navigated_url() const { | 208 const GURL& navigated_url() const { |
207 return navigated_url_; | 209 return navigated_url_; |
208 } | 210 } |
209 | 211 |
210 NavigationControllerImpl& controller_impl() { | 212 NavigationControllerImpl& controller_impl() { |
211 return static_cast<NavigationControllerImpl&>(controller()); | 213 return static_cast<NavigationControllerImpl&>(controller()); |
212 } | 214 } |
213 | 215 |
216 const IPC::Message* GetLastNavigationRequest() { | |
217 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
218 switches::kEnableBrowserSideNavigation)) { | |
219 return process()->sink().GetFirstMessageMatching( | |
220 FrameMsg_RequestNavigation::ID); | |
221 } | |
222 return process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); | |
223 } | |
224 | |
225 const GURL GetNavigationURLFromIPC(const IPC::Message* message) { | |
226 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
227 switches::kEnableBrowserSideNavigation)) { | |
228 Tuple2<CommonNavigationParams, RequestNavigationParams> nav_params; | |
229 FrameMsg_RequestNavigation::Read(message, &nav_params); | |
230 return nav_params.a.url; | |
231 } | |
232 Tuple1<FrameMsg_Navigate_Params> nav_params; | |
233 FrameMsg_Navigate::Read(message, &nav_params); | |
234 return nav_params.a.common_params.url; | |
235 } | |
236 | |
214 protected: | 237 protected: |
215 GURL navigated_url_; | 238 GURL navigated_url_; |
216 size_t navigation_entry_committed_counter_; | 239 size_t navigation_entry_committed_counter_; |
217 }; | 240 }; |
218 | 241 |
219 void RegisterForAllNavNotifications(TestNotificationTracker* tracker, | 242 void RegisterForAllNavNotifications(TestNotificationTracker* tracker, |
220 NavigationController* controller) { | 243 NavigationController* controller) { |
221 tracker->ListenFor(NOTIFICATION_NAV_LIST_PRUNED, | 244 tracker->ListenFor(NOTIFICATION_NAV_LIST_PRUNED, |
222 Source<NavigationController>(controller)); | 245 Source<NavigationController>(controller)); |
223 tracker->ListenFor(NOTIFICATION_NAV_ENTRY_CHANGED, | 246 tracker->ListenFor(NOTIFICATION_NAV_ENTRY_CHANGED, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry()); | 430 EXPECT_EQ(controller.GetPendingEntry(), controller.GetVisibleEntry()); |
408 // TODO(darin): maybe this should really be true? | 431 // TODO(darin): maybe this should really be true? |
409 EXPECT_FALSE(controller.CanGoBack()); | 432 EXPECT_FALSE(controller.CanGoBack()); |
410 EXPECT_FALSE(controller.CanGoForward()); | 433 EXPECT_FALSE(controller.CanGoForward()); |
411 EXPECT_EQ(contents()->GetMaxPageID(), 0); | 434 EXPECT_EQ(contents()->GetMaxPageID(), 0); |
412 | 435 |
413 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null()); | 436 EXPECT_TRUE(controller.GetPendingEntry()->GetTimestamp().is_null()); |
414 | 437 |
415 // Simulate the beforeunload ack for the cross-site transition, and then the | 438 // Simulate the beforeunload ack for the cross-site transition, and then the |
416 // commit. | 439 // commit. |
417 main_test_rfh()->SendBeforeUnloadACK(true); | 440 main_test_rfh()->PrepareForCommit(controller.GetPendingEntry()->GetURL()); |
418 contents()->GetPendingMainFrame()->SendNavigate(1, url2); | 441 contents()->GetPendingMainFrame()->SendNavigate(1, url2); |
419 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 442 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
420 navigation_entry_committed_counter_ = 0; | 443 navigation_entry_committed_counter_ = 0; |
421 | 444 |
422 // The load should now be committed. | 445 // The load should now be committed. |
423 EXPECT_EQ(controller.GetEntryCount(), 2); | 446 EXPECT_EQ(controller.GetEntryCount(), 2); |
424 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 447 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
425 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 448 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
426 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 449 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
427 EXPECT_FALSE(controller.GetPendingEntry()); | 450 EXPECT_FALSE(controller.GetPendingEntry()); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
745 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 768 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
746 navigation_entry_committed_counter_ = 0; | 769 navigation_entry_committed_counter_ = 0; |
747 | 770 |
748 // Make a pending entry to somewhere new. | 771 // Make a pending entry to somewhere new. |
749 const GURL kExistingURL2("http://bee"); | 772 const GURL kExistingURL2("http://bee"); |
750 controller.LoadURL( | 773 controller.LoadURL( |
751 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 774 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
752 EXPECT_EQ(0U, notifications.size()); | 775 EXPECT_EQ(0U, notifications.size()); |
753 | 776 |
754 // After the beforeunload but before it commits, do a new navigation. | 777 // After the beforeunload but before it commits, do a new navigation. |
755 main_test_rfh()->SendBeforeUnloadACK(true); | 778 main_test_rfh()->SendRendererResponseToNavigation(true, kExistingURL2); |
nasko
2014/12/17 19:55:38
Isn't this now PrepareForCommit?
clamy
2014/12/18 13:54:42
I think we can use either of them. After SendRende
| |
756 const GURL kNewURL("http://see"); | 779 const GURL kNewURL("http://see"); |
757 contents()->GetPendingMainFrame()->SendNavigate(3, kNewURL); | 780 contents()->GetMainFrame()->SendNavigate(3, kNewURL); |
758 | 781 |
759 // There should no longer be any pending entry, and the third navigation we | 782 // There should no longer be any pending entry, and the third navigation we |
760 // just made should be committed. | 783 // just made should be committed. |
761 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 784 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
762 navigation_entry_committed_counter_ = 0; | 785 navigation_entry_committed_counter_ = 0; |
763 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 786 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
764 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 787 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
765 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 788 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
766 } | 789 } |
767 | 790 |
(...skipping 22 matching lines...) Expand all Loading... | |
790 | 813 |
791 // Now make a pending back/forward navigation. The zeroth entry should be | 814 // Now make a pending back/forward navigation. The zeroth entry should be |
792 // pending. | 815 // pending. |
793 controller.GoBack(); | 816 controller.GoBack(); |
794 EXPECT_EQ(0U, notifications.size()); | 817 EXPECT_EQ(0U, notifications.size()); |
795 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 818 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
796 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 819 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
797 | 820 |
798 // Before that commits, do a new navigation. | 821 // Before that commits, do a new navigation. |
799 const GURL kNewURL("http://foo/see"); | 822 const GURL kNewURL("http://foo/see"); |
800 LoadCommittedDetails details; | |
801 main_test_rfh()->SendNavigate(3, kNewURL); | 823 main_test_rfh()->SendNavigate(3, kNewURL); |
802 | 824 |
803 // There should no longer be any pending entry, and the third navigation we | 825 // There should no longer be any pending entry, and the third navigation we |
804 // just made should be committed. | 826 // just made should be committed. |
805 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 827 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
806 navigation_entry_committed_counter_ = 0; | 828 navigation_entry_committed_counter_ = 0; |
807 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 829 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
808 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 830 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
809 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 831 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
810 } | 832 } |
(...skipping 13 matching lines...) Expand all Loading... | |
824 // Pretend it has bindings so we can tell if we incorrectly copy it. | 846 // Pretend it has bindings so we can tell if we incorrectly copy it. |
825 main_test_rfh()->GetRenderViewHost()->AllowBindings(2); | 847 main_test_rfh()->GetRenderViewHost()->AllowBindings(2); |
826 main_test_rfh()->SendNavigate(0, kExistingURL1); | 848 main_test_rfh()->SendNavigate(0, kExistingURL1); |
827 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 849 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
828 navigation_entry_committed_counter_ = 0; | 850 navigation_entry_committed_counter_ = 0; |
829 | 851 |
830 // Navigate cross-process to a second URL. | 852 // Navigate cross-process to a second URL. |
831 const GURL kExistingURL2("http://foo/eh"); | 853 const GURL kExistingURL2("http://foo/eh"); |
832 controller.LoadURL( | 854 controller.LoadURL( |
833 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 855 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
834 main_test_rfh()->SendBeforeUnloadACK(true); | 856 main_test_rfh()->PrepareForCommit(kExistingURL2); |
835 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); | 857 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); |
836 foo_rfh->SendNavigate(1, kExistingURL2); | 858 foo_rfh->SendNavigate(1, kExistingURL2); |
837 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 859 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
838 navigation_entry_committed_counter_ = 0; | 860 navigation_entry_committed_counter_ = 0; |
839 | 861 |
840 // Now make a pending back/forward navigation to a privileged entry. | 862 // Now make a pending back/forward navigation to a privileged entry. |
841 // The zeroth entry should be pending. | 863 // The zeroth entry should be pending. |
842 controller.GoBack(); | 864 controller.GoBack(); |
843 foo_rfh->SendBeforeUnloadACK(true); | 865 foo_rfh->SendBeforeUnloadACK(true); |
844 EXPECT_EQ(0U, notifications.size()); | 866 EXPECT_EQ(0U, notifications.size()); |
845 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 867 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
846 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 868 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
847 EXPECT_EQ(2, NavigationEntryImpl::FromNavigationEntry( | 869 EXPECT_EQ(2, NavigationEntryImpl::FromNavigationEntry( |
848 controller.GetPendingEntry())->bindings()); | 870 controller.GetPendingEntry())->bindings()); |
849 | 871 |
850 // Before that commits, do a new navigation. | 872 // Before that commits, do a new navigation. |
851 const GURL kNewURL("http://foo/bee"); | 873 const GURL kNewURL("http://foo/bee"); |
852 LoadCommittedDetails details; | |
853 foo_rfh->SendNavigate(3, kNewURL); | 874 foo_rfh->SendNavigate(3, kNewURL); |
854 | 875 |
855 // There should no longer be any pending entry, and the third navigation we | 876 // There should no longer be any pending entry, and the third navigation we |
856 // just made should be committed. | 877 // just made should be committed. |
857 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 878 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
858 navigation_entry_committed_counter_ = 0; | 879 navigation_entry_committed_counter_ = 0; |
859 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 880 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
860 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 881 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
861 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); | 882 EXPECT_EQ(kNewURL, controller.GetVisibleEntry()->GetURL()); |
862 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( | 883 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1095 // that orig_rfh belongs to, to prevent it from being destroyed when | 1116 // 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 | 1117 // it gets swapped out, so that we can reuse orig_rfh when the |
1097 // controller goes back. | 1118 // controller goes back. |
1098 orig_rfh->GetSiteInstance()->increment_active_frame_count(); | 1119 orig_rfh->GetSiteInstance()->increment_active_frame_count(); |
1099 | 1120 |
1100 // Navigate to a second URL, simulate the beforeunload ack for the cross-site | 1121 // 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 | 1122 // transition, and set bindings on the pending RenderViewHost to simulate a |
1102 // privileged url. | 1123 // privileged url. |
1103 controller.LoadURL( | 1124 controller.LoadURL( |
1104 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1125 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
1105 orig_rfh->SendBeforeUnloadACK(true); | 1126 orig_rfh->PrepareForCommit(url2); |
1106 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); | 1127 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); |
1107 new_rfh->GetRenderViewHost()->AllowBindings(1); | 1128 new_rfh->GetRenderViewHost()->AllowBindings(1); |
1108 new_rfh->SendNavigate(1, url2); | 1129 new_rfh->SendNavigate(1, url2); |
1109 | 1130 |
1110 // The second load should be committed, and bindings should be remembered. | 1131 // The second load should be committed, and bindings should be remembered. |
1111 EXPECT_EQ(controller.GetEntryCount(), 2); | 1132 EXPECT_EQ(controller.GetEntryCount(), 2); |
1112 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 1133 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
1113 EXPECT_TRUE(controller.CanGoBack()); | 1134 EXPECT_TRUE(controller.CanGoBack()); |
1114 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry( | 1135 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry( |
1115 controller.GetLastCommittedEntry())->bindings()); | 1136 controller.GetLastCommittedEntry())->bindings()); |
(...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3888 NavigationControllerImpl& controller = controller_impl(); | 3909 NavigationControllerImpl& controller = controller_impl(); |
3889 const GURL url1("http://foo/1"); | 3910 const GURL url1("http://foo/1"); |
3890 const GURL url2("http://foo/2"); | 3911 const GURL url2("http://foo/2"); |
3891 const GURL url3("http://foo/3"); | 3912 const GURL url3("http://foo/3"); |
3892 | 3913 |
3893 NavigateAndCommit(url1); | 3914 NavigateAndCommit(url1); |
3894 NavigateAndCommit(url2); | 3915 NavigateAndCommit(url2); |
3895 NavigateAndCommit(url3); | 3916 NavigateAndCommit(url3); |
3896 controller.GoBack(); | 3917 controller.GoBack(); |
3897 contents()->CommitPendingNavigation(); | 3918 contents()->CommitPendingNavigation(); |
3919 process()->sink().ClearMessages(); | |
3898 | 3920 |
3899 // Simulate the page calling history.back(). It should create a pending entry. | 3921 // Simulate the page calling history.back(). It should create a pending entry. |
3900 contents()->OnGoToEntryAtOffset(-1); | 3922 contents()->OnGoToEntryAtOffset(-1); |
3901 EXPECT_EQ(0, controller.GetPendingEntryIndex()); | 3923 EXPECT_EQ(0, controller.GetPendingEntryIndex()); |
3902 // The actual cross-navigation is suspended until the current RVH tells us | 3924 // The actual cross-navigation is suspended until the current RVH tells us |
3903 // it unloaded, simulate that. | 3925 // it unloaded, simulate that. |
3904 contents()->ProceedWithCrossSiteNavigation(); | 3926 contents()->ProceedWithCrossSiteNavigation(); |
3905 // Also make sure we told the page to navigate. | 3927 // Also make sure we told the page to navigate. |
3906 const IPC::Message* message = | 3928 const IPC::Message* message = GetLastNavigationRequest(); |
3907 process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); | |
3908 ASSERT_TRUE(message != NULL); | 3929 ASSERT_TRUE(message != NULL); |
3909 Tuple1<FrameMsg_Navigate_Params> nav_params; | 3930 GURL nav_url = GetNavigationURLFromIPC(message); |
3910 FrameMsg_Navigate::Read(message, &nav_params); | 3931 EXPECT_EQ(url1, nav_url); |
3911 EXPECT_EQ(url1, nav_params.a.common_params.url); | |
3912 process()->sink().ClearMessages(); | 3932 process()->sink().ClearMessages(); |
3913 | 3933 |
3914 // Now test history.forward() | 3934 // Now test history.forward() |
3915 contents()->OnGoToEntryAtOffset(2); | 3935 contents()->OnGoToEntryAtOffset(2); |
3916 EXPECT_EQ(2, controller.GetPendingEntryIndex()); | 3936 EXPECT_EQ(2, controller.GetPendingEntryIndex()); |
3917 // The actual cross-navigation is suspended until the current RVH tells us | 3937 // The actual cross-navigation is suspended until the current RVH tells us |
3918 // it unloaded, simulate that. | 3938 // it unloaded, simulate that. |
3919 contents()->ProceedWithCrossSiteNavigation(); | 3939 contents()->ProceedWithCrossSiteNavigation(); |
3920 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); | 3940 message = GetLastNavigationRequest(); |
3921 ASSERT_TRUE(message != NULL); | 3941 ASSERT_TRUE(message != NULL); |
3922 FrameMsg_Navigate::Read(message, &nav_params); | 3942 nav_url = GetNavigationURLFromIPC(message); |
3923 EXPECT_EQ(url3, nav_params.a.common_params.url); | 3943 EXPECT_EQ(url3, nav_url); |
3924 process()->sink().ClearMessages(); | 3944 process()->sink().ClearMessages(); |
3925 | 3945 |
3926 controller.DiscardNonCommittedEntries(); | 3946 controller.DiscardNonCommittedEntries(); |
3927 | 3947 |
3928 // Make sure an extravagant history.go() doesn't break. | 3948 // Make sure an extravagant history.go() doesn't break. |
3929 contents()->OnGoToEntryAtOffset(120); // Out of bounds. | 3949 contents()->OnGoToEntryAtOffset(120); // Out of bounds. |
3930 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 3950 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
3931 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); | 3951 message = GetLastNavigationRequest(); |
3932 EXPECT_TRUE(message == NULL); | 3952 EXPECT_TRUE(message == NULL); |
3933 } | 3953 } |
3934 | 3954 |
3935 // Test call to PruneAllButLastCommitted for the only entry. | 3955 // Test call to PruneAllButLastCommitted for the only entry. |
3936 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { | 3956 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { |
3937 NavigationControllerImpl& controller = controller_impl(); | 3957 NavigationControllerImpl& controller = controller_impl(); |
3938 const GURL url1("http://foo1"); | 3958 const GURL url1("http://foo1"); |
3939 NavigateAndCommit(url1); | 3959 NavigateAndCommit(url1); |
3940 | 3960 |
3941 contents()->ExpectSetHistoryOffsetAndLength(0, 1); | 3961 contents()->ExpectSetHistoryOffsetAndLength(0, 1); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4308 | 4328 |
4309 // Verify that the pending entry correctly indicates that the session history | 4329 // Verify that the pending entry correctly indicates that the session history |
4310 // should be cleared. | 4330 // should be cleared. |
4311 NavigationEntryImpl* entry = | 4331 NavigationEntryImpl* entry = |
4312 NavigationEntryImpl::FromNavigationEntry( | 4332 NavigationEntryImpl::FromNavigationEntry( |
4313 controller.GetPendingEntry()); | 4333 controller.GetPendingEntry()); |
4314 ASSERT_TRUE(entry); | 4334 ASSERT_TRUE(entry); |
4315 EXPECT_TRUE(entry->should_clear_history_list()); | 4335 EXPECT_TRUE(entry->should_clear_history_list()); |
4316 | 4336 |
4317 // Assume that the RF correctly cleared its history and commit the navigation. | 4337 // Assume that the RF correctly cleared its history and commit the navigation. |
4338 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
4339 switches::kEnableBrowserSideNavigation)) { | |
4340 contents()->GetMainFrame()->PrepareForCommit(entry->GetURL()); | |
4341 } | |
4318 contents()->GetPendingMainFrame()-> | 4342 contents()->GetPendingMainFrame()-> |
4319 set_simulate_history_list_was_cleared(true); | 4343 set_simulate_history_list_was_cleared(true); |
4320 contents()->CommitPendingNavigation(); | 4344 contents()->CommitPendingNavigation(); |
4321 | 4345 |
4322 // Verify that the NavigationController's session history was correctly | 4346 // Verify that the NavigationController's session history was correctly |
4323 // cleared. | 4347 // cleared. |
4324 EXPECT_EQ(1, controller.GetEntryCount()); | 4348 EXPECT_EQ(1, controller.GetEntryCount()); |
4325 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 4349 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
4326 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4350 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
4327 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 4351 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4360 params.post_id = -1; | 4384 params.post_id = -1; |
4361 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); | 4385 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); |
4362 | 4386 |
4363 // Now reload. replaceState overrides the POST, so we should not show a | 4387 // Now reload. replaceState overrides the POST, so we should not show a |
4364 // repost warning dialog. | 4388 // repost warning dialog. |
4365 controller_impl().Reload(true); | 4389 controller_impl().Reload(true); |
4366 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4390 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
4367 } | 4391 } |
4368 | 4392 |
4369 } // namespace content | 4393 } // namespace content |
OLD | NEW |