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

Side by Side Diff: content/common/content_security_policy/content_security_policy_unittest.cc

Issue 2910573002: Implement upgrade-insecure-requests in browser for frame requests (Closed)
Patch Set: rebase Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/common/content_security_policy/csp_context.h" 5 #include "content/common/content_security_policy/csp_context.h"
6 #include "content/common/content_security_policy_header.h" 6 #include "content/common/content_security_policy_header.h"
7 #include "content/common/navigation_params.h" 7 #include "content/common/navigation_params.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 context.AddSchemeToBypassCSP("https"); 231 context.AddSchemeToBypassCSP("https");
232 232
233 EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc, 233 EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
234 GURL("blob:https://example.com/"), 234 GURL("blob:https://example.com/"),
235 false, &context, SourceLocation())); 235 false, &context, SourceLocation()));
236 EXPECT_TRUE(ContentSecurityPolicy::Allow( 236 EXPECT_TRUE(ContentSecurityPolicy::Allow(
237 policy, CSPDirective::FrameSrc, GURL("blob:https://not-example.com/"), 237 policy, CSPDirective::FrameSrc, GURL("blob:https://not-example.com/"),
238 false, &context, SourceLocation())); 238 false, &context, SourceLocation()));
239 } 239 }
240 240
241 TEST(ContentSecurityPolicy, ShouldUpgradeInsecureRequest) {
242 std::vector<std::string> report_end_points; // empty
243 CSPSource source("https", "example.com", false, url::PORT_UNSPECIFIED, false,
244 "");
245 CSPSourceList source_list(false, false, {source});
246 ContentSecurityPolicy policy(
247 EmptyCspHeader(), {CSPDirective(CSPDirective::DefaultSrc, source_list)},
248 report_end_points);
249
250 EXPECT_FALSE(ContentSecurityPolicy::ShouldUpgradeInsecureRequest(policy));
251
252 policy.directives.push_back(
253 CSPDirective(CSPDirective::UpgradeInsecureRequests, CSPSourceList()));
254 EXPECT_TRUE(ContentSecurityPolicy::ShouldUpgradeInsecureRequest(policy));
255 }
256
241 } // namespace content 257 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698