OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 // unrelated to the current SiteInstance. | 1189 // unrelated to the current SiteInstance. |
1190 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); | 1190 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); |
1191 } | 1191 } |
1192 } | 1192 } |
1193 | 1193 |
1194 namespace { | 1194 namespace { |
1195 void SetWithinPage(const GURL& url, | 1195 void SetWithinPage(const GURL& url, |
1196 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { | 1196 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { |
1197 params->was_within_same_page = true; | 1197 params->was_within_same_page = true; |
1198 params->url = url; | 1198 params->url = url; |
| 1199 params->origin = url::Origin(url); |
1199 } | 1200 } |
1200 } | 1201 } |
1201 | 1202 |
1202 // A renderer process might try and claim that a cross site navigation was | 1203 // A renderer process might try and claim that a cross site navigation was |
1203 // within the same page by setting was_within_same_page = true for | 1204 // within the same page by setting was_within_same_page = true for |
1204 // FrameHostMsg_DidCommitProvisionalLoad. Such case should be detected on the | 1205 // FrameHostMsg_DidCommitProvisionalLoad. Such case should be detected on the |
1205 // browser side and the renderer process should be killed. | 1206 // browser side and the renderer process should be killed. |
1206 TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteClaimWithinPage) { | 1207 TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteClaimWithinPage) { |
1207 const GURL kUrl1("http://www.chromium.org/"); | 1208 const GURL kUrl1("http://www.chromium.org/"); |
1208 const GURL kUrl2("http://www.google.com/"); | 1209 const GURL kUrl2("http://www.google.com/"); |
1209 | 1210 |
1210 contents()->NavigateAndCommit(kUrl1); | 1211 contents()->NavigateAndCommit(kUrl1); |
1211 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 1212 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
1212 | 1213 |
1213 // Navigate to a different site. | 1214 // Navigate to a different site. |
1214 int entry_id = RequestNavigation(node, kUrl2); | 1215 int entry_id = RequestNavigation(node, kUrl2); |
1215 main_test_rfh()->PrepareForCommit(); | 1216 main_test_rfh()->PrepareForCommit(); |
1216 | 1217 |
1217 // Claim that the navigation was within same page. | 1218 // Claim that the navigation was within same page. |
1218 int bad_msg_count = process()->bad_msg_count(); | 1219 int bad_msg_count = process()->bad_msg_count(); |
1219 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback( | 1220 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback( |
1220 0, entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1)); | 1221 0, entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1)); |
1221 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1); | 1222 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1); |
1222 } | 1223 } |
1223 | 1224 |
1224 } // namespace content | 1225 } // namespace content |
OLD | NEW |