Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: content/browser/frame_host/navigator_impl_unittest.cc

Issue 2741313002: Renamed WasWithinSamePage to WasWithinSameDocument. (Closed)
Patch Set: Addressed review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 1133
1134 scoped_refptr<SiteInstance> converted_instance_2 = 1134 scoped_refptr<SiteInstance> converted_instance_2 =
1135 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); 1135 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get());
1136 // Should return |unrelated_instance| because its site matches and it is 1136 // Should return |unrelated_instance| because its site matches and it is
1137 // unrelated to the current SiteInstance. 1137 // unrelated to the current SiteInstance.
1138 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); 1138 EXPECT_EQ(unrelated_instance.get(), converted_instance_2);
1139 } 1139 }
1140 } 1140 }
1141 1141
1142 namespace { 1142 namespace {
1143 void SetWithinPage(const GURL& url, 1143 void SetWithinSameDocument(
1144 FrameHostMsg_DidCommitProvisionalLoad_Params* params) { 1144 const GURL& url,
1145 params->was_within_same_page = true; 1145 FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
1146 params->was_within_same_document = true;
1146 params->url = url; 1147 params->url = url;
1147 params->origin = url::Origin(url); 1148 params->origin = url::Origin(url);
1148 } 1149 }
1149 } 1150 }
1150 1151
1151 // A renderer process might try and claim that a cross site navigation was 1152 // A renderer process might try and claim that a cross site navigation was
1152 // within the same page by setting was_within_same_page = true for 1153 // within the same document by setting was_within_same_document = true for
1153 // FrameHostMsg_DidCommitProvisionalLoad. Such case should be detected on the 1154 // FrameHostMsg_DidCommitProvisionalLoad. Such case should be detected on the
1154 // browser side and the renderer process should be killed. 1155 // browser side and the renderer process should be killed.
1155 TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteClaimWithinPage) { 1156 TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteClaimWithinPage) {
1156 const GURL kUrl1("http://www.chromium.org/"); 1157 const GURL kUrl1("http://www.chromium.org/");
1157 const GURL kUrl2("http://www.google.com/"); 1158 const GURL kUrl2("http://www.google.com/");
1158 1159
1159 contents()->NavigateAndCommit(kUrl1); 1160 contents()->NavigateAndCommit(kUrl1);
1160 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); 1161 FrameTreeNode* node = main_test_rfh()->frame_tree_node();
1161 1162
1162 // Navigate to a different site. 1163 // Navigate to a different site.
1163 int entry_id = RequestNavigation(node, kUrl2); 1164 int entry_id = RequestNavigation(node, kUrl2);
1164 main_test_rfh()->PrepareForCommit(); 1165 main_test_rfh()->PrepareForCommit();
1165 1166
1166 // Claim that the navigation was within same page. 1167 // Claim that the navigation was within same page.
1167 int bad_msg_count = process()->bad_msg_count(); 1168 int bad_msg_count = process()->bad_msg_count();
1168 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback( 1169 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback(
1169 entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1)); 1170 entry_id, true, kUrl2, base::Bind(SetWithinSameDocument, kUrl1));
1170 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1); 1171 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1);
1171 } 1172 }
1172 1173
1173 // Tests that an ongoing NavigationRequest is deleted when a same-site 1174 // Tests that an ongoing NavigationRequest is deleted when a same-site
1174 // user-initiated navigation commits. 1175 // user-initiated navigation commits.
1175 TEST_F(NavigatorTestWithBrowserSideNavigation, 1176 TEST_F(NavigatorTestWithBrowserSideNavigation,
1176 NavigationRequestDeletedWhenUserInitiatedCommits) { 1177 NavigationRequestDeletedWhenUserInitiatedCommits) {
1177 const GURL kUrl1("http://www.chromium.org/"); 1178 const GURL kUrl1("http://www.chromium.org/");
1178 const GURL kUrl2("http://www.chromium.org/foo"); 1179 const GURL kUrl2("http://www.chromium.org/foo");
1179 const GURL kUrl3("http://www.google.com/"); 1180 const GURL kUrl3("http://www.google.com/");
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 1280
1280 // Navigate to the new URL. 1281 // Navigate to the new URL.
1281 contents()->NavigateAndCommit(kUrl2); 1282 contents()->NavigateAndCommit(kUrl2);
1282 1283
1283 // Check the feature policy after navigation. 1284 // Check the feature policy after navigation.
1284 FeaturePolicy* final_feature_policy = main_test_rfh()->get_feature_policy(); 1285 FeaturePolicy* final_feature_policy = main_test_rfh()->get_feature_policy();
1285 ASSERT_EQ(original_feature_policy, final_feature_policy); 1286 ASSERT_EQ(original_feature_policy, final_feature_policy);
1286 } 1287 }
1287 1288
1288 } // namespace content 1289 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698