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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/common/content_security_policy/content_security_policy_unittest.cc
diff --git a/content/common/content_security_policy/content_security_policy_unittest.cc b/content/common/content_security_policy/content_security_policy_unittest.cc
index ee9ae79e261802d4197643a2fcfb9b24344ed1b0..e14a04166388d48838e636a123a6797a559ff131 100644
--- a/content/common/content_security_policy/content_security_policy_unittest.cc
+++ b/content/common/content_security_policy/content_security_policy_unittest.cc
@@ -238,4 +238,20 @@ TEST(ContentSecurityPolicy, BlobAllowedWhenBypassingCSP) {
false, &context, SourceLocation()));
}
+TEST(ContentSecurityPolicy, ShouldUpgradeInsecureRequest) {
+ std::vector<std::string> report_end_points; // empty
+ CSPSource source("https", "example.com", false, url::PORT_UNSPECIFIED, false,
+ "");
+ CSPSourceList source_list(false, false, {source});
+ ContentSecurityPolicy policy(
+ EmptyCspHeader(), {CSPDirective(CSPDirective::DefaultSrc, source_list)},
+ report_end_points);
+
+ EXPECT_FALSE(ContentSecurityPolicy::ShouldUpgradeInsecureRequest(policy));
+
+ policy.directives.push_back(
+ CSPDirective(CSPDirective::UpgradeInsecureRequests, CSPSourceList()));
+ EXPECT_TRUE(ContentSecurityPolicy::ShouldUpgradeInsecureRequest(policy));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698