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

Unified Diff: third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp

Issue 2075053003: Add basic Referrer-Policy support for Documents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add crbug for TODO Created 4 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: third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
diff --git a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
index 3420d2ba30d0b45778d15919fbe44070f532bd69..94edc3dc27a5ff2edf552bf735cec0d79d7c07cd 100644
--- a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
+++ b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
@@ -283,4 +283,22 @@ TEST(HTTPParsersTest, SuboriginParseInvalidPolicy)
expectParsePolicyFail("Valid policy and then policy that is a single quote", "foobar 'unsafe-postmessage-send' '");
}
+TEST(HTTPParsersTest, ParseReferrerPolicy)
+{
+ EXPECT_EQ(ReferrerPolicyDefault, parseReferrerPolicyHeader(""));
+
+ // Test that invalid policy values are ignored.
+ EXPECT_EQ(ReferrerPolicyDefault, parseReferrerPolicyHeader("not-a-valid-policy"));
+ EXPECT_EQ(ReferrerPolicyDefault, parseReferrerPolicyHeader("not-a-valid-policy,also-not-a-valid-policy"));
+ EXPECT_EQ(ReferrerPolicyAlways, parseReferrerPolicyHeader("not-a-valid-policy,unsafe-url"));
+ EXPECT_EQ(ReferrerPolicyAlways, parseReferrerPolicyHeader("unsafe-url,not-a-valid-policy"));
+
+ // Test parsing each of the policy values.
+ EXPECT_EQ(ReferrerPolicyAlways, parseReferrerPolicyHeader("unsafe-url"));
+ EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade, parseReferrerPolicyHeader("no-referrer-when-downgrade"));
+ EXPECT_EQ(ReferrerPolicyNever, parseReferrerPolicyHeader("no-referrer"));
+ EXPECT_EQ(ReferrerPolicyOrigin, parseReferrerPolicyHeader("origin"));
+ EXPECT_EQ(ReferrerPolicyOriginWhenCrossOrigin, parseReferrerPolicyHeader("origin-when-cross-origin"));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698