| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "platform/weborigin/OriginAccessEntry.h" | 31 #include "platform/weborigin/OriginAccessEntry.h" |
| 32 | 32 |
| 33 #include "platform/testing/TestingPlatformSupport.h" | |
| 34 #include "platform/weborigin/KURL.h" | 33 #include "platform/weborigin/KURL.h" |
| 35 #include "platform/weborigin/SecurityOrigin.h" | 34 #include "platform/weborigin/SecurityOrigin.h" |
| 36 #include "public/platform/Platform.h" | |
| 37 #include "public/platform/WebPublicSuffixList.h" | |
| 38 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 39 | 36 |
| 40 namespace blink { | 37 namespace blink { |
| 41 | 38 |
| 42 class OriginAccessEntryTestSuffixList : public blink::WebPublicSuffixList { | |
| 43 public: | |
| 44 size_t getPublicSuffixLength(const blink::WebString&) override | |
| 45 { | |
| 46 return m_length; | |
| 47 } | |
| 48 | |
| 49 void setPublicSuffix(const blink::WebString& suffix) | |
| 50 { | |
| 51 m_length = suffix.length(); | |
| 52 } | |
| 53 | |
| 54 private: | |
| 55 size_t m_length; | |
| 56 }; | |
| 57 | |
| 58 class OriginAccessEntryTestPlatform : public TestingPlatformSupport { | |
| 59 public: | |
| 60 blink::WebPublicSuffixList* publicSuffixList() override | |
| 61 { | |
| 62 return &m_suffixList; | |
| 63 } | |
| 64 | |
| 65 void setPublicSuffix(const blink::WebString& suffix) | |
| 66 { | |
| 67 m_suffixList.setPublicSuffix(suffix); | |
| 68 } | |
| 69 | |
| 70 private: | |
| 71 OriginAccessEntryTestSuffixList m_suffixList; | |
| 72 }; | |
| 73 | |
| 74 TEST(OriginAccessEntryTest, PublicSuffixListTest) | 39 TEST(OriginAccessEntryTest, PublicSuffixListTest) |
| 75 { | 40 { |
| 76 OriginAccessEntryTestPlatform platform; | |
| 77 platform.setPublicSuffix("com"); | |
| 78 | |
| 79 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("http://www
.google.com"); | 41 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("http://www
.google.com"); |
| 80 OriginAccessEntry entry1("http", "google.com", OriginAccessEntry::AllowSubdo
mains); | 42 OriginAccessEntry entry1("http", "google.com", OriginAccessEntry::AllowSubdo
mains); |
| 81 OriginAccessEntry entry2("http", "hamster.com", OriginAccessEntry::AllowSubd
omains); | 43 OriginAccessEntry entry2("http", "hamster.com", OriginAccessEntry::AllowSubd
omains); |
| 82 OriginAccessEntry entry3("http", "com", OriginAccessEntry::AllowSubdomains); | 44 OriginAccessEntry entry3("http", "com", OriginAccessEntry::AllowSubdomains); |
| 83 EXPECT_EQ(OriginAccessEntry::MatchesOrigin, entry1.matchesOrigin(*origin)); | 45 EXPECT_EQ(OriginAccessEntry::MatchesOrigin, entry1.matchesOrigin(*origin)); |
| 84 EXPECT_EQ(OriginAccessEntry::DoesNotMatchOrigin, entry2.matchesOrigin(*origi
n)); | 46 EXPECT_EQ(OriginAccessEntry::DoesNotMatchOrigin, entry2.matchesOrigin(*origi
n)); |
| 85 EXPECT_EQ(OriginAccessEntry::MatchesOriginButIsPublicSuffix, entry3.matchesO
rigin(*origin)); | 47 EXPECT_EQ(OriginAccessEntry::MatchesOriginButIsPublicSuffix, entry3.matchesO
rigin(*origin)); |
| 86 } | 48 } |
| 87 | 49 |
| 88 TEST(OriginAccessEntryTest, AllowSubdomainsTest) | 50 TEST(OriginAccessEntryTest, AllowSubdomainsTest) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 106 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin, OriginAccessEntry::MatchesOrigin }, | 68 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin, OriginAccessEntry::MatchesOrigin }, |
| 107 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin, OriginAccessEntry::MatchesOrigin }, | 69 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin, OriginAccessEntry::MatchesOrigin }, |
| 108 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin, OriginAccessEntry::MatchesOrigin }, | 70 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin, OriginAccessEntry::MatchesOrigin }, |
| 109 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin, OriginAccessEntry::DoesNotMatchOrigin }, | 71 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin, OriginAccessEntry::DoesNotMatchOrigin }, |
| 110 { "http", "example.com", "https://beispiel.de/", OriginAccessEntry::Does
NotMatchOrigin, OriginAccessEntry::DoesNotMatchOrigin }, | 72 { "http", "example.com", "https://beispiel.de/", OriginAccessEntry::Does
NotMatchOrigin, OriginAccessEntry::DoesNotMatchOrigin }, |
| 111 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin, O
riginAccessEntry::MatchesOrigin }, | 73 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin, O
riginAccessEntry::MatchesOrigin }, |
| 112 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin, O
riginAccessEntry::MatchesOrigin }, | 74 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin, O
riginAccessEntry::MatchesOrigin }, |
| 113 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin, OriginAccessEntry::MatchesOrigin }, | 75 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin, OriginAccessEntry::MatchesOrigin }, |
| 114 }; | 76 }; |
| 115 | 77 |
| 116 OriginAccessEntryTestPlatform platform; | |
| 117 platform.setPublicSuffix("com"); | |
| 118 | |
| 119 for (const auto& test : inputs) { | 78 for (const auto& test : inputs) { |
| 120 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); | 79 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); |
| 121 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 80 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 122 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); | 81 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); |
| 123 EXPECT_EQ(test.expectedOrigin, entry1.matchesOrigin(*originToTest)); | 82 EXPECT_EQ(test.expectedOrigin, entry1.matchesOrigin(*originToTest)); |
| 124 EXPECT_EQ(test.expectedDomain, entry1.matchesDomain(*originToTest)); | 83 EXPECT_EQ(test.expectedDomain, entry1.matchesDomain(*originToTest)); |
| 125 } | 84 } |
| 126 } | 85 } |
| 127 | 86 |
| 128 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) | 87 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 144 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::Match
esOriginButIsPublicSuffix }, | 103 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::Match
esOriginButIsPublicSuffix }, |
| 145 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin }, | 104 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin }, |
| 146 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, | 105 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, |
| 147 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, | 106 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, |
| 148 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, | 107 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, |
| 149 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin }, | 108 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin }, |
| 150 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, | 109 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, |
| 151 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 110 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, |
| 152 }; | 111 }; |
| 153 | 112 |
| 154 OriginAccessEntryTestPlatform platform; | |
| 155 platform.setPublicSuffix("com"); | |
| 156 | |
| 157 for (const auto& test : inputs) { | 113 for (const auto& test : inputs) { |
| 158 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 114 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 159 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); | 115 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); |
| 160 | 116 |
| 161 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); | 117 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); |
| 162 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 118 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 163 } | 119 } |
| 164 } | 120 } |
| 165 | 121 |
| 166 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTestWithDottedSuffix) | 122 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTestWithDottedSuffix) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 182 { "http", "appspot.com", "http://www.www.example.appspot.com/", OriginAc
cessEntry::MatchesOriginButIsPublicSuffix }, | 138 { "http", "appspot.com", "http://www.www.example.appspot.com/", OriginAc
cessEntry::MatchesOriginButIsPublicSuffix }, |
| 183 { "https", "example.appspot.com", "http://example.appspot.com/", OriginA
ccessEntry::DoesNotMatchOrigin }, | 139 { "https", "example.appspot.com", "http://example.appspot.com/", OriginA
ccessEntry::DoesNotMatchOrigin }, |
| 184 { "https", "example.appspot.com", "http://www.example.appspot.com/", Ori
ginAccessEntry::DoesNotMatchOrigin }, | 140 { "https", "example.appspot.com", "http://www.example.appspot.com/", Ori
ginAccessEntry::DoesNotMatchOrigin }, |
| 185 { "https", "example.appspot.com", "http://www.www.example.appspot.com/",
OriginAccessEntry::DoesNotMatchOrigin }, | 141 { "https", "example.appspot.com", "http://www.www.example.appspot.com/",
OriginAccessEntry::DoesNotMatchOrigin }, |
| 186 { "http", "example.appspot.com", "http://beispiel.de/", OriginAccessEntr
y::DoesNotMatchOrigin }, | 142 { "http", "example.appspot.com", "http://beispiel.de/", OriginAccessEntr
y::DoesNotMatchOrigin }, |
| 187 { "http", "", "http://example.appspot.com/", OriginAccessEntry::MatchesO
rigin }, | 143 { "http", "", "http://example.appspot.com/", OriginAccessEntry::MatchesO
rigin }, |
| 188 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, | 144 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, |
| 189 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 145 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, |
| 190 }; | 146 }; |
| 191 | 147 |
| 192 OriginAccessEntryTestPlatform platform; | |
| 193 platform.setPublicSuffix("appspot.com"); | |
| 194 | |
| 195 for (const auto& test : inputs) { | 148 for (const auto& test : inputs) { |
| 196 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 149 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 197 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); | 150 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); |
| 198 | 151 |
| 199 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); | 152 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); |
| 200 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 153 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 201 } | 154 } |
| 202 } | 155 } |
| 203 | 156 |
| 204 TEST(OriginAccessEntryTest, DisallowSubdomainsTest) | 157 TEST(OriginAccessEntryTest, DisallowSubdomainsTest) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 217 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::DoesN
otMatchOrigin }, | 170 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::DoesN
otMatchOrigin }, |
| 218 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin }, | 171 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin }, |
| 219 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, | 172 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, |
| 220 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, | 173 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, |
| 221 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, | 174 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, |
| 222 { "http", "", "http://example.com/", OriginAccessEntry::DoesNotMatchOrig
in }, | 175 { "http", "", "http://example.com/", OriginAccessEntry::DoesNotMatchOrig
in }, |
| 223 { "http", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOrig
in }, | 176 { "http", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOrig
in }, |
| 224 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 177 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, |
| 225 }; | 178 }; |
| 226 | 179 |
| 227 OriginAccessEntryTestPlatform platform; | |
| 228 platform.setPublicSuffix("com"); | |
| 229 | |
| 230 for (const auto& test : inputs) { | 180 for (const auto& test : inputs) { |
| 231 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); | 181 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); |
| 232 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 182 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 233 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); | 183 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); |
| 234 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 184 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 235 } | 185 } |
| 236 } | 186 } |
| 237 | 187 |
| 238 TEST(OriginAccessEntryTest, IPAddressTest) | 188 TEST(OriginAccessEntryTest, IPAddressTest) |
| 239 { | 189 { |
| 240 struct TestCase { | 190 struct TestCase { |
| 241 const char* protocol; | 191 const char* protocol; |
| 242 const char* host; | 192 const char* host; |
| 243 bool isIPAddress; | 193 bool isIPAddress; |
| 244 } inputs[] = { | 194 } inputs[] = { |
| 245 { "http", "1.1.1.1", true }, | 195 { "http", "1.1.1.1", true }, |
| 246 { "http", "1.1.1.1.1", false }, | 196 { "http", "1.1.1.1.1", false }, |
| 247 { "http", "example.com", false }, | 197 { "http", "example.com", false }, |
| 248 { "http", "hostname.that.ends.with.a.number1", false }, | 198 { "http", "hostname.that.ends.with.a.number1", false }, |
| 249 { "http", "2001:db8::1", false }, | 199 { "http", "2001:db8::1", false }, |
| 250 { "http", "[2001:db8::1]", true }, | 200 { "http", "[2001:db8::1]", true }, |
| 251 { "http", "2001:db8::a", false }, | 201 { "http", "2001:db8::a", false }, |
| 252 { "http", "[2001:db8::a]", true }, | 202 { "http", "[2001:db8::a]", true }, |
| 253 { "http", "", false }, | 203 { "http", "", false }, |
| 254 }; | 204 }; |
| 255 | 205 |
| 256 OriginAccessEntryTestPlatform platform; | |
| 257 platform.setPublicSuffix("com"); | |
| 258 | |
| 259 for (const auto& test : inputs) { | 206 for (const auto& test : inputs) { |
| 260 SCOPED_TRACE(testing::Message() << "Host: " << test.host); | 207 SCOPED_TRACE(testing::Message() << "Host: " << test.host); |
| 261 OriginAccessEntry entry(test.protocol, test.host, OriginAccessEntry::Dis
allowSubdomains); | 208 OriginAccessEntry entry(test.protocol, test.host, OriginAccessEntry::Dis
allowSubdomains); |
| 262 EXPECT_EQ(test.isIPAddress, entry.hostIsIPAddress()) << test.host; | 209 EXPECT_EQ(test.isIPAddress, entry.hostIsIPAddress()) << test.host; |
| 263 } | 210 } |
| 264 } | 211 } |
| 265 | 212 |
| 266 TEST(OriginAccessEntryTest, IPAddressMatchingTest) | 213 TEST(OriginAccessEntryTest, IPAddressMatchingTest) |
| 267 { | 214 { |
| 268 struct TestCase { | 215 struct TestCase { |
| 269 const char* protocol; | 216 const char* protocol; |
| 270 const char* host; | 217 const char* host; |
| 271 const char* origin; | 218 const char* origin; |
| 272 OriginAccessEntry::MatchResult expected; | 219 OriginAccessEntry::MatchResult expected; |
| 273 } inputs[] = { | 220 } inputs[] = { |
| 274 { "http", "192.0.0.123", "http://192.0.0.123/", OriginAccessEntry::Match
esOrigin }, | 221 { "http", "192.0.0.123", "http://192.0.0.123/", OriginAccessEntry::Match
esOrigin }, |
| 275 { "http", "0.0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMa
tchOrigin }, | 222 { "http", "0.0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMa
tchOrigin }, |
| 276 { "http", "0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, | 223 { "http", "0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, |
| 277 { "http", "1.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, | 224 { "http", "1.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, |
| 278 }; | 225 }; |
| 279 | 226 |
| 280 OriginAccessEntryTestPlatform platform; | |
| 281 platform.setPublicSuffix("com"); | |
| 282 | |
| 283 for (const auto& test : inputs) { | 227 for (const auto& test : inputs) { |
| 284 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); | 228 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); |
| 285 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 229 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 286 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); | 230 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); |
| 287 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 231 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 288 | 232 |
| 289 OriginAccessEntry entry2(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); | 233 OriginAccessEntry entry2(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); |
| 290 EXPECT_EQ(test.expected, entry2.matchesOrigin(*originToTest)); | 234 EXPECT_EQ(test.expected, entry2.matchesOrigin(*originToTest)); |
| 291 } | 235 } |
| 292 } | 236 } |
| 293 | 237 |
| 294 } // namespace blink | 238 } // namespace blink |
| OLD | NEW |