| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/network/HTTPParsers.h" | 5 #include "platform/network/HTTPParsers.h" |
| 6 | 6 |
| 7 #include "platform/heap/Handle.h" | 7 #include "platform/heap/Handle.h" |
| 8 #include "platform/weborigin/Suborigin.h" | 8 #include "platform/weborigin/Suborigin.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "wtf/MathExtras.h" | 10 #include "wtf/MathExtras.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 expectParsePolicyFail("One policy, invalid characters", "foobar 'un$afe-post
message-send'"); | 276 expectParsePolicyFail("One policy, invalid characters", "foobar 'un$afe-post
message-send'"); |
| 277 expectParsePolicyFail("One policy, caps", "foobar 'UNSAFE-POSTMESSAGE-SEND'"
); | 277 expectParsePolicyFail("One policy, caps", "foobar 'UNSAFE-POSTMESSAGE-SEND'"
); |
| 278 expectParsePolicyFail("One policy, missing first quote", "foobar unsafe-post
message-send'"); | 278 expectParsePolicyFail("One policy, missing first quote", "foobar unsafe-post
message-send'"); |
| 279 expectParsePolicyFail("One policy, missing last quote", "foobar 'unsafe-post
message-send"); | 279 expectParsePolicyFail("One policy, missing last quote", "foobar 'unsafe-post
message-send"); |
| 280 expectParsePolicyFail("One policy, invalid character at end", "foobar 'unsaf
e-postmessage-send';"); | 280 expectParsePolicyFail("One policy, invalid character at end", "foobar 'unsaf
e-postmessage-send';"); |
| 281 expectParsePolicyFail("Multiple policies, extra character between options",
"foobar 'unsafe-postmessage-send' ; 'unsafe-postmessage-send'"); | 281 expectParsePolicyFail("Multiple policies, extra character between options",
"foobar 'unsafe-postmessage-send' ; 'unsafe-postmessage-send'"); |
| 282 expectParsePolicyFail("Policy that is a single quote", "foobar '"); | 282 expectParsePolicyFail("Policy that is a single quote", "foobar '"); |
| 283 expectParsePolicyFail("Valid policy and then policy that is a single quote",
"foobar 'unsafe-postmessage-send' '"); | 283 expectParsePolicyFail("Valid policy and then policy that is a single quote",
"foobar 'unsafe-postmessage-send' '"); |
| 284 } | 284 } |
| 285 | 285 |
| 286 TEST(HTTPParsersTest, ParseReferrerPolicy) |
| 287 { |
| 288 EXPECT_EQ(ReferrerPolicyDefault, parseReferrerPolicyHeader("")); |
| 289 |
| 290 // Test that invalid policy values are ignored. |
| 291 EXPECT_EQ(ReferrerPolicyDefault, parseReferrerPolicyHeader("not-a-valid-poli
cy")); |
| 292 EXPECT_EQ(ReferrerPolicyDefault, parseReferrerPolicyHeader("not-a-valid-poli
cy,also-not-a-valid-policy")); |
| 293 EXPECT_EQ(ReferrerPolicyAlways, parseReferrerPolicyHeader("not-a-valid-polic
y,unsafe-url")); |
| 294 EXPECT_EQ(ReferrerPolicyAlways, parseReferrerPolicyHeader("unsafe-url,not-a-
valid-policy")); |
| 295 |
| 296 // Test parsing each of the policy values. |
| 297 EXPECT_EQ(ReferrerPolicyAlways, parseReferrerPolicyHeader("unsafe-url")); |
| 298 EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade, parseReferrerPolicyHeader("
no-referrer-when-downgrade")); |
| 299 EXPECT_EQ(ReferrerPolicyNever, parseReferrerPolicyHeader("no-referrer")); |
| 300 EXPECT_EQ(ReferrerPolicyOrigin, parseReferrerPolicyHeader("origin")); |
| 301 EXPECT_EQ(ReferrerPolicyOriginWhenCrossOrigin, parseReferrerPolicyHeader("or
igin-when-cross-origin")); |
| 302 } |
| 303 |
| 286 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |