| Index: third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp b/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
|
| index 73697a53f75f57011d30e14ca61784761b9ce565..c0cca7e0840d43bd92b04b4547c6f8048fdaed8e 100644
|
| --- a/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
|
| @@ -1336,4 +1336,40 @@ TEST_F(SourceListDirectiveTest, GetSources) {
|
| }
|
| }
|
|
|
| +TEST_F(SourceListDirectiveTest, ParseHost) {
|
| + struct TestCase {
|
| + String sources;
|
| + bool expected;
|
| + } cases[] = {
|
| + // Wildcard.
|
| + {"*", true},
|
| + {"*.", false},
|
| + {"*.a", true},
|
| + {"a.*.a", false},
|
| + {"a.*", false},
|
| +
|
| + // Dots.
|
| + {"a.b.c", true},
|
| + {"a.b.", false},
|
| + {".b.c", false},
|
| + {"a..c", false},
|
| +
|
| + // Valid/Invalid characters.
|
| + {"az09-", true},
|
| + {"+", false},
|
| + };
|
| +
|
| + for (const auto& test : cases) {
|
| + String host;
|
| + CSPSource::WildcardDisposition disposition = CSPSource::NoWildcard;
|
| + Vector<UChar> characters;
|
| + test.sources.appendTo(characters);
|
| + const UChar* start = characters.data();
|
| + const UChar* end = start + characters.size();
|
| + EXPECT_EQ(test.expected,
|
| + SourceListDirective::parseHost(start, end, host, disposition))
|
| + << "SourceListDirective::parseHost fail to parse: " << test.sources;
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|