| 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 "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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SetUp() override { | 206 void SetUp() override { |
| 207 RenderViewHostImplTestHarness::SetUp(); | 207 RenderViewHostImplTestHarness::SetUp(); |
| 208 WebContents* web_contents = RenderViewHostImplTestHarness::web_contents(); | 208 WebContents* web_contents = RenderViewHostImplTestHarness::web_contents(); |
| 209 ASSERT_TRUE(web_contents); // The WebContents should be created by now. | 209 ASSERT_TRUE(web_contents); // The WebContents should be created by now. |
| 210 WebContentsObserver::Observe(web_contents); | 210 WebContentsObserver::Observe(web_contents); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // WebContentsObserver: | 213 // WebContentsObserver: |
| 214 void DidStartNavigationToPendingEntry( | 214 void DidStartNavigationToPendingEntry(const GURL& url, |
| 215 const GURL& url, | 215 ReloadType reload_type) override { |
| 216 NavigationController::ReloadType reload_type) override { | |
| 217 navigated_url_ = url; | 216 navigated_url_ = url; |
| 218 } | 217 } |
| 219 | 218 |
| 220 void NavigationEntryCommitted( | 219 void NavigationEntryCommitted( |
| 221 const LoadCommittedDetails& load_details) override { | 220 const LoadCommittedDetails& load_details) override { |
| 222 navigation_entry_committed_counter_++; | 221 navigation_entry_committed_counter_++; |
| 223 } | 222 } |
| 224 | 223 |
| 225 const GURL& navigated_url() const { | 224 const GURL& navigated_url() const { |
| 226 return navigated_url_; | 225 return navigated_url_; |
| (...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 params.nav_entry_id = entry_id; | 1965 params.nav_entry_id = entry_id; |
| 1967 params.did_create_new_entry = false; | 1966 params.did_create_new_entry = false; |
| 1968 | 1967 |
| 1969 EXPECT_EQ(0U, notifications.size()); | 1968 EXPECT_EQ(0U, notifications.size()); |
| 1970 LoadCommittedDetailsObserver observer(contents()); | 1969 LoadCommittedDetailsObserver observer(contents()); |
| 1971 main_test_rfh()->PrepareForCommit(); | 1970 main_test_rfh()->PrepareForCommit(); |
| 1972 main_test_rfh()->SendNavigateWithParams(¶ms); | 1971 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 1973 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 1972 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 1974 navigation_entry_committed_counter_ = 0; | 1973 navigation_entry_committed_counter_ = 0; |
| 1975 | 1974 |
| 1976 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); | 1975 EXPECT_EQ(NavigationType::SAME_PAGE, observer.details().type); |
| 1977 EXPECT_EQ(controller.GetEntryCount(), 1); | 1976 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 1978 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 1977 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 1979 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 1978 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 1980 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 1979 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 1981 EXPECT_FALSE(controller.GetPendingEntry()); | 1980 EXPECT_FALSE(controller.GetPendingEntry()); |
| 1982 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 1981 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 1983 | 1982 |
| 1984 EXPECT_FALSE(controller.CanGoBack()); | 1983 EXPECT_FALSE(controller.CanGoBack()); |
| 1985 EXPECT_FALSE(controller.CanGoForward()); | 1984 EXPECT_FALSE(controller.CanGoForward()); |
| 1986 } | 1985 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 params.did_create_new_entry = false; | 2034 params.did_create_new_entry = false; |
| 2036 params.method = "GET"; | 2035 params.method = "GET"; |
| 2037 | 2036 |
| 2038 EXPECT_EQ(0U, notifications.size()); | 2037 EXPECT_EQ(0U, notifications.size()); |
| 2039 LoadCommittedDetailsObserver observer(contents()); | 2038 LoadCommittedDetailsObserver observer(contents()); |
| 2040 main_test_rfh()->PrepareForCommit(); | 2039 main_test_rfh()->PrepareForCommit(); |
| 2041 main_test_rfh()->SendNavigateWithParams(¶ms); | 2040 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 2042 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2041 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2043 navigation_entry_committed_counter_ = 0; | 2042 navigation_entry_committed_counter_ = 0; |
| 2044 | 2043 |
| 2045 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); | 2044 EXPECT_EQ(NavigationType::SAME_PAGE, observer.details().type); |
| 2046 EXPECT_EQ(controller.GetEntryCount(), 1); | 2045 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 2047 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 2046 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 2048 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 2047 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 2049 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 2048 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 2050 EXPECT_FALSE(controller.GetPendingEntry()); | 2049 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2051 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2050 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 2052 EXPECT_FALSE(controller.GetVisibleEntry()->GetHasPostData()); | 2051 EXPECT_FALSE(controller.GetVisibleEntry()->GetHasPostData()); |
| 2053 | 2052 |
| 2054 EXPECT_FALSE(controller.CanGoBack()); | 2053 EXPECT_FALSE(controller.CanGoBack()); |
| 2055 EXPECT_FALSE(controller.CanGoForward()); | 2054 EXPECT_FALSE(controller.CanGoForward()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 params.page_state = PageState::CreateFromURL(url2); | 2086 params.page_state = PageState::CreateFromURL(url2); |
| 2088 | 2087 |
| 2089 LoadCommittedDetailsObserver observer(contents()); | 2088 LoadCommittedDetailsObserver observer(contents()); |
| 2090 | 2089 |
| 2091 EXPECT_EQ(0U, notifications.size()); | 2090 EXPECT_EQ(0U, notifications.size()); |
| 2092 main_test_rfh()->PrepareForCommit(); | 2091 main_test_rfh()->PrepareForCommit(); |
| 2093 main_test_rfh()->SendNavigateWithParams(¶ms); | 2092 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 2094 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2093 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2095 navigation_entry_committed_counter_ = 0; | 2094 navigation_entry_committed_counter_ = 0; |
| 2096 | 2095 |
| 2097 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.details().type); | 2096 EXPECT_EQ(NavigationType::NEW_PAGE, observer.details().type); |
| 2098 EXPECT_EQ(controller.GetEntryCount(), 1); | 2097 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 2099 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 2098 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 2100 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 2099 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 2101 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 2100 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 2102 EXPECT_FALSE(controller.GetPendingEntry()); | 2101 EXPECT_FALSE(controller.GetPendingEntry()); |
| 2103 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 2102 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 2104 | 2103 |
| 2105 EXPECT_FALSE(controller.CanGoBack()); | 2104 EXPECT_FALSE(controller.CanGoBack()); |
| 2106 EXPECT_FALSE(controller.CanGoForward()); | 2105 EXPECT_FALSE(controller.CanGoForward()); |
| 2107 } | 2106 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 params.intended_as_new_entry = true; | 2147 params.intended_as_new_entry = true; |
| 2149 params.did_create_new_entry = false; | 2148 params.did_create_new_entry = false; |
| 2150 params.url = url1; | 2149 params.url = url1; |
| 2151 params.transition = ui::PAGE_TRANSITION_TYPED; | 2150 params.transition = ui::PAGE_TRANSITION_TYPED; |
| 2152 params.page_state = PageState::CreateFromURL(url1); | 2151 params.page_state = PageState::CreateFromURL(url1); |
| 2153 | 2152 |
| 2154 LoadCommittedDetailsObserver observer(contents()); | 2153 LoadCommittedDetailsObserver observer(contents()); |
| 2155 | 2154 |
| 2156 main_test_rfh()->PrepareForCommit(); | 2155 main_test_rfh()->PrepareForCommit(); |
| 2157 main_test_rfh()->SendNavigateWithParams(¶ms); | 2156 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 2158 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.details().type); | 2157 EXPECT_EQ(NavigationType::EXISTING_PAGE, observer.details().type); |
| 2159 } | 2158 } |
| 2160 | 2159 |
| 2161 // Tests navigation via link click within a subframe. A new navigation entry | 2160 // Tests navigation via link click within a subframe. A new navigation entry |
| 2162 // should be created. | 2161 // should be created. |
| 2163 TEST_F(NavigationControllerTest, NewSubframe) { | 2162 TEST_F(NavigationControllerTest, NewSubframe) { |
| 2164 NavigationControllerImpl& controller = controller_impl(); | 2163 NavigationControllerImpl& controller = controller_impl(); |
| 2165 TestNotificationTracker notifications; | 2164 TestNotificationTracker notifications; |
| 2166 RegisterForAllNavNotifications(¬ifications, &controller); | 2165 RegisterForAllNavNotifications(¬ifications, &controller); |
| 2167 | 2166 |
| 2168 const GURL url1("http://foo1"); | 2167 const GURL url1("http://foo1"); |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2967 browser_context()); | 2966 browser_context()); |
| 2968 entry->SetPageID(0); | 2967 entry->SetPageID(0); |
| 2969 entry->SetTitle(base::ASCIIToUTF16("Title")); | 2968 entry->SetTitle(base::ASCIIToUTF16("Title")); |
| 2970 entry->SetPageState(PageState::CreateFromEncodedData("state")); | 2969 entry->SetPageState(PageState::CreateFromEncodedData("state")); |
| 2971 const base::Time timestamp = base::Time::Now(); | 2970 const base::Time timestamp = base::Time::Now(); |
| 2972 entry->SetTimestamp(timestamp); | 2971 entry->SetTimestamp(timestamp); |
| 2973 entries.push_back(std::move(entry)); | 2972 entries.push_back(std::move(entry)); |
| 2974 std::unique_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2973 std::unique_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
| 2975 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2974 WebContents::Create(WebContents::CreateParams(browser_context())))); |
| 2976 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2975 NavigationControllerImpl& our_controller = our_contents->GetController(); |
| 2977 our_controller.Restore( | 2976 our_controller.Restore(0, RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); |
| 2978 0, | |
| 2979 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | |
| 2980 &entries); | |
| 2981 ASSERT_EQ(0u, entries.size()); | 2977 ASSERT_EQ(0u, entries.size()); |
| 2982 | 2978 |
| 2983 // Before navigating to the restored entry, it should have a restore_type | 2979 // Before navigating to the restored entry, it should have a restore_type |
| 2984 // and no SiteInstance. | 2980 // and no SiteInstance. |
| 2985 ASSERT_EQ(1, our_controller.GetEntryCount()); | 2981 ASSERT_EQ(1, our_controller.GetEntryCount()); |
| 2986 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 2982 EXPECT_EQ(RestoreType::LAST_SESSION_EXITED_CLEANLY, |
| 2987 our_controller.GetEntryAtIndex(0)->restore_type()); | 2983 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 2988 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); | 2984 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); |
| 2989 | 2985 |
| 2990 // After navigating, we should have one entry, and it should be "pending". | 2986 // After navigating, we should have one entry, and it should be "pending". |
| 2991 our_controller.GoToIndex(0); | 2987 our_controller.GoToIndex(0); |
| 2992 EXPECT_EQ(1, our_controller.GetEntryCount()); | 2988 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 2993 EXPECT_EQ(our_controller.GetEntryAtIndex(0), | 2989 EXPECT_EQ(our_controller.GetEntryAtIndex(0), |
| 2994 our_controller.GetPendingEntry()); | 2990 our_controller.GetPendingEntry()); |
| 2995 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); | 2991 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); |
| 2996 | 2992 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3015 | 3011 |
| 3016 // There should be no longer any pending entry and one committed one. This | 3012 // There should be no longer any pending entry and one committed one. This |
| 3017 // means that we were able to locate the entry, assign its site instance, and | 3013 // means that we were able to locate the entry, assign its site instance, and |
| 3018 // commit it properly. | 3014 // commit it properly. |
| 3019 EXPECT_EQ(1, our_controller.GetEntryCount()); | 3015 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 3020 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 3016 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
| 3021 EXPECT_FALSE(our_controller.GetPendingEntry()); | 3017 EXPECT_FALSE(our_controller.GetPendingEntry()); |
| 3022 EXPECT_EQ( | 3018 EXPECT_EQ( |
| 3023 url, | 3019 url, |
| 3024 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); | 3020 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); |
| 3025 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | 3021 EXPECT_EQ(RestoreType::NONE, |
| 3026 our_controller.GetEntryAtIndex(0)->restore_type()); | 3022 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 3027 | 3023 |
| 3028 // Timestamp should have been updated. | 3024 // Timestamp should have been updated. |
| 3029 EXPECT_GE(our_controller.GetEntryAtIndex(0)->GetTimestamp(), timestamp); | 3025 EXPECT_GE(our_controller.GetEntryAtIndex(0)->GetTimestamp(), timestamp); |
| 3030 } | 3026 } |
| 3031 | 3027 |
| 3032 // Tests that we can still navigate to a restored entry after a different | 3028 // Tests that we can still navigate to a restored entry after a different |
| 3033 // navigation fails and clears the pending entry. http://crbug.com/90085 | 3029 // navigation fails and clears the pending entry. http://crbug.com/90085 |
| 3034 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { | 3030 TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { |
| 3035 // Create a NavigationController with a restored set of tabs. | 3031 // Create a NavigationController with a restored set of tabs. |
| 3036 GURL url("http://foo"); | 3032 GURL url("http://foo"); |
| 3037 std::vector<std::unique_ptr<NavigationEntry>> entries; | 3033 std::vector<std::unique_ptr<NavigationEntry>> entries; |
| 3038 std::unique_ptr<NavigationEntry> new_entry = | 3034 std::unique_ptr<NavigationEntry> new_entry = |
| 3039 NavigationControllerImpl::CreateNavigationEntry( | 3035 NavigationControllerImpl::CreateNavigationEntry( |
| 3040 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), | 3036 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
| 3041 browser_context()); | 3037 browser_context()); |
| 3042 new_entry->SetPageID(0); | 3038 new_entry->SetPageID(0); |
| 3043 new_entry->SetTitle(base::ASCIIToUTF16("Title")); | 3039 new_entry->SetTitle(base::ASCIIToUTF16("Title")); |
| 3044 new_entry->SetPageState(PageState::CreateFromEncodedData("state")); | 3040 new_entry->SetPageState(PageState::CreateFromEncodedData("state")); |
| 3045 entries.push_back(std::move(new_entry)); | 3041 entries.push_back(std::move(new_entry)); |
| 3046 std::unique_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 3042 std::unique_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
| 3047 WebContents::Create(WebContents::CreateParams(browser_context())))); | 3043 WebContents::Create(WebContents::CreateParams(browser_context())))); |
| 3048 NavigationControllerImpl& our_controller = our_contents->GetController(); | 3044 NavigationControllerImpl& our_controller = our_contents->GetController(); |
| 3049 our_controller.Restore( | 3045 our_controller.Restore(0, RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); |
| 3050 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); | |
| 3051 ASSERT_EQ(0u, entries.size()); | 3046 ASSERT_EQ(0u, entries.size()); |
| 3052 | 3047 |
| 3053 // Ensure the RenderFrame is initialized before simulating events coming from | 3048 // Ensure the RenderFrame is initialized before simulating events coming from |
| 3054 // it. | 3049 // it. |
| 3055 main_test_rfh()->InitializeRenderFrameIfNeeded(); | 3050 main_test_rfh()->InitializeRenderFrameIfNeeded(); |
| 3056 | 3051 |
| 3057 // Before navigating to the restored entry, it should have a restore_type | 3052 // Before navigating to the restored entry, it should have a restore_type |
| 3058 // and no SiteInstance. | 3053 // and no SiteInstance. |
| 3059 NavigationEntry* entry = our_controller.GetEntryAtIndex(0); | 3054 NavigationEntry* entry = our_controller.GetEntryAtIndex(0); |
| 3060 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 3055 EXPECT_EQ(RestoreType::LAST_SESSION_EXITED_CLEANLY, |
| 3061 our_controller.GetEntryAtIndex(0)->restore_type()); | 3056 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 3062 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); | 3057 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); |
| 3063 | 3058 |
| 3064 // After navigating, we should have one entry, and it should be "pending". | 3059 // After navigating, we should have one entry, and it should be "pending". |
| 3065 our_controller.GoToIndex(0); | 3060 our_controller.GoToIndex(0); |
| 3066 EXPECT_EQ(1, our_controller.GetEntryCount()); | 3061 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 3067 EXPECT_EQ(our_controller.GetEntryAtIndex(0), | 3062 EXPECT_EQ(our_controller.GetEntryAtIndex(0), |
| 3068 our_controller.GetPendingEntry()); | 3063 our_controller.GetPendingEntry()); |
| 3069 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); | 3064 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->GetPageID()); |
| 3070 | 3065 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3096 main_rfh->PrepareForCommit(); | 3091 main_rfh->PrepareForCommit(); |
| 3097 main_rfh->SendNavigateWithParams(¶ms); | 3092 main_rfh->SendNavigateWithParams(¶ms); |
| 3098 | 3093 |
| 3099 // There should be no pending entry and one committed one. | 3094 // There should be no pending entry and one committed one. |
| 3100 EXPECT_EQ(1, our_controller.GetEntryCount()); | 3095 EXPECT_EQ(1, our_controller.GetEntryCount()); |
| 3101 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); | 3096 EXPECT_EQ(0, our_controller.GetLastCommittedEntryIndex()); |
| 3102 EXPECT_FALSE(our_controller.GetPendingEntry()); | 3097 EXPECT_FALSE(our_controller.GetPendingEntry()); |
| 3103 EXPECT_EQ( | 3098 EXPECT_EQ( |
| 3104 url, | 3099 url, |
| 3105 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); | 3100 our_controller.GetLastCommittedEntry()->site_instance()->GetSiteURL()); |
| 3106 EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, | 3101 EXPECT_EQ(RestoreType::NONE, |
| 3107 our_controller.GetEntryAtIndex(0)->restore_type()); | 3102 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 3108 } | 3103 } |
| 3109 | 3104 |
| 3110 // Make sure that the page type and stuff is correct after an interstitial. | 3105 // Make sure that the page type and stuff is correct after an interstitial. |
| 3111 TEST_F(NavigationControllerTest, Interstitial) { | 3106 TEST_F(NavigationControllerTest, Interstitial) { |
| 3112 NavigationControllerImpl& controller = controller_impl(); | 3107 NavigationControllerImpl& controller = controller_impl(); |
| 3113 // First navigate somewhere normal. | 3108 // First navigate somewhere normal. |
| 3114 const GURL url1("http://foo"); | 3109 const GURL url1("http://foo"); |
| 3115 controller.LoadURL( | 3110 controller.LoadURL( |
| 3116 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3111 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| (...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4619 std::string(), browser_context()); | 4614 std::string(), browser_context()); |
| 4620 entry->SetPageID(static_cast<int>(i)); | 4615 entry->SetPageID(static_cast<int>(i)); |
| 4621 entries.push_back(std::move(entry)); | 4616 entries.push_back(std::move(entry)); |
| 4622 } | 4617 } |
| 4623 | 4618 |
| 4624 // Create a WebContents with restored entries. | 4619 // Create a WebContents with restored entries. |
| 4625 std::unique_ptr<TestWebContents> source_contents( | 4620 std::unique_ptr<TestWebContents> source_contents( |
| 4626 static_cast<TestWebContents*>(CreateTestWebContents())); | 4621 static_cast<TestWebContents*>(CreateTestWebContents())); |
| 4627 NavigationControllerImpl& source_controller = | 4622 NavigationControllerImpl& source_controller = |
| 4628 source_contents->GetController(); | 4623 source_contents->GetController(); |
| 4629 source_controller.Restore( | 4624 source_controller.Restore(entries.size() - 1, |
| 4630 entries.size() - 1, | 4625 RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); |
| 4631 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | |
| 4632 &entries); | |
| 4633 ASSERT_EQ(0u, entries.size()); | 4626 ASSERT_EQ(0u, entries.size()); |
| 4634 source_controller.LoadIfNecessary(); | 4627 source_controller.LoadIfNecessary(); |
| 4635 source_contents->CommitPendingNavigation(); | 4628 source_contents->CommitPendingNavigation(); |
| 4636 | 4629 |
| 4637 // Load a page, then copy state from |source_contents|. | 4630 // Load a page, then copy state from |source_contents|. |
| 4638 NavigateAndCommit(kInitialUrl); | 4631 NavigateAndCommit(kInitialUrl); |
| 4639 contents()->ExpectSetHistoryOffsetAndLength(2, 3); | 4632 contents()->ExpectSetHistoryOffsetAndLength(2, 3); |
| 4640 controller_impl().CopyStateFromAndPrune(&source_controller, false); | 4633 controller_impl().CopyStateFromAndPrune(&source_controller, false); |
| 4641 ASSERT_EQ(3, controller_impl().GetEntryCount()); | 4634 ASSERT_EQ(3, controller_impl().GetEntryCount()); |
| 4642 | 4635 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5179 params.url_is_unreachable = true; | 5172 params.url_is_unreachable = true; |
| 5180 | 5173 |
| 5181 // Navigate to new page. | 5174 // Navigate to new page. |
| 5182 { | 5175 { |
| 5183 LoadCommittedDetailsObserver observer(contents()); | 5176 LoadCommittedDetailsObserver observer(contents()); |
| 5184 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); | 5177 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); |
| 5185 main_test_rfh()->PrepareForCommit(); | 5178 main_test_rfh()->PrepareForCommit(); |
| 5186 main_test_rfh()->SendNavigateWithParams(¶ms); | 5179 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 5187 EXPECT_EQ(PAGE_TYPE_ERROR, | 5180 EXPECT_EQ(PAGE_TYPE_ERROR, |
| 5188 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5181 controller_impl().GetLastCommittedEntry()->GetPageType()); |
| 5189 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.details().type); | 5182 EXPECT_EQ(NavigationType::NEW_PAGE, observer.details().type); |
| 5190 } | 5183 } |
| 5191 | 5184 |
| 5192 // Navigate to existing page. | 5185 // Navigate to existing page. |
| 5193 { | 5186 { |
| 5194 params.did_create_new_entry = false; | 5187 params.did_create_new_entry = false; |
| 5195 LoadCommittedDetailsObserver observer(contents()); | 5188 LoadCommittedDetailsObserver observer(contents()); |
| 5196 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); | 5189 main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false); |
| 5197 main_test_rfh()->PrepareForCommit(); | 5190 main_test_rfh()->PrepareForCommit(); |
| 5198 main_test_rfh()->SendNavigateWithParams(¶ms); | 5191 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 5199 EXPECT_EQ(PAGE_TYPE_ERROR, | 5192 EXPECT_EQ(PAGE_TYPE_ERROR, |
| 5200 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5193 controller_impl().GetLastCommittedEntry()->GetPageType()); |
| 5201 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.details().type); | 5194 EXPECT_EQ(NavigationType::EXISTING_PAGE, observer.details().type); |
| 5202 } | 5195 } |
| 5203 | 5196 |
| 5204 // Navigate to same page. | 5197 // Navigate to same page. |
| 5205 // Note: The call to LoadURL() creates a pending entry in order to trigger the | 5198 // Note: The call to LoadURL() creates a pending entry in order to trigger the |
| 5206 // same-page transition. | 5199 // same-page transition. |
| 5207 controller_impl().LoadURL( | 5200 controller_impl().LoadURL( |
| 5208 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 5201 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 5209 params.nav_entry_id = controller_impl().GetPendingEntry()->GetUniqueID(); | 5202 params.nav_entry_id = controller_impl().GetPendingEntry()->GetUniqueID(); |
| 5210 params.transition = ui::PAGE_TRANSITION_TYPED; | 5203 params.transition = ui::PAGE_TRANSITION_TYPED; |
| 5211 { | 5204 { |
| 5212 LoadCommittedDetailsObserver observer(contents()); | 5205 LoadCommittedDetailsObserver observer(contents()); |
| 5213 main_test_rfh()->PrepareForCommit(); | 5206 main_test_rfh()->PrepareForCommit(); |
| 5214 main_test_rfh()->SendNavigateWithParams(¶ms); | 5207 main_test_rfh()->SendNavigateWithParams(¶ms); |
| 5215 EXPECT_EQ(PAGE_TYPE_ERROR, | 5208 EXPECT_EQ(PAGE_TYPE_ERROR, |
| 5216 controller_impl().GetLastCommittedEntry()->GetPageType()); | 5209 controller_impl().GetLastCommittedEntry()->GetPageType()); |
| 5217 EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type); | 5210 EXPECT_EQ(NavigationType::SAME_PAGE, observer.details().type); |
| 5218 } | 5211 } |
| 5219 | 5212 |
| 5220 // Navigate in page. | 5213 // Navigate in page. |
| 5221 params.url = GURL("http://foo#foo"); | 5214 params.url = GURL("http://foo#foo"); |
| 5222 params.transition = ui::PAGE_TRANSITION_LINK; | 5215 params.transition = ui::PAGE_TRANSITION_LINK; |
| 5223 params.was_within_same_page = true; | 5216 params.was_within_same_page = true; |
| 5224 { | 5217 { |
| 5225 LoadCommittedDetailsObserver observer(contents()); | 5218 LoadCommittedDetailsObserver observer(contents()); |
| 5226 main_test_rfh()->SendRendererInitiatedNavigationRequest(params.url, false); | 5219 main_test_rfh()->SendRendererInitiatedNavigationRequest(params.url, false); |
| 5227 main_test_rfh()->PrepareForCommit(); | 5220 main_test_rfh()->PrepareForCommit(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5330 EXPECT_EQ(default_ssl_status.connection_status, | 5323 EXPECT_EQ(default_ssl_status.connection_status, |
| 5331 observer.details().ssl_status.connection_status); | 5324 observer.details().ssl_status.connection_status); |
| 5332 EXPECT_EQ(default_ssl_status.content_status, | 5325 EXPECT_EQ(default_ssl_status.content_status, |
| 5333 observer.details().ssl_status.content_status); | 5326 observer.details().ssl_status.content_status); |
| 5334 EXPECT_EQ(default_ssl_status.sct_statuses, | 5327 EXPECT_EQ(default_ssl_status.sct_statuses, |
| 5335 observer.details().ssl_status.sct_statuses); | 5328 observer.details().ssl_status.sct_statuses); |
| 5336 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5329 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
| 5337 } | 5330 } |
| 5338 | 5331 |
| 5339 } // namespace content | 5332 } // namespace content |
| OLD | NEW |