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

Unified Diff: third_party/WebKit/Source/core/dom/DocumentTest.cpp

Issue 2278823004: Stop supporting legacy keywords in Referrer-Policy header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jochen comment Created 4 years, 4 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/core/dom/DocumentTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/DocumentTest.cpp b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
index b7f3156c6fb14154f21656d32cebca411fa21ef5..b2224b1d87ab48aa4ca040475216c495d5fefc09 100644
--- a/third_party/WebKit/Source/core/dom/DocumentTest.cpp
+++ b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
@@ -184,28 +184,37 @@ TEST_F(DocumentTest, referrerPolicyParsing)
struct TestCase {
const char* policy;
ReferrerPolicy expected;
+ bool isLegacy;
} tests[] = {
- { "", ReferrerPolicyDefault },
+ { "", ReferrerPolicyDefault, false },
// Test that invalid policy values are ignored.
- { "not-a-real-policy", ReferrerPolicyDefault },
- { "not-a-real-policy,also-not-a-real-policy", ReferrerPolicyDefault },
- { "not-a-real-policy,unsafe-url", ReferrerPolicyAlways },
- { "unsafe-url,not-a-real-policy", ReferrerPolicyAlways },
+ { "not-a-real-policy", ReferrerPolicyDefault, false },
+ { "not-a-real-policy,also-not-a-real-policy", ReferrerPolicyDefault, false },
+ { "not-a-real-policy,unsafe-url", ReferrerPolicyAlways, false },
+ { "unsafe-url,not-a-real-policy", ReferrerPolicyAlways, false },
// Test parsing each of the policy values.
- { "always", ReferrerPolicyAlways },
- { "default", ReferrerPolicyNoReferrerWhenDowngrade },
- { "never", ReferrerPolicyNever },
- { "no-referrer", ReferrerPolicyNever },
- { "no-referrer-when-downgrade", ReferrerPolicyNoReferrerWhenDowngrade },
- { "origin", ReferrerPolicyOrigin },
- { "origin-when-crossorigin", ReferrerPolicyOriginWhenCrossOrigin },
- { "origin-when-cross-origin", ReferrerPolicyOriginWhenCrossOrigin },
+ { "always", ReferrerPolicyAlways, true },
+ { "default", ReferrerPolicyNoReferrerWhenDowngrade, true },
+ { "never", ReferrerPolicyNever, true },
+ { "no-referrer", ReferrerPolicyNever, false },
+ { "default", ReferrerPolicyNoReferrerWhenDowngrade, true },
+ { "no-referrer-when-downgrade", ReferrerPolicyNoReferrerWhenDowngrade, false },
+ { "origin", ReferrerPolicyOrigin, false },
+ { "origin-when-crossorigin", ReferrerPolicyOriginWhenCrossOrigin, true },
+ { "origin-when-cross-origin", ReferrerPolicyOriginWhenCrossOrigin, false },
{ "unsafe-url", ReferrerPolicyAlways },
};
for (auto test : tests) {
document().setReferrerPolicy(ReferrerPolicyDefault);
- document().parseAndSetReferrerPolicy(test.policy);
+ if (test.isLegacy) {
+ // Legacy keyword support must be explicitly enabled for the policy to parse successfully.
+ document().parseAndSetReferrerPolicy(test.policy);
+ EXPECT_EQ(ReferrerPolicyDefault, document().getReferrerPolicy());
+ document().parseAndSetReferrerPolicy(test.policy, true);
+ } else {
+ document().parseAndSetReferrerPolicy(test.policy);
+ }
EXPECT_EQ(test.expected, document().getReferrerPolicy()) << test.policy;
}
}

Powered by Google App Engine
This is Rietveld 408576698