| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 { | 50 { |
| 51 m_length = suffix.length(); | 51 m_length = suffix.length(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 size_t m_length; | 55 size_t m_length; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class OriginAccessEntryTestPlatform : public blink::Platform { | 58 class OriginAccessEntryTestPlatform : public blink::Platform { |
| 59 public: | 59 public: |
| 60 OriginAccessEntryTestPlatform() |
| 61 : m_oldPlatform(Platform::current()) |
| 62 { |
| 63 Platform::initialize(this); |
| 64 } |
| 65 |
| 66 ~OriginAccessEntryTestPlatform() |
| 67 { |
| 68 Platform::initialize(m_oldPlatform); |
| 69 } |
| 70 |
| 60 blink::WebPublicSuffixList* publicSuffixList() override | 71 blink::WebPublicSuffixList* publicSuffixList() override |
| 61 { | 72 { |
| 62 return &m_suffixList; | 73 return &m_suffixList; |
| 63 } | 74 } |
| 64 | 75 |
| 65 // Stub for pure virtual method. | 76 // Stub for pure virtual method. |
| 66 void cryptographicallyRandomValues(unsigned char*, size_t) override | 77 void cryptographicallyRandomValues(unsigned char*, size_t) override |
| 67 { | 78 { |
| 68 RELEASE_ASSERT_NOT_REACHED(); | 79 RELEASE_ASSERT_NOT_REACHED(); |
| 69 } | 80 } |
| 70 | 81 |
| 71 void setPublicSuffix(const blink::WebString& suffix) | 82 void setPublicSuffix(const blink::WebString& suffix) |
| 72 { | 83 { |
| 73 m_suffixList.setPublicSuffix(suffix); | 84 m_suffixList.setPublicSuffix(suffix); |
| 74 } | 85 } |
| 75 | 86 |
| 76 private: | 87 private: |
| 88 blink::Platform* m_oldPlatform; |
| 77 OriginAccessEntryTestSuffixList m_suffixList; | 89 OriginAccessEntryTestSuffixList m_suffixList; |
| 78 }; | 90 }; |
| 79 | 91 |
| 80 TEST(OriginAccessEntryTest, PublicSuffixListTest) | 92 TEST(OriginAccessEntryTest, PublicSuffixListTest) |
| 81 { | 93 { |
| 82 OriginAccessEntryTestPlatform platform; | 94 OriginAccessEntryTestPlatform platform; |
| 83 platform.setPublicSuffix("com"); | 95 platform.setPublicSuffix("com"); |
| 84 Platform::initialize(&platform); | |
| 85 | 96 |
| 86 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("http://www
.google.com"); | 97 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("http://www
.google.com"); |
| 87 OriginAccessEntry entry1("http", "google.com", OriginAccessEntry::AllowSubdo
mains); | 98 OriginAccessEntry entry1("http", "google.com", OriginAccessEntry::AllowSubdo
mains); |
| 88 OriginAccessEntry entry2("http", "hamster.com", OriginAccessEntry::AllowSubd
omains); | 99 OriginAccessEntry entry2("http", "hamster.com", OriginAccessEntry::AllowSubd
omains); |
| 89 OriginAccessEntry entry3("http", "com", OriginAccessEntry::AllowSubdomains); | 100 OriginAccessEntry entry3("http", "com", OriginAccessEntry::AllowSubdomains); |
| 90 EXPECT_EQ(OriginAccessEntry::MatchesOrigin, entry1.matchesOrigin(*origin)); | 101 EXPECT_EQ(OriginAccessEntry::MatchesOrigin, entry1.matchesOrigin(*origin)); |
| 91 EXPECT_EQ(OriginAccessEntry::DoesNotMatchOrigin, entry2.matchesOrigin(*origi
n)); | 102 EXPECT_EQ(OriginAccessEntry::DoesNotMatchOrigin, entry2.matchesOrigin(*origi
n)); |
| 92 EXPECT_EQ(OriginAccessEntry::MatchesOriginButIsPublicSuffix, entry3.matchesO
rigin(*origin)); | 103 EXPECT_EQ(OriginAccessEntry::MatchesOriginButIsPublicSuffix, entry3.matchesO
rigin(*origin)); |
| 93 | |
| 94 Platform::shutdown(); | |
| 95 } | 104 } |
| 96 | 105 |
| 97 TEST(OriginAccessEntryTest, AllowSubdomainsTest) | 106 TEST(OriginAccessEntryTest, AllowSubdomainsTest) |
| 98 { | 107 { |
| 99 struct TestCase { | 108 struct TestCase { |
| 100 const char* protocol; | 109 const char* protocol; |
| 101 const char* host; | 110 const char* host; |
| 102 const char* origin; | 111 const char* origin; |
| 103 OriginAccessEntry::MatchResult expected; | 112 OriginAccessEntry::MatchResult expected; |
| 104 } inputs[] = { | 113 } inputs[] = { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 115 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, | 124 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, |
| 116 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, | 125 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, |
| 117 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, | 126 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, |
| 118 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin }, | 127 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin }, |
| 119 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, | 128 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, |
| 120 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 129 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, |
| 121 }; | 130 }; |
| 122 | 131 |
| 123 OriginAccessEntryTestPlatform platform; | 132 OriginAccessEntryTestPlatform platform; |
| 124 platform.setPublicSuffix("com"); | 133 platform.setPublicSuffix("com"); |
| 125 Platform::initialize(&platform); | |
| 126 | 134 |
| 127 for (const auto& test : inputs) { | 135 for (const auto& test : inputs) { |
| 128 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); | 136 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); |
| 129 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 137 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 130 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); | 138 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); |
| 131 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 139 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 132 } | 140 } |
| 133 | |
| 134 Platform::shutdown(); | |
| 135 } | 141 } |
| 136 | 142 |
| 137 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) | 143 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) |
| 138 { | 144 { |
| 139 struct TestCase { | 145 struct TestCase { |
| 140 const char* protocol; | 146 const char* protocol; |
| 141 const char* host; | 147 const char* host; |
| 142 const char* origin; | 148 const char* origin; |
| 143 OriginAccessEntry::MatchResult expected; | 149 OriginAccessEntry::MatchResult expected; |
| 144 } inputs[] = { | 150 } inputs[] = { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 155 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, | 161 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, |
| 156 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, | 162 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, |
| 157 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, | 163 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, |
| 158 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin }, | 164 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin }, |
| 159 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, | 165 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, |
| 160 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 166 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, |
| 161 }; | 167 }; |
| 162 | 168 |
| 163 OriginAccessEntryTestPlatform platform; | 169 OriginAccessEntryTestPlatform platform; |
| 164 platform.setPublicSuffix("com"); | 170 platform.setPublicSuffix("com"); |
| 165 Platform::initialize(&platform); | |
| 166 | 171 |
| 167 for (const auto& test : inputs) { | 172 for (const auto& test : inputs) { |
| 168 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 173 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 169 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); | 174 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); |
| 170 | 175 |
| 171 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); | 176 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); |
| 172 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 177 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 173 } | 178 } |
| 174 | |
| 175 Platform::shutdown(); | |
| 176 } | 179 } |
| 177 | 180 |
| 178 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTestWithDottedSuffix) | 181 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTestWithDottedSuffix) |
| 179 { | 182 { |
| 180 struct TestCase { | 183 struct TestCase { |
| 181 const char* protocol; | 184 const char* protocol; |
| 182 const char* host; | 185 const char* host; |
| 183 const char* origin; | 186 const char* origin; |
| 184 OriginAccessEntry::MatchResult expected; | 187 OriginAccessEntry::MatchResult expected; |
| 185 } inputs[] = { | 188 } inputs[] = { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 196 { "https", "example.appspot.com", "http://www.example.appspot.com/", Ori
ginAccessEntry::DoesNotMatchOrigin }, | 199 { "https", "example.appspot.com", "http://www.example.appspot.com/", Ori
ginAccessEntry::DoesNotMatchOrigin }, |
| 197 { "https", "example.appspot.com", "http://www.www.example.appspot.com/",
OriginAccessEntry::DoesNotMatchOrigin }, | 200 { "https", "example.appspot.com", "http://www.www.example.appspot.com/",
OriginAccessEntry::DoesNotMatchOrigin }, |
| 198 { "http", "example.appspot.com", "http://beispiel.de/", OriginAccessEntr
y::DoesNotMatchOrigin }, | 201 { "http", "example.appspot.com", "http://beispiel.de/", OriginAccessEntr
y::DoesNotMatchOrigin }, |
| 199 { "http", "", "http://example.appspot.com/", OriginAccessEntry::MatchesO
rigin }, | 202 { "http", "", "http://example.appspot.com/", OriginAccessEntry::MatchesO
rigin }, |
| 200 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, | 203 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, |
| 201 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 204 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, |
| 202 }; | 205 }; |
| 203 | 206 |
| 204 OriginAccessEntryTestPlatform platform; | 207 OriginAccessEntryTestPlatform platform; |
| 205 platform.setPublicSuffix("appspot.com"); | 208 platform.setPublicSuffix("appspot.com"); |
| 206 Platform::initialize(&platform); | |
| 207 | 209 |
| 208 for (const auto& test : inputs) { | 210 for (const auto& test : inputs) { |
| 209 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 211 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 210 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); | 212 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowRegisterableDomains); |
| 211 | 213 |
| 212 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); | 214 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin << ", Domain: " << entry1.registerable().utf8().data()); |
| 213 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 215 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 214 } | 216 } |
| 215 | |
| 216 Platform::shutdown(); | |
| 217 } | 217 } |
| 218 | 218 |
| 219 TEST(OriginAccessEntryTest, DisallowSubdomainsTest) | 219 TEST(OriginAccessEntryTest, DisallowSubdomainsTest) |
| 220 { | 220 { |
| 221 struct TestCase { | 221 struct TestCase { |
| 222 const char* protocol; | 222 const char* protocol; |
| 223 const char* host; | 223 const char* host; |
| 224 const char* origin; | 224 const char* origin; |
| 225 OriginAccessEntry::MatchResult expected; | 225 OriginAccessEntry::MatchResult expected; |
| 226 } inputs[] = { | 226 } inputs[] = { |
| 227 { "http", "example.com", "http://example.com/", OriginAccessEntry::Match
esOrigin }, | 227 { "http", "example.com", "http://example.com/", OriginAccessEntry::Match
esOrigin }, |
| 228 { "http", "example.com", "http://www.example.com/", OriginAccessEntry::D
oesNotMatchOrigin }, | 228 { "http", "example.com", "http://www.example.com/", OriginAccessEntry::D
oesNotMatchOrigin }, |
| 229 { "http", "example.com", "http://www.www.example.com/", OriginAccessEntr
y::DoesNotMatchOrigin }, | 229 { "http", "example.com", "http://www.www.example.com/", OriginAccessEntr
y::DoesNotMatchOrigin }, |
| 230 { "http", "com", "http://example.com/", OriginAccessEntry::DoesNotMatchO
rigin }, | 230 { "http", "com", "http://example.com/", OriginAccessEntry::DoesNotMatchO
rigin }, |
| 231 { "http", "com", "http://www.example.com/", OriginAccessEntry::DoesNotMa
tchOrigin }, | 231 { "http", "com", "http://www.example.com/", OriginAccessEntry::DoesNotMa
tchOrigin }, |
| 232 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::DoesN
otMatchOrigin }, | 232 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::DoesN
otMatchOrigin }, |
| 233 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin }, | 233 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin }, |
| 234 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, | 234 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, |
| 235 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, | 235 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, |
| 236 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, | 236 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, |
| 237 { "http", "", "http://example.com/", OriginAccessEntry::DoesNotMatchOrig
in }, | 237 { "http", "", "http://example.com/", OriginAccessEntry::DoesNotMatchOrig
in }, |
| 238 { "http", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOrig
in }, | 238 { "http", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOrig
in }, |
| 239 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 239 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 OriginAccessEntryTestPlatform platform; | 242 OriginAccessEntryTestPlatform platform; |
| 243 platform.setPublicSuffix("com"); | 243 platform.setPublicSuffix("com"); |
| 244 Platform::initialize(&platform); | |
| 245 | 244 |
| 246 for (const auto& test : inputs) { | 245 for (const auto& test : inputs) { |
| 247 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); | 246 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); |
| 248 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 247 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 249 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); | 248 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); |
| 250 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 249 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 251 } | 250 } |
| 252 | |
| 253 Platform::shutdown(); | |
| 254 } | 251 } |
| 255 | 252 |
| 256 TEST(OriginAccessEntryTest, IPAddressTest) | 253 TEST(OriginAccessEntryTest, IPAddressTest) |
| 257 { | 254 { |
| 258 struct TestCase { | 255 struct TestCase { |
| 259 const char* protocol; | 256 const char* protocol; |
| 260 const char* host; | 257 const char* host; |
| 261 bool isIPAddress; | 258 bool isIPAddress; |
| 262 } inputs[] = { | 259 } inputs[] = { |
| 263 { "http", "1.1.1.1", true }, | 260 { "http", "1.1.1.1", true }, |
| 264 { "http", "1.1.1.1.1", false }, | 261 { "http", "1.1.1.1.1", false }, |
| 265 { "http", "example.com", false }, | 262 { "http", "example.com", false }, |
| 266 { "http", "hostname.that.ends.with.a.number1", false }, | 263 { "http", "hostname.that.ends.with.a.number1", false }, |
| 267 { "http", "2001:db8::1", false }, | 264 { "http", "2001:db8::1", false }, |
| 268 { "http", "[2001:db8::1]", true }, | 265 { "http", "[2001:db8::1]", true }, |
| 269 { "http", "2001:db8::a", false }, | 266 { "http", "2001:db8::a", false }, |
| 270 { "http", "[2001:db8::a]", true }, | 267 { "http", "[2001:db8::a]", true }, |
| 271 { "http", "", false }, | 268 { "http", "", false }, |
| 272 }; | 269 }; |
| 273 | 270 |
| 274 OriginAccessEntryTestPlatform platform; | 271 OriginAccessEntryTestPlatform platform; |
| 275 platform.setPublicSuffix("com"); | 272 platform.setPublicSuffix("com"); |
| 276 Platform::initialize(&platform); | |
| 277 | 273 |
| 278 for (const auto& test : inputs) { | 274 for (const auto& test : inputs) { |
| 279 SCOPED_TRACE(testing::Message() << "Host: " << test.host); | 275 SCOPED_TRACE(testing::Message() << "Host: " << test.host); |
| 280 OriginAccessEntry entry(test.protocol, test.host, OriginAccessEntry::Dis
allowSubdomains); | 276 OriginAccessEntry entry(test.protocol, test.host, OriginAccessEntry::Dis
allowSubdomains); |
| 281 EXPECT_EQ(test.isIPAddress, entry.hostIsIPAddress()) << test.host; | 277 EXPECT_EQ(test.isIPAddress, entry.hostIsIPAddress()) << test.host; |
| 282 } | 278 } |
| 283 | |
| 284 Platform::shutdown(); | |
| 285 } | 279 } |
| 286 | 280 |
| 287 TEST(OriginAccessEntryTest, IPAddressMatchingTest) | 281 TEST(OriginAccessEntryTest, IPAddressMatchingTest) |
| 288 { | 282 { |
| 289 struct TestCase { | 283 struct TestCase { |
| 290 const char* protocol; | 284 const char* protocol; |
| 291 const char* host; | 285 const char* host; |
| 292 const char* origin; | 286 const char* origin; |
| 293 OriginAccessEntry::MatchResult expected; | 287 OriginAccessEntry::MatchResult expected; |
| 294 } inputs[] = { | 288 } inputs[] = { |
| 295 { "http", "192.0.0.123", "http://192.0.0.123/", OriginAccessEntry::Match
esOrigin }, | 289 { "http", "192.0.0.123", "http://192.0.0.123/", OriginAccessEntry::Match
esOrigin }, |
| 296 { "http", "0.0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMa
tchOrigin }, | 290 { "http", "0.0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMa
tchOrigin }, |
| 297 { "http", "0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, | 291 { "http", "0.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, |
| 298 { "http", "1.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, | 292 { "http", "1.123", "http://192.0.0.123/", OriginAccessEntry::DoesNotMatc
hOrigin }, |
| 299 }; | 293 }; |
| 300 | 294 |
| 301 OriginAccessEntryTestPlatform platform; | 295 OriginAccessEntryTestPlatform platform; |
| 302 platform.setPublicSuffix("com"); | 296 platform.setPublicSuffix("com"); |
| 303 Platform::initialize(&platform); | |
| 304 | 297 |
| 305 for (const auto& test : inputs) { | 298 for (const auto& test : inputs) { |
| 306 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); | 299 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); |
| 307 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 300 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 308 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); | 301 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); |
| 309 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 302 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); |
| 310 | 303 |
| 311 OriginAccessEntry entry2(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); | 304 OriginAccessEntry entry2(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); |
| 312 EXPECT_EQ(test.expected, entry2.matchesOrigin(*originToTest)); | 305 EXPECT_EQ(test.expected, entry2.matchesOrigin(*originToTest)); |
| 313 } | 306 } |
| 314 | |
| 315 Platform::shutdown(); | |
| 316 } | 307 } |
| 317 | 308 |
| 318 } // namespace blink | 309 } // namespace blink |
| 319 | 310 |
| OLD | NEW |