| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 OriginAccessEntry::kMatchesOrigin}, | 136 OriginAccessEntry::kMatchesOrigin}, |
| 137 {"https", "", "http://beispiel.de/", | 137 {"https", "", "http://beispiel.de/", |
| 138 OriginAccessEntry::kDoesNotMatchOrigin, | 138 OriginAccessEntry::kDoesNotMatchOrigin, |
| 139 OriginAccessEntry::kMatchesOrigin}, | 139 OriginAccessEntry::kMatchesOrigin}, |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 ScopedTestingPlatformSupport<OriginAccessEntryTestPlatform> platform; | 142 ScopedTestingPlatformSupport<OriginAccessEntryTestPlatform> platform; |
| 143 platform->SetPublicSuffix("com"); | 143 platform->SetPublicSuffix("com"); |
| 144 | 144 |
| 145 for (const auto& test : inputs) { | 145 for (const auto& test : inputs) { |
| 146 SCOPED_TRACE(testing::Message() << "Host: " << test.host | 146 SCOPED_TRACE(testing::Message() |
| 147 << ", Origin: " << test.origin); | 147 << "Host: " << test.host << ", Origin: " << test.origin); |
| 148 RefPtr<SecurityOrigin> origin_to_test = | 148 RefPtr<SecurityOrigin> origin_to_test = |
| 149 SecurityOrigin::CreateFromString(test.origin); | 149 SecurityOrigin::CreateFromString(test.origin); |
| 150 OriginAccessEntry entry1(test.protocol, test.host, | 150 OriginAccessEntry entry1(test.protocol, test.host, |
| 151 OriginAccessEntry::kAllowSubdomains); | 151 OriginAccessEntry::kAllowSubdomains); |
| 152 EXPECT_EQ(test.expected_origin, entry1.MatchesOrigin(*origin_to_test)); | 152 EXPECT_EQ(test.expected_origin, entry1.MatchesOrigin(*origin_to_test)); |
| 153 EXPECT_EQ(test.expected_domain, entry1.MatchesDomain(*origin_to_test)); | 153 EXPECT_EQ(test.expected_domain, entry1.MatchesDomain(*origin_to_test)); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) { | 157 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 {"http", "", "http://beispiel.de/", | 297 {"http", "", "http://beispiel.de/", |
| 298 OriginAccessEntry::kDoesNotMatchOrigin}, | 298 OriginAccessEntry::kDoesNotMatchOrigin}, |
| 299 {"https", "", "http://beispiel.de/", | 299 {"https", "", "http://beispiel.de/", |
| 300 OriginAccessEntry::kDoesNotMatchOrigin}, | 300 OriginAccessEntry::kDoesNotMatchOrigin}, |
| 301 }; | 301 }; |
| 302 | 302 |
| 303 ScopedTestingPlatformSupport<OriginAccessEntryTestPlatform> platform; | 303 ScopedTestingPlatformSupport<OriginAccessEntryTestPlatform> platform; |
| 304 platform->SetPublicSuffix("com"); | 304 platform->SetPublicSuffix("com"); |
| 305 | 305 |
| 306 for (const auto& test : inputs) { | 306 for (const auto& test : inputs) { |
| 307 SCOPED_TRACE(testing::Message() << "Host: " << test.host | 307 SCOPED_TRACE(testing::Message() |
| 308 << ", Origin: " << test.origin); | 308 << "Host: " << test.host << ", Origin: " << test.origin); |
| 309 RefPtr<SecurityOrigin> origin_to_test = | 309 RefPtr<SecurityOrigin> origin_to_test = |
| 310 SecurityOrigin::CreateFromString(test.origin); | 310 SecurityOrigin::CreateFromString(test.origin); |
| 311 OriginAccessEntry entry1(test.protocol, test.host, | 311 OriginAccessEntry entry1(test.protocol, test.host, |
| 312 OriginAccessEntry::kDisallowSubdomains); | 312 OriginAccessEntry::kDisallowSubdomains); |
| 313 EXPECT_EQ(test.expected, entry1.MatchesOrigin(*origin_to_test)); | 313 EXPECT_EQ(test.expected, entry1.MatchesOrigin(*origin_to_test)); |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 TEST(OriginAccessEntryTest, IPAddressTest) { | 317 TEST(OriginAccessEntryTest, IPAddressTest) { |
| 318 struct TestCase { | 318 struct TestCase { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 {"http", "0.123", "http://192.0.0.123/", | 356 {"http", "0.123", "http://192.0.0.123/", |
| 357 OriginAccessEntry::kDoesNotMatchOrigin}, | 357 OriginAccessEntry::kDoesNotMatchOrigin}, |
| 358 {"http", "1.123", "http://192.0.0.123/", | 358 {"http", "1.123", "http://192.0.0.123/", |
| 359 OriginAccessEntry::kDoesNotMatchOrigin}, | 359 OriginAccessEntry::kDoesNotMatchOrigin}, |
| 360 }; | 360 }; |
| 361 | 361 |
| 362 ScopedTestingPlatformSupport<OriginAccessEntryTestPlatform> platform; | 362 ScopedTestingPlatformSupport<OriginAccessEntryTestPlatform> platform; |
| 363 platform->SetPublicSuffix("com"); | 363 platform->SetPublicSuffix("com"); |
| 364 | 364 |
| 365 for (const auto& test : inputs) { | 365 for (const auto& test : inputs) { |
| 366 SCOPED_TRACE(testing::Message() << "Host: " << test.host | 366 SCOPED_TRACE(testing::Message() |
| 367 << ", Origin: " << test.origin); | 367 << "Host: " << test.host << ", Origin: " << test.origin); |
| 368 RefPtr<SecurityOrigin> origin_to_test = | 368 RefPtr<SecurityOrigin> origin_to_test = |
| 369 SecurityOrigin::CreateFromString(test.origin); | 369 SecurityOrigin::CreateFromString(test.origin); |
| 370 OriginAccessEntry entry1(test.protocol, test.host, | 370 OriginAccessEntry entry1(test.protocol, test.host, |
| 371 OriginAccessEntry::kAllowSubdomains); | 371 OriginAccessEntry::kAllowSubdomains); |
| 372 EXPECT_EQ(test.expected, entry1.MatchesOrigin(*origin_to_test)); | 372 EXPECT_EQ(test.expected, entry1.MatchesOrigin(*origin_to_test)); |
| 373 | 373 |
| 374 OriginAccessEntry entry2(test.protocol, test.host, | 374 OriginAccessEntry entry2(test.protocol, test.host, |
| 375 OriginAccessEntry::kDisallowSubdomains); | 375 OriginAccessEntry::kDisallowSubdomains); |
| 376 EXPECT_EQ(test.expected, entry2.MatchesOrigin(*origin_to_test)); | 376 EXPECT_EQ(test.expected, entry2.MatchesOrigin(*origin_to_test)); |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 | 379 |
| 380 } // namespace blink | 380 } // namespace blink |
| OLD | NEW |