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 2804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 entry->SetTitle(base::ASCIIToUTF16("Title")); | 2815 entry->SetTitle(base::ASCIIToUTF16("Title")); |
2816 entry->SetPageState(PageState::CreateFromEncodedData("state")); | 2816 entry->SetPageState(PageState::CreateFromEncodedData("state")); |
2817 entries.push_back(entry); | 2817 entries.push_back(entry); |
2818 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( | 2818 scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( |
2819 WebContents::Create(WebContents::CreateParams(browser_context())))); | 2819 WebContents::Create(WebContents::CreateParams(browser_context())))); |
2820 NavigationControllerImpl& our_controller = our_contents->GetController(); | 2820 NavigationControllerImpl& our_controller = our_contents->GetController(); |
2821 our_controller.Restore( | 2821 our_controller.Restore( |
2822 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); | 2822 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); |
2823 ASSERT_EQ(0u, entries.size()); | 2823 ASSERT_EQ(0u, entries.size()); |
2824 | 2824 |
| 2825 // Ensure the RenderFrame is initialized before simulating events coming from |
| 2826 // it. |
| 2827 main_test_rfh()->InitializeRenderFrameIfNeeded(); |
| 2828 |
2825 // Before navigating to the restored entry, it should have a restore_type | 2829 // Before navigating to the restored entry, it should have a restore_type |
2826 // and no SiteInstance. | 2830 // and no SiteInstance. |
2827 entry = our_controller.GetEntryAtIndex(0); | 2831 entry = our_controller.GetEntryAtIndex(0); |
2828 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 2832 EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
2829 our_controller.GetEntryAtIndex(0)->restore_type()); | 2833 our_controller.GetEntryAtIndex(0)->restore_type()); |
2830 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); | 2834 EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance()); |
2831 | 2835 |
2832 // After navigating, we should have one entry, and it should be "pending". | 2836 // After navigating, we should have one entry, and it should be "pending". |
2833 // It should now have a SiteInstance and no restore_type. | 2837 // It should now have a SiteInstance and no restore_type. |
2834 our_controller.GoToIndex(0); | 2838 our_controller.GoToIndex(0); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3243 NavigationControllerImpl& controller = controller_impl(); | 3247 NavigationControllerImpl& controller = controller_impl(); |
3244 Navigator* navigator = | 3248 Navigator* navigator = |
3245 contents()->GetFrameTree()->root()->navigator(); | 3249 contents()->GetFrameTree()->root()->navigator(); |
3246 | 3250 |
3247 const GURL url1("nonexistent:12121"); | 3251 const GURL url1("nonexistent:12121"); |
3248 const GURL url1_fixed("http://nonexistent:12121/"); | 3252 const GURL url1_fixed("http://nonexistent:12121/"); |
3249 const GURL url2("http://foo"); | 3253 const GURL url2("http://foo"); |
3250 | 3254 |
3251 // We create pending entries for renderer-initiated navigations so that we | 3255 // We create pending entries for renderer-initiated navigations so that we |
3252 // can show them in new tabs when it is safe. | 3256 // can show them in new tabs when it is safe. |
| 3257 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false); |
| 3258 main_test_rfh()->PrepareForCommit(); |
3253 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 3259 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); |
3254 | 3260 |
3255 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing | 3261 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing |
3256 // the virtual URL to differ from the URL. | 3262 // the virtual URL to differ from the URL. |
3257 controller.GetPendingEntry()->SetURL(url1_fixed); | 3263 controller.GetPendingEntry()->SetURL(url1_fixed); |
3258 controller.GetPendingEntry()->SetVirtualURL(url1); | 3264 controller.GetPendingEntry()->SetVirtualURL(url1); |
3259 | 3265 |
3260 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); | 3266 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); |
3261 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); | 3267 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); |
3262 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); | 3268 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4893 { | 4899 { |
4894 LoadCommittedDetails details; | 4900 LoadCommittedDetails details; |
4895 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | 4901 controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); |
4896 EXPECT_EQ(PAGE_TYPE_ERROR, | 4902 EXPECT_EQ(PAGE_TYPE_ERROR, |
4897 controller_impl().GetLastCommittedEntry()->GetPageType()); | 4903 controller_impl().GetLastCommittedEntry()->GetPageType()); |
4898 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); | 4904 EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); |
4899 } | 4905 } |
4900 } | 4906 } |
4901 | 4907 |
4902 } // namespace content | 4908 } // namespace content |
OLD | NEW |