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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2794 NavigationControllerImpl& controller = controller_impl(); | 2794 NavigationControllerImpl& controller = controller_impl(); |
2795 Navigator* navigator = | 2795 Navigator* navigator = |
2796 contents()->GetFrameTree()->root()->navigator(); | 2796 contents()->GetFrameTree()->root()->navigator(); |
2797 | 2797 |
2798 const GURL url1("nonexistent:12121"); | 2798 const GURL url1("nonexistent:12121"); |
2799 const GURL url1_fixed("http://nonexistent:12121/"); | 2799 const GURL url1_fixed("http://nonexistent:12121/"); |
2800 const GURL url2("http://foo"); | 2800 const GURL url2("http://foo"); |
2801 | 2801 |
2802 // We create pending entries for renderer-initiated navigations so that we | 2802 // We create pending entries for renderer-initiated navigations so that we |
2803 // can show them in new tabs when it is safe. | 2803 // can show them in new tabs when it is safe. |
2804 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 2804 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, false); |
2805 | 2805 |
2806 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing | 2806 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing |
2807 // the virtual URL to differ from the URL. | 2807 // the virtual URL to differ from the URL. |
2808 controller.GetPendingEntry()->SetURL(url1_fixed); | 2808 controller.GetPendingEntry()->SetURL(url1_fixed); |
2809 controller.GetPendingEntry()->SetVirtualURL(url1); | 2809 controller.GetPendingEntry()->SetVirtualURL(url1); |
2810 | 2810 |
2811 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); | 2811 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); |
2812 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); | 2812 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); |
2813 EXPECT_TRUE( | 2813 EXPECT_TRUE( |
2814 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 2814 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
2815 is_renderer_initiated()); | 2815 is_renderer_initiated()); |
2816 | 2816 |
2817 // If the user clicks another link, we should replace the pending entry. | 2817 // If the user clicks another link, we should replace the pending entry. |
2818 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); | 2818 navigator->DidStartProvisionalLoad(main_test_rfh(), url2, false); |
2819 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); | 2819 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); |
2820 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL()); | 2820 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL()); |
2821 | 2821 |
2822 // Once it commits, the URL and virtual URL should reflect the actual page. | 2822 // Once it commits, the URL and virtual URL should reflect the actual page. |
2823 main_test_rfh()->SendNavigate(0, url2); | 2823 main_test_rfh()->SendNavigate(0, url2); |
2824 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 2824 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
2825 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL()); | 2825 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL()); |
2826 | 2826 |
2827 // We should not replace the pending entry for an error URL. | 2827 // We should not replace the pending entry for an error URL. |
2828 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 2828 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, false); |
2829 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 2829 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
2830 navigator->DidStartProvisionalLoad(main_test_rfh(), | 2830 navigator->DidStartProvisionalLoad(main_test_rfh(), |
2831 GURL(kUnreachableWebDataURL)); | 2831 GURL(kUnreachableWebDataURL), false); |
2832 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); | 2832 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); |
2833 | 2833 |
2834 // We should remember if the pending entry will replace the current one. | 2834 // We should remember if the pending entry will replace the current one. |
2835 // http://crbug.com/308444. | 2835 // http://crbug.com/308444. |
2836 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); | 2836 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, false); |
2837 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 2837 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
2838 set_should_replace_entry(true); | 2838 set_should_replace_entry(true); |
2839 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); | 2839 navigator->DidStartProvisionalLoad(main_test_rfh(), url2, false); |
2840 EXPECT_TRUE( | 2840 EXPECT_TRUE( |
2841 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> | 2841 NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
2842 should_replace_entry()); | 2842 should_replace_entry()); |
2843 // TODO(nasko): Until OnNavigate is moved to RenderFrameHost, we need | 2843 // TODO(nasko): Until OnNavigate is moved to RenderFrameHost, we need |
2844 // to go through the RenderViewHost. The TestRenderViewHost routes navigations | 2844 // to go through the RenderViewHost. The TestRenderViewHost routes navigations |
2845 // to the main frame. | 2845 // to the main frame. |
2846 main_test_rfh()->SendNavigate(0, url2); | 2846 main_test_rfh()->SendNavigate(0, url2); |
2847 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); | 2847 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); |
2848 } | 2848 } |
2849 | 2849 |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4338 params.post_id = -1; | 4338 params.post_id = -1; |
4339 test_rvh()->SendNavigateWithParams(¶ms); | 4339 test_rvh()->SendNavigateWithParams(¶ms); |
4340 | 4340 |
4341 // Now reload. replaceState overrides the POST, so we should not show a | 4341 // Now reload. replaceState overrides the POST, so we should not show a |
4342 // repost warning dialog. | 4342 // repost warning dialog. |
4343 controller_impl().Reload(true); | 4343 controller_impl().Reload(true); |
4344 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4344 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
4345 } | 4345 } |
4346 | 4346 |
4347 } // namespace content | 4347 } // namespace content |
OLD | NEW |