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 6a6c02c995f11e0e3aa2de1c2fd1ad20e2954a0b..0461c1e3f848bcb19355443ca706220f71fc7c3f 100644 |
--- a/content/common/content_security_policy/content_security_policy_unittest.cc |
+++ b/content/common/content_security_policy/content_security_policy_unittest.cc |
@@ -4,6 +4,7 @@ |
#include "content/common/content_security_policy/csp_context.h" |
#include "content/common/content_security_policy_header.h" |
+#include "content/common/navigation_params.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace content { |
@@ -14,8 +15,9 @@ class CSPContextTest : public CSPContext { |
const std::string& LastConsoleMessage() { return console_message_; } |
private: |
- void LogToConsole(const std::string& message) override { |
- console_message_ = message; |
+ void ReportContentSecurityPolicyViolation( |
+ const CSPViolationParams& violation_params) override { |
+ console_message_ = violation_params.console_message; |
} |
std::string console_message_; |
}; |
@@ -32,7 +34,7 @@ TEST(ContentSecurityPolicy, NoDirective) { |
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FormAction, |
GURL("http://www.example.com"), |
- &context)); |
+ false, &context, SourceLocation())); |
EXPECT_EQ("", context.LastConsoleMessage()); |
} |
@@ -51,7 +53,7 @@ TEST(ContentSecurityPolicy, ReportViolation) { |
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FormAction, |
GURL("http://www.not-example.com"), |
- &context)); |
+ false, &context, SourceLocation())); |
const char console_message[] = |
"Refused to send form data to 'http://www.not-example.com/' because it " |
@@ -76,7 +78,8 @@ TEST(ContentSecurityPolicy, DirectiveFallback) { |
{CSPDirective(CSPDirective::DefaultSrc, source_list_a)}, |
report_end_points, "" /* header */); |
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc, |
- GURL("http://b.com"), &context)); |
+ GURL("http://b.com"), false, |
+ &context, SourceLocation())); |
const char console_message[] = |
"Refused to frame 'http://b.com/' because it violates " |
"the following Content Security Policy directive: \"default-src " |
@@ -84,7 +87,8 @@ TEST(ContentSecurityPolicy, DirectiveFallback) { |
"set, so 'default-src' is used as a fallback.\n"; |
EXPECT_EQ(console_message, context.LastConsoleMessage()); |
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc, |
- GURL("http://a.com"), &context)); |
+ GURL("http://a.com"), false, |
+ &context, SourceLocation())); |
} |
{ |
CSPContextTest context; |
@@ -94,7 +98,8 @@ TEST(ContentSecurityPolicy, DirectiveFallback) { |
{CSPDirective(CSPDirective::ChildSrc, source_list_a)}, |
report_end_points, "" /* header */); |
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc, |
- GURL("http://b.com"), &context)); |
+ GURL("http://b.com"), false, |
+ &context, SourceLocation())); |
const char console_message[] = |
"Refused to frame 'http://b.com/' because it violates " |
"the following Content Security Policy directive: \"child-src " |
@@ -102,7 +107,8 @@ TEST(ContentSecurityPolicy, DirectiveFallback) { |
"set, so 'child-src' is used as a fallback.\n"; |
EXPECT_EQ(console_message, context.LastConsoleMessage()); |
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc, |
- GURL("http://a.com"), &context)); |
+ GURL("http://a.com"), false, |
+ &context, SourceLocation())); |
} |
{ |
CSPContextTest context; |
@@ -114,9 +120,11 @@ TEST(ContentSecurityPolicy, DirectiveFallback) { |
CSPDirective(CSPDirective::ChildSrc, {source_list_b})}, |
report_end_points, "" /* header */); |
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc, |
- GURL("http://a.com"), &context)); |
+ GURL("http://a.com"), false, |
+ &context, SourceLocation())); |
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc, |
- GURL("http://b.com"), &context)); |
+ GURL("http://b.com"), false, |
+ &context, SourceLocation())); |
const char console_message[] = |
"Refused to frame 'http://b.com/' because it violates " |
"the following Content Security Policy directive: \"frame-src " |