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

Unified Diff: content/common/content_security_policy/csp_context_unittest.cc

Issue 2761153003: PlzNavigate & CSP. Use the SourceLocation in violation reports. (Closed)
Patch Set: Addressed comment @alexmos 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/content_security_policy/csp_context.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/content_security_policy/csp_context_unittest.cc
diff --git a/content/common/content_security_policy/csp_context_unittest.cc b/content/common/content_security_policy/csp_context_unittest.cc
index e34c300d68cba222f616b7790c9846c3e6bba8e1..7027a75bddab5f5cafed95ac0324efada24a730e 100644
--- a/content/common/content_security_policy/csp_context_unittest.cc
+++ b/content/common/content_security_policy/csp_context_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 {
@@ -24,8 +25,9 @@ class CSPContextTest : public CSPContext {
}
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_;
std::vector<std::string> scheme_to_bypass_;
@@ -42,7 +44,7 @@ ContentSecurityPolicy BuildPolicy(CSPDirective::Name directive_name,
std::vector<std::string>()); // report_end_points
}
-} // namespace;
+} // namespace
TEST(CSPContextTest, SchemeShouldBypassCSP) {
CSPSource source("", "example.com", false, url::PORT_UNSPECIFIED, false, "");
@@ -51,12 +53,14 @@ TEST(CSPContextTest, SchemeShouldBypassCSP) {
BuildPolicy(CSPDirective::DefaultSrc, {source}));
EXPECT_FALSE(context.IsAllowedByCsp(CSPDirective::FrameSrc,
- GURL("data:text/html,<html></html>")));
+ GURL("data:text/html,<html></html>"),
+ false, SourceLocation()));
context.AddSchemeToBypassCSP("data");
EXPECT_TRUE(context.IsAllowedByCsp(CSPDirective::FrameSrc,
- GURL("data:text/html,<html></html>")));
+ GURL("data:text/html,<html></html>"),
+ false, SourceLocation()));
}
TEST(CSPContextTest, MultiplePolicies) {
@@ -72,14 +76,14 @@ TEST(CSPContextTest, MultiplePolicies) {
context.AddContentSecurityPolicy(
BuildPolicy(CSPDirective::FrameSrc, {source_a, source_c}));
- EXPECT_TRUE(
- context.IsAllowedByCsp(CSPDirective::FrameSrc, GURL("http://a.com")));
- EXPECT_FALSE(
- context.IsAllowedByCsp(CSPDirective::FrameSrc, GURL("http://b.com")));
- EXPECT_FALSE(
- context.IsAllowedByCsp(CSPDirective::FrameSrc, GURL("http://c.com")));
- EXPECT_FALSE(
- context.IsAllowedByCsp(CSPDirective::FrameSrc, GURL("http://d.com")));
+ EXPECT_TRUE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://a.com"), false, SourceLocation()));
+ EXPECT_FALSE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://b.com"), false, SourceLocation()));
+ EXPECT_FALSE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://c.com"), false, SourceLocation()));
+ EXPECT_FALSE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://d.com"), false, SourceLocation()));
}
} // namespace content
« no previous file with comments | « content/common/content_security_policy/csp_context.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698