| 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" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> |
| 7 | 10 |
| 8 #include "base/bind.h" | 11 #include "base/bind.h" |
| 9 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 10 #include "base/macros.h" | 13 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 16 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 17 #include "content/browser/frame_host/cross_site_transferring_request.h" | 20 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 18 #include "content/browser/frame_host/frame_navigation_entry.h" | 21 #include "content/browser/frame_host/frame_navigation_entry.h" |
| 19 #include "content/browser/frame_host/navigation_controller_impl.h" | |
| 20 #include "content/browser/frame_host/navigation_entry_impl.h" | 22 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 21 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 23 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
| 22 #include "content/browser/frame_host/navigation_request.h" | 24 #include "content/browser/frame_host/navigation_request.h" |
| 23 #include "content/browser/frame_host/navigator.h" | 25 #include "content/browser/frame_host/navigator.h" |
| 24 #include "content/browser/frame_host/navigator_impl.h" | 26 #include "content/browser/frame_host/navigator_impl.h" |
| 25 #include "content/browser/site_instance_impl.h" | 27 #include "content/browser/site_instance_impl.h" |
| 26 #include "content/browser/web_contents/web_contents_impl.h" | 28 #include "content/browser/web_contents/web_contents_impl.h" |
| 27 #include "content/common/frame_messages.h" | 29 #include "content/common/frame_messages.h" |
| 28 #include "content/common/site_isolation_policy.h" | 30 #include "content/common/site_isolation_policy.h" |
| 29 #include "content/common/ssl_status_serialization.h" | 31 #include "content/common/ssl_status_serialization.h" |
| (...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2794 std::vector<scoped_ptr<NavigationEntry>> entries; | 2796 std::vector<scoped_ptr<NavigationEntry>> entries; |
| 2795 scoped_ptr<NavigationEntry> entry = | 2797 scoped_ptr<NavigationEntry> entry = |
| 2796 NavigationControllerImpl::CreateNavigationEntry( | 2798 NavigationControllerImpl::CreateNavigationEntry( |
| 2797 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), | 2799 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
| 2798 browser_context()); | 2800 browser_context()); |
| 2799 entry->SetPageID(0); | 2801 entry->SetPageID(0); |
| 2800 entry->SetTitle(base::ASCIIToUTF16("Title")); | 2802 entry->SetTitle(base::ASCIIToUTF16("Title")); |
| 2801 entry->SetPageState(PageState::CreateFromEncodedData("state")); | 2803 entry->SetPageState(PageState::CreateFromEncodedData("state")); |
| 2802 const base::Time timestamp = base::Time::Now(); | 2804 const base::Time timestamp = base::Time::Now(); |
| 2803 entry->SetTimestamp(timestamp); | 2805 entry->SetTimestamp(timestamp); |
| 2804 entries.push_back(entry.Pass()); | 2806 entries.push_back(std::move(entry)); |
| 2805 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2807 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
| 2806 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2808 WebContents::Create(WebContents::CreateParams(browser_context())))); |
| 2807 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2809 NavigationControllerImpl& our_controller = our_contents->GetController(); |
| 2808 our_controller.Restore( | 2810 our_controller.Restore( |
| 2809 0, | 2811 0, |
| 2810 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 2812 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
| 2811 &entries); | 2813 &entries); |
| 2812 ASSERT_EQ(0u, entries.size()); | 2814 ASSERT_EQ(0u, entries.size()); |
| 2813 | 2815 |
| 2814 // Before navigating to the restored entry, it should have a restore_type | 2816 // Before navigating to the restored entry, it should have a restore_type |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 // Create a NavigationController with a restored set of tabs. | 2867 // Create a NavigationController with a restored set of tabs. |
| 2866 GURL url("http://foo"); | 2868 GURL url("http://foo"); |
| 2867 std::vector<scoped_ptr<NavigationEntry>> entries; | 2869 std::vector<scoped_ptr<NavigationEntry>> entries; |
| 2868 scoped_ptr<NavigationEntry> new_entry = | 2870 scoped_ptr<NavigationEntry> new_entry = |
| 2869 NavigationControllerImpl::CreateNavigationEntry( | 2871 NavigationControllerImpl::CreateNavigationEntry( |
| 2870 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), | 2872 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
| 2871 browser_context()); | 2873 browser_context()); |
| 2872 new_entry->SetPageID(0); | 2874 new_entry->SetPageID(0); |
| 2873 new_entry->SetTitle(base::ASCIIToUTF16("Title")); | 2875 new_entry->SetTitle(base::ASCIIToUTF16("Title")); |
| 2874 new_entry->SetPageState(PageState::CreateFromEncodedData("state")); | 2876 new_entry->SetPageState(PageState::CreateFromEncodedData("state")); |
| 2875 entries.push_back(new_entry.Pass()); | 2877 entries.push_back(std::move(new_entry)); |
| 2876 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2878 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
| 2877 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2879 WebContents::Create(WebContents::CreateParams(browser_context())))); |
| 2878 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2880 NavigationControllerImpl& our_controller = our_contents->GetController(); |
| 2879 our_controller.Restore( | 2881 our_controller.Restore( |
| 2880 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); | 2882 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); |
| 2881 ASSERT_EQ(0u, entries.size()); | 2883 ASSERT_EQ(0u, entries.size()); |
| 2882 | 2884 |
| 2883 // Ensure the RenderFrame is initialized before simulating events coming from | 2885 // Ensure the RenderFrame is initialized before simulating events coming from |
| 2884 // it. | 2886 // it. |
| 2885 main_test_rfh()->InitializeRenderFrameIfNeeded(); | 2887 main_test_rfh()->InitializeRenderFrameIfNeeded(); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3106 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3108 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 3107 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3109 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3108 main_test_rfh()->PrepareForCommit(); | 3110 main_test_rfh()->PrepareForCommit(); |
| 3109 main_test_rfh()->SendNavigate(1, entry_id, true, url1); | 3111 main_test_rfh()->SendNavigate(1, entry_id, true, url1); |
| 3110 | 3112 |
| 3111 notifications.Reset(); | 3113 notifications.Reset(); |
| 3112 | 3114 |
| 3113 // Adding a transient with no pending entry. | 3115 // Adding a transient with no pending entry. |
| 3114 scoped_ptr<NavigationEntry> transient_entry(new NavigationEntryImpl); | 3116 scoped_ptr<NavigationEntry> transient_entry(new NavigationEntryImpl); |
| 3115 transient_entry->SetURL(transient_url); | 3117 transient_entry->SetURL(transient_url); |
| 3116 controller.SetTransientEntry(transient_entry.Pass()); | 3118 controller.SetTransientEntry(std::move(transient_entry)); |
| 3117 | 3119 |
| 3118 // We should not have received any notifications. | 3120 // We should not have received any notifications. |
| 3119 EXPECT_EQ(0U, notifications.size()); | 3121 EXPECT_EQ(0U, notifications.size()); |
| 3120 | 3122 |
| 3121 // Check our state. | 3123 // Check our state. |
| 3122 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3124 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3123 EXPECT_EQ(controller.GetEntryCount(), 3); | 3125 EXPECT_EQ(controller.GetEntryCount(), 3); |
| 3124 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 3126 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 3125 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 3127 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 3126 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 3128 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 3127 EXPECT_FALSE(controller.GetPendingEntry()); | 3129 EXPECT_FALSE(controller.GetPendingEntry()); |
| 3128 EXPECT_TRUE(controller.CanGoBack()); | 3130 EXPECT_TRUE(controller.CanGoBack()); |
| 3129 EXPECT_FALSE(controller.CanGoForward()); | 3131 EXPECT_FALSE(controller.CanGoForward()); |
| 3130 EXPECT_EQ(contents()->GetMaxPageID(), 1); | 3132 EXPECT_EQ(contents()->GetMaxPageID(), 1); |
| 3131 | 3133 |
| 3132 // Navigate. | 3134 // Navigate. |
| 3133 controller.LoadURL( | 3135 controller.LoadURL( |
| 3134 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3136 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 3135 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3137 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3136 main_test_rfh()->PrepareForCommit(); | 3138 main_test_rfh()->PrepareForCommit(); |
| 3137 main_test_rfh()->SendNavigate(2, entry_id, true, url2); | 3139 main_test_rfh()->SendNavigate(2, entry_id, true, url2); |
| 3138 | 3140 |
| 3139 // We should have navigated, transient entry should be gone. | 3141 // We should have navigated, transient entry should be gone. |
| 3140 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 3142 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 3141 EXPECT_EQ(controller.GetEntryCount(), 3); | 3143 EXPECT_EQ(controller.GetEntryCount(), 3); |
| 3142 | 3144 |
| 3143 // Add a transient again, then navigate with no pending entry this time. | 3145 // Add a transient again, then navigate with no pending entry this time. |
| 3144 transient_entry.reset(new NavigationEntryImpl); | 3146 transient_entry.reset(new NavigationEntryImpl); |
| 3145 transient_entry->SetURL(transient_url); | 3147 transient_entry->SetURL(transient_url); |
| 3146 controller.SetTransientEntry(transient_entry.Pass()); | 3148 controller.SetTransientEntry(std::move(transient_entry)); |
| 3147 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3149 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3148 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, true); | 3150 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, true); |
| 3149 main_test_rfh()->PrepareForCommit(); | 3151 main_test_rfh()->PrepareForCommit(); |
| 3150 main_test_rfh()->SendNavigate(3, 0, true, url3); | 3152 main_test_rfh()->SendNavigate(3, 0, true, url3); |
| 3151 // Transient entry should be gone. | 3153 // Transient entry should be gone. |
| 3152 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 3154 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 3153 EXPECT_EQ(controller.GetEntryCount(), 4); | 3155 EXPECT_EQ(controller.GetEntryCount(), 4); |
| 3154 | 3156 |
| 3155 // Initiate a navigation, add a transient then commit navigation. | 3157 // Initiate a navigation, add a transient then commit navigation. |
| 3156 controller.LoadURL( | 3158 controller.LoadURL( |
| 3157 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3159 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 3158 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3160 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3159 transient_entry.reset(new NavigationEntryImpl); | 3161 transient_entry.reset(new NavigationEntryImpl); |
| 3160 transient_entry->SetURL(transient_url); | 3162 transient_entry->SetURL(transient_url); |
| 3161 controller.SetTransientEntry(transient_entry.Pass()); | 3163 controller.SetTransientEntry(std::move(transient_entry)); |
| 3162 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3164 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3163 main_test_rfh()->PrepareForCommit(); | 3165 main_test_rfh()->PrepareForCommit(); |
| 3164 main_test_rfh()->SendNavigate(4, entry_id, true, url4); | 3166 main_test_rfh()->SendNavigate(4, entry_id, true, url4); |
| 3165 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); | 3167 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); |
| 3166 EXPECT_EQ(controller.GetEntryCount(), 5); | 3168 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 3167 | 3169 |
| 3168 // Add a transient and go back. This should simply remove the transient. | 3170 // Add a transient and go back. This should simply remove the transient. |
| 3169 transient_entry.reset(new NavigationEntryImpl); | 3171 transient_entry.reset(new NavigationEntryImpl); |
| 3170 transient_entry->SetURL(transient_url); | 3172 transient_entry->SetURL(transient_url); |
| 3171 controller.SetTransientEntry(transient_entry.Pass()); | 3173 controller.SetTransientEntry(std::move(transient_entry)); |
| 3172 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3174 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3173 EXPECT_TRUE(controller.CanGoBack()); | 3175 EXPECT_TRUE(controller.CanGoBack()); |
| 3174 EXPECT_FALSE(controller.CanGoForward()); | 3176 EXPECT_FALSE(controller.CanGoForward()); |
| 3175 controller.GoBack(); | 3177 controller.GoBack(); |
| 3176 // Transient entry should be gone. | 3178 // Transient entry should be gone. |
| 3177 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); | 3179 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); |
| 3178 EXPECT_EQ(controller.GetEntryCount(), 5); | 3180 EXPECT_EQ(controller.GetEntryCount(), 5); |
| 3179 | 3181 |
| 3180 // Suppose the page requested a history navigation backward. | 3182 // Suppose the page requested a history navigation backward. |
| 3181 controller.GoToOffset(-1); | 3183 controller.GoToOffset(-1); |
| 3182 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3184 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3183 main_test_rfh()->PrepareForCommit(); | 3185 main_test_rfh()->PrepareForCommit(); |
| 3184 main_test_rfh()->SendNavigate(3, entry_id, false, url3); | 3186 main_test_rfh()->SendNavigate(3, entry_id, false, url3); |
| 3185 | 3187 |
| 3186 // Add a transient and go to an entry before the current one. | 3188 // Add a transient and go to an entry before the current one. |
| 3187 transient_entry.reset(new NavigationEntryImpl); | 3189 transient_entry.reset(new NavigationEntryImpl); |
| 3188 transient_entry->SetURL(transient_url); | 3190 transient_entry->SetURL(transient_url); |
| 3189 controller.SetTransientEntry(transient_entry.Pass()); | 3191 controller.SetTransientEntry(std::move(transient_entry)); |
| 3190 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3192 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3191 controller.GoToIndex(1); | 3193 controller.GoToIndex(1); |
| 3192 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3194 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3193 // The navigation should have been initiated, transient entry should be gone. | 3195 // The navigation should have been initiated, transient entry should be gone. |
| 3194 EXPECT_FALSE(controller.GetTransientEntry()); | 3196 EXPECT_FALSE(controller.GetTransientEntry()); |
| 3195 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 3197 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
| 3196 // Visible entry does not update for history navigations until commit. | 3198 // Visible entry does not update for history navigations until commit. |
| 3197 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 3199 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 3198 main_test_rfh()->PrepareForCommit(); | 3200 main_test_rfh()->PrepareForCommit(); |
| 3199 main_test_rfh()->SendNavigate(1, entry_id, false, url1); | 3201 main_test_rfh()->SendNavigate(1, entry_id, false, url1); |
| 3200 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 3202 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| 3201 | 3203 |
| 3202 // Add a transient and go to an entry after the current one. | 3204 // Add a transient and go to an entry after the current one. |
| 3203 transient_entry.reset(new NavigationEntryImpl); | 3205 transient_entry.reset(new NavigationEntryImpl); |
| 3204 transient_entry->SetURL(transient_url); | 3206 transient_entry->SetURL(transient_url); |
| 3205 controller.SetTransientEntry(transient_entry.Pass()); | 3207 controller.SetTransientEntry(std::move(transient_entry)); |
| 3206 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3208 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3207 controller.GoToIndex(3); | 3209 controller.GoToIndex(3); |
| 3208 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3210 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3209 // The navigation should have been initiated, transient entry should be gone. | 3211 // The navigation should have been initiated, transient entry should be gone. |
| 3210 // Because of the transient entry that is removed, going to index 3 makes us | 3212 // Because of the transient entry that is removed, going to index 3 makes us |
| 3211 // land on url2 (which is visible after the commit). | 3213 // land on url2 (which is visible after the commit). |
| 3212 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); | 3214 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); |
| 3213 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 3215 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| 3214 main_test_rfh()->PrepareForCommit(); | 3216 main_test_rfh()->PrepareForCommit(); |
| 3215 main_test_rfh()->SendNavigate(2, entry_id, false, url2); | 3217 main_test_rfh()->SendNavigate(2, entry_id, false, url2); |
| 3216 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 3218 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 3217 | 3219 |
| 3218 // Add a transient and go forward. | 3220 // Add a transient and go forward. |
| 3219 transient_entry.reset(new NavigationEntryImpl); | 3221 transient_entry.reset(new NavigationEntryImpl); |
| 3220 transient_entry->SetURL(transient_url); | 3222 transient_entry->SetURL(transient_url); |
| 3221 controller.SetTransientEntry(transient_entry.Pass()); | 3223 controller.SetTransientEntry(std::move(transient_entry)); |
| 3222 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3224 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3223 EXPECT_TRUE(controller.CanGoForward()); | 3225 EXPECT_TRUE(controller.CanGoForward()); |
| 3224 controller.GoForward(); | 3226 controller.GoForward(); |
| 3225 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3227 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3226 // We should have navigated, transient entry should be gone. | 3228 // We should have navigated, transient entry should be gone. |
| 3227 EXPECT_FALSE(controller.GetTransientEntry()); | 3229 EXPECT_FALSE(controller.GetTransientEntry()); |
| 3228 EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL()); | 3230 EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL()); |
| 3229 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); | 3231 EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL()); |
| 3230 main_test_rfh()->PrepareForCommit(); | 3232 main_test_rfh()->PrepareForCommit(); |
| 3231 main_test_rfh()->SendNavigate(3, entry_id, false, url3); | 3233 main_test_rfh()->SendNavigate(3, entry_id, false, url3); |
| 3232 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); | 3234 EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL()); |
| 3233 | 3235 |
| 3234 // Add a transient and do an in-page navigation, replacing the current entry. | 3236 // Add a transient and do an in-page navigation, replacing the current entry. |
| 3235 transient_entry.reset(new NavigationEntryImpl); | 3237 transient_entry.reset(new NavigationEntryImpl); |
| 3236 transient_entry->SetURL(transient_url); | 3238 transient_entry->SetURL(transient_url); |
| 3237 controller.SetTransientEntry(transient_entry.Pass()); | 3239 controller.SetTransientEntry(std::move(transient_entry)); |
| 3238 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3240 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3239 | 3241 |
| 3240 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false); | 3242 main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false); |
| 3241 main_test_rfh()->PrepareForCommit(); | 3243 main_test_rfh()->PrepareForCommit(); |
| 3242 main_test_rfh()->SendNavigate(3, 0, false, url3_ref); | 3244 main_test_rfh()->SendNavigate(3, 0, false, url3_ref); |
| 3243 // Transient entry should be gone. | 3245 // Transient entry should be gone. |
| 3244 EXPECT_FALSE(controller.GetTransientEntry()); | 3246 EXPECT_FALSE(controller.GetTransientEntry()); |
| 3245 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL()); | 3247 EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL()); |
| 3246 | 3248 |
| 3247 // Ensure the URLs are correct. | 3249 // Ensure the URLs are correct. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3265 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3267 url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 3266 int entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3268 int entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3267 main_test_rfh()->PrepareForCommit(); | 3269 main_test_rfh()->PrepareForCommit(); |
| 3268 main_test_rfh()->SendNavigate(0, entry_id, true, url0); | 3270 main_test_rfh()->SendNavigate(0, entry_id, true, url0); |
| 3269 controller.LoadURL( | 3271 controller.LoadURL( |
| 3270 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3272 url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 3271 | 3273 |
| 3272 // A transient entry is added, interrupting the navigation. | 3274 // A transient entry is added, interrupting the navigation. |
| 3273 scoped_ptr<NavigationEntry> transient_entry(new NavigationEntryImpl); | 3275 scoped_ptr<NavigationEntry> transient_entry(new NavigationEntryImpl); |
| 3274 transient_entry->SetURL(transient_url); | 3276 transient_entry->SetURL(transient_url); |
| 3275 controller.SetTransientEntry(transient_entry.Pass()); | 3277 controller.SetTransientEntry(std::move(transient_entry)); |
| 3276 EXPECT_TRUE(controller.GetTransientEntry()); | 3278 EXPECT_TRUE(controller.GetTransientEntry()); |
| 3277 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); | 3279 EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL()); |
| 3278 | 3280 |
| 3279 // The page is reloaded, which should remove the pending entry for |url1| and | 3281 // The page is reloaded, which should remove the pending entry for |url1| and |
| 3280 // the transient entry for |transient_url|, and start a navigation to | 3282 // the transient entry for |transient_url|, and start a navigation to |
| 3281 // |transient_url|. | 3283 // |transient_url|. |
| 3282 controller.Reload(true); | 3284 controller.Reload(true); |
| 3283 entry_id = controller.GetPendingEntry()->GetUniqueID(); | 3285 entry_id = controller.GetPendingEntry()->GetUniqueID(); |
| 3284 EXPECT_FALSE(controller.GetTransientEntry()); | 3286 EXPECT_FALSE(controller.GetTransientEntry()); |
| 3285 EXPECT_TRUE(controller.GetPendingEntry()); | 3287 EXPECT_TRUE(controller.GetPendingEntry()); |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4415 }; | 4417 }; |
| 4416 const GURL kInitialUrl("http://site3.com"); | 4418 const GURL kInitialUrl("http://site3.com"); |
| 4417 | 4419 |
| 4418 std::vector<scoped_ptr<NavigationEntry>> entries; | 4420 std::vector<scoped_ptr<NavigationEntry>> entries; |
| 4419 for (size_t i = 0; i < arraysize(kRestoredUrls); ++i) { | 4421 for (size_t i = 0; i < arraysize(kRestoredUrls); ++i) { |
| 4420 scoped_ptr<NavigationEntry> entry = | 4422 scoped_ptr<NavigationEntry> entry = |
| 4421 NavigationControllerImpl::CreateNavigationEntry( | 4423 NavigationControllerImpl::CreateNavigationEntry( |
| 4422 kRestoredUrls[i], Referrer(), ui::PAGE_TRANSITION_RELOAD, false, | 4424 kRestoredUrls[i], Referrer(), ui::PAGE_TRANSITION_RELOAD, false, |
| 4423 std::string(), browser_context()); | 4425 std::string(), browser_context()); |
| 4424 entry->SetPageID(static_cast<int>(i)); | 4426 entry->SetPageID(static_cast<int>(i)); |
| 4425 entries.push_back(entry.Pass()); | 4427 entries.push_back(std::move(entry)); |
| 4426 } | 4428 } |
| 4427 | 4429 |
| 4428 // Create a WebContents with restored entries. | 4430 // Create a WebContents with restored entries. |
| 4429 scoped_ptr<TestWebContents> source_contents( | 4431 scoped_ptr<TestWebContents> source_contents( |
| 4430 static_cast<TestWebContents*>(CreateTestWebContents())); | 4432 static_cast<TestWebContents*>(CreateTestWebContents())); |
| 4431 NavigationControllerImpl& source_controller = | 4433 NavigationControllerImpl& source_controller = |
| 4432 source_contents->GetController(); | 4434 source_contents->GetController(); |
| 4433 source_controller.Restore( | 4435 source_controller.Restore( |
| 4434 entries.size() - 1, | 4436 entries.size() - 1, |
| 4435 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 4437 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5119 EXPECT_EQ(default_ssl_status.connection_status, | 5121 EXPECT_EQ(default_ssl_status.connection_status, |
| 5120 details.ssl_status.connection_status); | 5122 details.ssl_status.connection_status); |
| 5121 EXPECT_EQ(default_ssl_status.content_status, | 5123 EXPECT_EQ(default_ssl_status.content_status, |
| 5122 details.ssl_status.content_status); | 5124 details.ssl_status.content_status); |
| 5123 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5125 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
| 5124 | 5126 |
| 5125 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5127 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
| 5126 } | 5128 } |
| 5127 | 5129 |
| 5128 } // namespace content | 5130 } // namespace content |
| OLD | NEW |