Chromium Code Reviews| 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/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 2775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2786 ASSERT_EQ(0u, entries.size()); | 2786 ASSERT_EQ(0u, entries.size()); |
| 2787 | 2787 |
| 2788 // Before navigating to the restored entry, it should have a restore_type | 2788 // Before navigating to the restored entry, it should have a restore_type |
| 2789 // and no SiteInstance. | 2789 // and no SiteInstance. |
| 2790 ASSERT_EQ(1, our_controller.GetEntryCount()); | 2790 ASSERT_EQ(1, our_controller.GetEntryCount()); |
| 2791 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 2791 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
| 2792 our_controller.GetEntryAtIndex(0)->restore_type()); | 2792 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 2793 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); | 2793 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); |
| 2794 | 2794 |
| 2795 // After navigating, we should have one entry, and it should be "pending". | 2795 // After navigating, we should have one entry, and it should be "pending". |
| 2796 // It should now have a SiteInstance and no restore_type. | |
| 2797 our_controller.GoToIndex(0); | 2796 our_controller.GoToIndex(0); |
| 2798 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2797 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 2799 EXPECT_EQ(our_controller.GetEntryAtIndex(0), | 2798 EXPECT_EQ(our_controller.GetEntryAtIndex(0), |
| 2800 our_controller.GetPendingEntry()); | 2799 our_controller.GetPendingEntry()); |
| 2801 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); | 2800 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); |
| 2802 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | |
| 2803 our_controller.GetEntryAtIndex(0)->restore_type()); | |
|
Charlie Reis
2015/07/29 23:58:27
We still need this to be set to RESTORE_NONE at so
Fabrice (no longer in Chrome)
2015/07/30 15:59:26
I'm removing the check here, and restoring the che
| |
| 2804 EXPECT_TRUE(our_controller.GetEntryAtIndex(0)->site_instance()); | |
| 2805 | 2801 |
| 2806 // Timestamp should remain the same before the navigation finishes. | 2802 // Timestamp should remain the same before the navigation finishes. |
| 2807 EXPECT_EQ(timestamp, our_controller.GetEntryAtIndex(0)->GetTimestamp()); | 2803 EXPECT_EQ(timestamp, our_controller.GetEntryAtIndex(0)->GetTimestamp()); |
| 2808 | 2804 |
| 2809 // Say we navigated to that entry. | 2805 // Say we navigated to that entry. |
| 2810 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2806 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2811 params.page_id = 0; | 2807 params.page_id = 0; |
| 2812 params.nav_entry_id = our_controller.GetPendingEntry()->GetUniqueID(); | 2808 params.nav_entry_id = our_controller.GetPendingEntry()->GetUniqueID(); |
| 2813 params.did_create_new_entry = false; | 2809 params.did_create_new_entry = false; |
| 2814 params.url = url; | 2810 params.url = url; |
| 2815 params.transition = ui::PAGE_TRANSITION_LINK; | 2811 params.transition = ui::PAGE_TRANSITION_LINK; |
| 2816 params.should_update_history = false; | 2812 params.should_update_history = false; |
| 2817 params.gesture = NavigationGestureUser; | 2813 params.gesture = NavigationGestureUser; |
| 2818 params.is_post = false; | 2814 params.is_post = false; |
| 2819 params.page_state = PageState::CreateFromURL(url); | 2815 params.page_state = PageState::CreateFromURL(url); |
| 2820 LoadCommittedDetails details; | 2816 LoadCommittedDetails details; |
| 2821 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, | 2817 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, |
| 2822 &details); | 2818 &details); |
| 2823 | 2819 |
| 2824 // There should be no longer any pending entry and one committed one. This | 2820 // There should be no longer any pending entry and one committed one. This |
| 2825 // means that we were able to locate the entry, assign its site instance, and | 2821 // means that we were able to locate the entry, assign its site instance, and |
| 2826 // commit it properly. | 2822 // commit it properly. |
| 2827 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2823 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 2828 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 2824 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
| 2829 EXPECT_FALSE(our_controller.GetPendingEntry()); | 2825 EXPECT_FALSE(our_controller.GetPendingEntry()); |
| 2830 EXPECT_EQ( | 2826 EXPECT_EQ( |
| 2831 url, | 2827 url, |
| 2832 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); | 2828 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); |
| 2833 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | |
| 2834 our_controller.GetEntryAtIndex(0)->restore_type()); | |
|
Charlie Reis
2015/07/29 23:58:27
We definitely need this check.
Fabrice (no longer in Chrome)
2015/07/30 15:59:26
Yes, sorry. Done.
| |
| 2835 | 2829 |
| 2836 // Timestamp should have been updated. | 2830 // Timestamp should have been updated. |
| 2837 EXPECT_GE(our_controller.GetEntryAtIndex(0)->GetTimestamp(), timestamp); | 2831 EXPECT_GE(our_controller.GetEntryAtIndex(0)->GetTimestamp(), timestamp); |
| 2838 } | 2832 } |
| 2839 | 2833 |
| 2840 // Tests that we can still navigate to a restored entry after a different | 2834 // Tests that we can still navigate to a restored entry after a different |
| 2841 // navigation fails and clears the pending entry. http://crbug.com/90085 | 2835 // navigation fails and clears the pending entry. http://crbug.com/90085 |
| 2842 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { | 2836 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { |
| 2843 // Create a NavigationController with a restored set of tabs. | 2837 // Create a NavigationController with a restored set of tabs. |
| 2844 GURL url("http://foo"); | 2838 GURL url("http://foo"); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2863 main_test_rfh()->InitializeRenderFrameIfNeeded(); | 2857 main_test_rfh()->InitializeRenderFrameIfNeeded(); |
| 2864 | 2858 |
| 2865 // Before navigating to the restored entry, it should have a restore_type | 2859 // Before navigating to the restored entry, it should have a restore_type |
| 2866 // and no SiteInstance. | 2860 // and no SiteInstance. |
| 2867 NavigationEntry* entry = our_controller.GetEntryAtIndex(0); | 2861 NavigationEntry* entry = our_controller.GetEntryAtIndex(0); |
| 2868 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 2862 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
| 2869 our_controller.GetEntryAtIndex(0)->restore_type()); | 2863 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 2870 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); | 2864 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); |
| 2871 | 2865 |
| 2872 // After navigating, we should have one entry, and it should be "pending". | 2866 // After navigating, we should have one entry, and it should be "pending". |
| 2873 // It should now have a SiteInstance and no restore_type. | |
| 2874 our_controller.GoToIndex(0); | 2867 our_controller.GoToIndex(0); |
| 2875 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2868 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 2876 EXPECT_EQ(our_controller.GetEntryAtIndex(0), | 2869 EXPECT_EQ(our_controller.GetEntryAtIndex(0), |
| 2877 our_controller.GetPendingEntry()); | 2870 our_controller.GetPendingEntry()); |
| 2878 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); | 2871 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); |
| 2879 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | |
| 2880 our_controller.GetEntryAtIndex(0)->restore_type()); | |
| 2881 EXPECT_TRUE(our_controller.GetEntryAtIndex(0)->site_instance()); | |
| 2882 | 2872 |
| 2883 // This pending navigation may have caused a different navigation to fail, | 2873 // This pending navigation may have caused a different navigation to fail, |
| 2884 // which causes the pending entry to be cleared. | 2874 // which causes the pending entry to be cleared. |
| 2885 FrameHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; | 2875 FrameHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; |
| 2886 fail_load_params.error_code = net::ERR_ABORTED; | 2876 fail_load_params.error_code = net::ERR_ABORTED; |
| 2887 fail_load_params.error_description = base::string16(); | 2877 fail_load_params.error_description = base::string16(); |
| 2888 fail_load_params.url = url; | 2878 fail_load_params.url = url; |
| 2889 fail_load_params.showing_repost_interstitial = false; | 2879 fail_load_params.showing_repost_interstitial = false; |
| 2890 main_test_rfh()->InitializeRenderFrameIfNeeded(); | 2880 main_test_rfh()->InitializeRenderFrameIfNeeded(); |
| 2891 main_test_rfh()->OnMessageReceived( | 2881 main_test_rfh()->OnMessageReceived( |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2907 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, | 2897 our_controller.RendererDidNavigate(our_contents->GetMainFrame(), params, |
| 2908 &details); | 2898 &details); |
| 2909 | 2899 |
| 2910 // There should be no pending entry and one committed one. | 2900 // There should be no pending entry and one committed one. |
| 2911 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2901 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 2912 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 2902 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
| 2913 EXPECT_FALSE(our_controller.GetPendingEntry()); | 2903 EXPECT_FALSE(our_controller.GetPendingEntry()); |
| 2914 EXPECT_EQ( | 2904 EXPECT_EQ( |
| 2915 url, | 2905 url, |
| 2916 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); | 2906 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); |
| 2917 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | |
| 2918 our_controller.GetEntryAtIndex(0)->restore_type()); | |
| 2919 } | 2907 } |
| 2920 | 2908 |
| 2921 // Make sure that the page type and stuff is correct after an interstitial. | 2909 // Make sure that the page type and stuff is correct after an interstitial. |
| 2922 TEST_F(NavigationControllerTest, Interstitial) { | 2910 TEST_F(NavigationControllerTest, Interstitial) { |
| 2923 NavigationControllerImpl& controller = controller_impl(); | 2911 NavigationControllerImpl& controller = controller_impl(); |
| 2924 // First navigate somewhere normal. | 2912 // First navigate somewhere normal. |
| 2925 const GURL url1("http://foo"); | 2913 const GURL url1("http://foo"); |
| 2926 controller.LoadURL( | 2914 controller.LoadURL( |
| 2927 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 2915 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 2928 int entry_id = controller.GetPendingEntry()->GetUniqueID(); | 2916 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| (...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5037 EXPECT_EQ(default_ssl_status.connection_status, | 5025 EXPECT_EQ(default_ssl_status.connection_status, |
| 5038 details.ssl_status.connection_status); | 5026 details.ssl_status.connection_status); |
| 5039 EXPECT_EQ(default_ssl_status.content_status, | 5027 EXPECT_EQ(default_ssl_status.content_status, |
| 5040 details.ssl_status.content_status); | 5028 details.ssl_status.content_status); |
| 5041 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5029 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
| 5042 | 5030 |
| 5043 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5031 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
| 5044 } | 5032 } |
| 5045 | 5033 |
| 5046 } // namespace content | 5034 } // namespace content |
| OLD | NEW |