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

Unified Diff: third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp

Issue 2451673002: Trim leading and trailing whitespace from stored CSP headers. (Closed)
Patch Set: ASAN Created 4 years, 2 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 | « third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp b/third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp
index 62361d795bfa96444fcac53ef758cf07e52ef014..de8284a448854ce4752017c0c94d2a82dc07ae30 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp
@@ -33,6 +33,25 @@ class CSPDirectiveListTest : public ::testing::Test {
Persistent<ContentSecurityPolicy> csp;
};
+TEST_F(CSPDirectiveListTest, Header) {
+ struct TestCase {
+ const char* list;
+ const char* expected;
+ } cases[] = {{"script-src 'self'", "script-src 'self'"},
+ {" script-src 'self' ", "script-src 'self'"},
+ {"\t\tscript-src 'self'", "script-src 'self'"},
+ {"script-src 'self' \t", "script-src 'self'"}};
+
+ for (const auto& test : cases) {
+ Member<CSPDirectiveList> directiveList =
+ createList(test.list, ContentSecurityPolicyHeaderTypeReport);
+ EXPECT_EQ(test.expected, directiveList->header());
+ directiveList =
+ createList(test.list, ContentSecurityPolicyHeaderTypeEnforce);
+ EXPECT_EQ(test.expected, directiveList->header());
+ }
+}
+
TEST_F(CSPDirectiveListTest, IsMatchingNoncePresent) {
struct TestCase {
const char* list;
« no previous file with comments | « third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698