| 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 14 matching lines...) Expand all Loading... |
| 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 "config.h" | 31 #include "config.h" |
| 32 #include "platform/weborigin/SecurityOrigin.h" | 32 #include "platform/weborigin/SecurityOrigin.h" |
| 33 | 33 |
| 34 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
| 35 #include "platform/blob/BlobURL.h" | |
| 36 #include "platform/weborigin/KURL.h" | 35 #include "platform/weborigin/KURL.h" |
| 37 #include "platform/weborigin/SecurityPolicy.h" | 36 #include "platform/weborigin/SecurityPolicy.h" |
| 38 #include "wtf/text/StringBuilder.h" | 37 #include "wtf/text/StringBuilder.h" |
| 39 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
| 40 #include <gtest/gtest.h> | 39 #include <gtest/gtest.h> |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 const int MaxAllowedPort = 65535; | 43 const int MaxAllowedPort = 65535; |
| 45 | 44 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 {"file", "example.com", 0, "file://"}, | 378 {"file", "example.com", 0, "file://"}, |
| 380 }; | 379 }; |
| 381 | 380 |
| 382 for (const auto& test : cases) { | 381 for (const auto& test : cases) { |
| 383 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(test.scheme, test
.host, test.port); | 382 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(test.scheme, test
.host, test.port); |
| 384 EXPECT_EQ(test.origin, origin->toString()) << test.origin; | 383 EXPECT_EQ(test.origin, origin->toString()) << test.origin; |
| 385 } | 384 } |
| 386 | 385 |
| 387 } | 386 } |
| 388 | 387 |
| 389 TEST_F(SecurityOriginTest, UniquenessPropagatesToBlobUrls) | |
| 390 { | |
| 391 struct TestCase { | |
| 392 const char* url; | |
| 393 bool expectedUniqueness; | |
| 394 const char* expectedOriginString; | |
| 395 } cases[] { | |
| 396 { "", true, "null" }, | |
| 397 { "null", true, "null" }, | |
| 398 { "data:text/plain,hello_world", true, "null" }, | |
| 399 { "file:///path", false, "file://" }, | |
| 400 { "filesystem:http://host/filesystem-path", false, "http://host" }, | |
| 401 { "filesystem:file:///filesystem-path", false, "file://" }, | |
| 402 { "filesystem:null/filesystem-path", true, "null" }, | |
| 403 { "blob:http://host/blob-id", false, "http://host" }, | |
| 404 { "blob:file:///blob-id", false, "file://" }, | |
| 405 { "blob:null/blob-id", true, "null" }, | |
| 406 }; | |
| 407 | |
| 408 for (const TestCase& test : cases) { | |
| 409 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(test.ur
l); | |
| 410 EXPECT_EQ(test.expectedUniqueness, origin->isUnique()); | |
| 411 EXPECT_EQ(test.expectedOriginString, origin->toString()); | |
| 412 | |
| 413 KURL blobUrl = BlobURL::createPublicURL(origin.get()); | |
| 414 RefPtr<SecurityOrigin> blobUrlOrigin = SecurityOrigin::create(blobUrl); | |
| 415 EXPECT_EQ(blobUrlOrigin->isUnique(), origin->isUnique()); | |
| 416 EXPECT_EQ(blobUrlOrigin->toString(), origin->toString()); | |
| 417 EXPECT_EQ(blobUrlOrigin->toRawString(), origin->toRawString()); | |
| 418 } | |
| 419 } | |
| 420 | |
| 421 } // namespace blink | 388 } // namespace blink |
| OLD | NEW |