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 3835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3846 WebPreferences prefs = test_rvh()->GetWebkitPreferences(); | 3846 WebPreferences prefs = test_rvh()->GetWebkitPreferences(); |
3847 prefs.allow_universal_access_from_file_urls = true; | 3847 prefs.allow_universal_access_from_file_urls = true; |
3848 test_rvh()->UpdateWebkitPreferences(prefs); | 3848 test_rvh()->UpdateWebkitPreferences(prefs); |
3849 prefs = test_rvh()->GetWebkitPreferences(); | 3849 prefs = test_rvh()->GetWebkitPreferences(); |
3850 EXPECT_TRUE(prefs.allow_universal_access_from_file_urls); | 3850 EXPECT_TRUE(prefs.allow_universal_access_from_file_urls); |
3851 | 3851 |
3852 // Allow in page navigation to be cross-origin if existing URL is file scheme. | 3852 // Allow in page navigation to be cross-origin if existing URL is file scheme. |
3853 const GURL file_url("file:///foo/index.html"); | 3853 const GURL file_url("file:///foo/index.html"); |
3854 const url::Origin file_origin(file_url); | 3854 const url::Origin file_origin(file_url); |
3855 main_test_rfh()->NavigateAndCommitRendererInitiated(true, file_url); | 3855 main_test_rfh()->NavigateAndCommitRendererInitiated(true, file_url); |
3856 EXPECT_TRUE(file_origin.IsSameOriginWith( | 3856 EXPECT_TRUE( |
3857 main_test_rfh()->frame_tree_node()->current_origin())); | 3857 file_origin.IsSameOriginWith(main_test_rfh()->GetLastCommittedOrigin())); |
3858 EXPECT_EQ(0, rph->bad_msg_count()); | 3858 EXPECT_EQ(0, rph->bad_msg_count()); |
3859 EXPECT_TRUE(controller.IsURLInPageNavigation( | 3859 EXPECT_TRUE(controller.IsURLInPageNavigation( |
3860 different_origin_url, url::Origin(different_origin_url), true, | 3860 different_origin_url, url::Origin(different_origin_url), true, |
3861 main_test_rfh())); | 3861 main_test_rfh())); |
3862 EXPECT_EQ(0, rph->bad_msg_count()); | 3862 EXPECT_EQ(0, rph->bad_msg_count()); |
3863 | 3863 |
3864 // Doing a replaceState to a cross-origin URL is thus allowed. | 3864 // Doing a replaceState to a cross-origin URL is thus allowed. |
3865 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3865 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3866 params.nav_entry_id = 1; | 3866 params.nav_entry_id = 1; |
3867 params.did_create_new_entry = false; | 3867 params.did_create_new_entry = false; |
3868 params.url = different_origin_url; | 3868 params.url = different_origin_url; |
3869 params.origin = file_origin; | 3869 params.origin = file_origin; |
3870 params.transition = ui::PAGE_TRANSITION_LINK; | 3870 params.transition = ui::PAGE_TRANSITION_LINK; |
3871 params.gesture = NavigationGestureUser; | 3871 params.gesture = NavigationGestureUser; |
3872 params.page_state = PageState::CreateFromURL(different_origin_url); | 3872 params.page_state = PageState::CreateFromURL(different_origin_url); |
3873 params.was_within_same_page = true; | 3873 params.was_within_same_page = true; |
3874 params.method = "GET"; | 3874 params.method = "GET"; |
3875 params.post_id = -1; | 3875 params.post_id = -1; |
3876 main_test_rfh()->SendRendererInitiatedNavigationRequest(different_origin_url, | 3876 main_test_rfh()->SendRendererInitiatedNavigationRequest(different_origin_url, |
3877 false); | 3877 false); |
3878 main_test_rfh()->PrepareForCommit(); | 3878 main_test_rfh()->PrepareForCommit(); |
3879 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); | 3879 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); |
3880 | 3880 |
3881 // At this point, we should still consider the current origin to be file://, | 3881 // At this point, we should still consider the current origin to be file://, |
3882 // so that a file URL would still be in-page. See https://crbug.com/553418. | 3882 // so that a file URL would still be in-page. See https://crbug.com/553418. |
3883 EXPECT_TRUE(file_origin.IsSameOriginWith( | 3883 EXPECT_TRUE( |
3884 main_test_rfh()->frame_tree_node()->current_origin())); | 3884 file_origin.IsSameOriginWith(main_test_rfh()->GetLastCommittedOrigin())); |
3885 EXPECT_TRUE(controller.IsURLInPageNavigation(file_url, url::Origin(file_url), | 3885 EXPECT_TRUE(controller.IsURLInPageNavigation(file_url, url::Origin(file_url), |
3886 true, main_test_rfh())); | 3886 true, main_test_rfh())); |
3887 EXPECT_EQ(0, rph->bad_msg_count()); | 3887 EXPECT_EQ(0, rph->bad_msg_count()); |
3888 | 3888 |
3889 // Don't honor allow_universal_access_from_file_urls if actual URL is | 3889 // Don't honor allow_universal_access_from_file_urls if actual URL is |
3890 // not file scheme. | 3890 // not file scheme. |
3891 const GURL url("http://www.google.com/home.html"); | 3891 const GURL url("http://www.google.com/home.html"); |
3892 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url); | 3892 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url); |
3893 EXPECT_FALSE(controller.IsURLInPageNavigation( | 3893 EXPECT_FALSE(controller.IsURLInPageNavigation( |
3894 different_origin_url, url::Origin(different_origin_url), true, | 3894 different_origin_url, url::Origin(different_origin_url), true, |
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5205 // means that occasionally a navigation conflict will end up with one entry | 5205 // means that occasionally a navigation conflict will end up with one entry |
5206 // bubbling to the end of the entry list, but that's the least-bad option. | 5206 // bubbling to the end of the entry list, but that's the least-bad option. |
5207 EXPECT_EQ(3, controller.GetEntryCount()); | 5207 EXPECT_EQ(3, controller.GetEntryCount()); |
5208 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 5208 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
5209 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); | 5209 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); |
5210 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); | 5210 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); |
5211 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); | 5211 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); |
5212 } | 5212 } |
5213 | 5213 |
5214 } // namespace content | 5214 } // namespace content |
OLD | NEW |