From 9b61ca88b112c7725020d68e8ffe2d68ae43a12d Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Fri, 26 Apr 2024 07:38:20 +0000 Subject: [PATCH] Bug 1890277: part 3) Add CSP parser tests for the `trusted-types` directive. r=tschuster Differential Revision: https://phabricator.services.mozilla.com/D207130 --- dom/security/test/gtest/TestCSPParser.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom/security/test/gtest/TestCSPParser.cpp b/dom/security/test/gtest/TestCSPParser.cpp index 859add014220..388055f38852 100644 --- a/dom/security/test/gtest/TestCSPParser.cpp +++ b/dom/security/test/gtest/TestCSPParser.cpp @@ -228,6 +228,9 @@ TEST(CSPParser, Directives) "script-src http://example.com"}, { "require-trusted-types-for 'script'", "require-trusted-types-for 'script'" }, + { "trusted-types somePolicyName", "trusted-types somePolicyName" }, + { "trusted-types somePolicyName anotherPolicyName 1 - # = _ / @ . % *", + "trusted-types somePolicyName anotherPolicyName 1 - # = _ / @ . % *" }, // clang-format on }; @@ -255,6 +258,11 @@ TEST(CSPParser, Keywords) "script-src 'wasm-unsafe-eval'" }, { "img-src 'none'; script-src 'unsafe-eval' 'unsafe-inline'; default-src 'self'", "img-src 'none'; script-src 'unsafe-eval' 'unsafe-inline'; default-src 'self'" }, + { "trusted-types somePolicyName 'allow-duplicates'", + "trusted-types somePolicyName 'allow-duplicates'" }, + { "trusted-types 'none'", "trusted-types 'none'" }, + { "trusted-types", "trusted-types 'none'" }, + { "trusted-types *", "trusted-types *" }, // clang-format on }; @@ -597,6 +605,7 @@ TEST(CSPParser, BadPolicies) { "report-uri http://:foo", ""}, { "require-sri-for", ""}, { "require-sri-for style", ""}, + { "trusted-types $", ""}, // clang-format on }; -- 2.11.4.GIT