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

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

Issue 2707263013: Don't recreate feature policy on fragment navigation (Closed)
Patch Set: Fix condition, add tests 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
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 EXPECT_TRUE(node->navigation_request()); 1233 EXPECT_TRUE(node->navigation_request());
1234 1234
1235 // The first navigation commits. This should clear up the speculative RFH and 1235 // The first navigation commits. This should clear up the speculative RFH and
1236 // the ongoing NavigationRequest. 1236 // the ongoing NavigationRequest.
1237 speculative_rfh->SendNavigate(entry_id, true, kUrl2); 1237 speculative_rfh->SendNavigate(entry_id, true, kUrl2);
1238 EXPECT_FALSE(node->navigation_request()); 1238 EXPECT_FALSE(node->navigation_request());
1239 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 1239 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
1240 EXPECT_EQ(speculative_rfh, main_test_rfh()); 1240 EXPECT_EQ(speculative_rfh, main_test_rfh());
1241 } 1241 }
1242 1242
1243 // Feature Policy: Test that the feature policy is reset when navigating pages
1244 // within a site.
1245 TEST_F(NavigatorTestWithBrowserSideNavigation,
1246 FeaturePolicySameSiteNavigation) {
1247 const GURL kUrl1("http://www.chromium.org/");
1248 const GURL kUrl2("http://www.chromium.org/Home");
1249
1250 contents()->NavigateAndCommit(kUrl1);
1251
1252 // Check the feature policy before navigation.
1253 FeaturePolicy* original_feature_policy =
1254 main_test_rfh()->get_feature_policy();
1255 ASSERT_TRUE(original_feature_policy);
1256
1257 // Navigate to the new URL.
1258 process()->sink().ClearMessages();
1259 main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
1260 main_test_rfh()->SendNavigate(0, true, kUrl2);
alexmos 2017/03/04 01:33:25 Would it work to just use contents()->NavigateAndC
iclelland 2017/03/04 05:43:10 It absolutely does. Thanks, done. (Validated manua
1261
1262 // Check the feature policy after navigation.
1263 FeaturePolicy* final_feature_policy = main_test_rfh()->get_feature_policy();
1264 ASSERT_TRUE(final_feature_policy);
1265 ASSERT_NE(original_feature_policy, final_feature_policy);
1266 }
1267
1268 // Feature Policy: Test that the feature policy is not reset when navigating
1269 // within a page.
1270 TEST_F(NavigatorTestWithBrowserSideNavigation,
1271 FeaturePolicyFragmentNavigation) {
1272 const GURL kUrl1("http://www.chromium.org/");
1273 const GURL kUrl2("http://www.chromium.org/#Home");
1274
1275 contents()->NavigateAndCommit(kUrl1);
1276
1277 // Check the feature policy before navigation.
1278 FeaturePolicy* original_feature_policy =
1279 main_test_rfh()->get_feature_policy();
1280 ASSERT_TRUE(original_feature_policy);
1281
1282 // Navigate to the new URL.
1283 process()->sink().ClearMessages();
1284 main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false);
1285 main_test_rfh()->SendNavigate(0, true, kUrl2);
1286
1287 // Check the feature policy after navigation.
1288 FeaturePolicy* final_feature_policy = main_test_rfh()->get_feature_policy();
1289 ASSERT_EQ(original_feature_policy, final_feature_policy);
1290 }
1291
1243 } // namespace content 1292 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698