| Index: url/origin_unittest.cc
|
| diff --git a/url/origin_unittest.cc b/url/origin_unittest.cc
|
| index c094ee6cf50efe6470da1da9586a11a4644fc341..e58f02d700d115ca636768c70c588a8dd3ea8a27 100644
|
| --- a/url/origin_unittest.cc
|
| +++ b/url/origin_unittest.cc
|
| @@ -13,27 +13,132 @@ namespace {
|
| // violating DCHECKs.
|
| TEST(OriginTest, constructEmpty) {
|
| Origin origin;
|
| - EXPECT_EQ("null", origin.string());
|
| + EXPECT_EQ("null", origin.serialize());
|
| }
|
|
|
| TEST(OriginTest, constructNull) {
|
| Origin origin("null");
|
| - EXPECT_EQ("null", origin.string());
|
| + EXPECT_EQ("null", origin.serialize());
|
| }
|
|
|
| TEST(OriginTest, constructValidOrigin) {
|
| Origin origin("http://example.com:8080");
|
| - EXPECT_EQ("http://example.com:8080", origin.string());
|
| + EXPECT_EQ("http://example.com:8080", origin.serialize());
|
| }
|
|
|
| TEST(OriginTest, constructValidFileOrigin) {
|
| Origin origin("file://");
|
| - EXPECT_EQ("file://", origin.string());
|
| + EXPECT_EQ("file://", origin.serialize());
|
| }
|
|
|
| TEST(OriginTest, constructValidOriginWithoutPort) {
|
| Origin origin("wss://example2.com");
|
| - EXPECT_EQ("wss://example2.com", origin.string());
|
| + EXPECT_EQ("wss://example2.com", origin.serialize());
|
| +}
|
| +
|
| +TEST(OriginTest, Constructors) {
|
| + struct TestCases {
|
| + const char* url;
|
| + const char* scheme;
|
| + const char* host;
|
| + unsigned short port;
|
| + bool unique;
|
| + const char* serialized;
|
| + } cases[] = {
|
| + // Invalid/unique URLs
|
| + {"", "", "", 0, true, "null"},
|
| + {"null", "", "", 0, true, "null"},
|
| + {"!", "", "", 0, true, "null"},
|
| + {"javascript:window.alert(\"hello,world\");", "", "", 0, true, "null"},
|
| +
|
| + // File URLs
|
| + {"file:///path/to/file", "file", "", 0, false, "file://"},
|
| + {"file:///path/to/another/file", "file", "", 0, false, "file://"},
|
| +
|
| + // Webby URLs
|
| + {"http://example.com/",
|
| + "http",
|
| + "example.com",
|
| + 80,
|
| + false,
|
| + "http://example.com"},
|
| + {"http://example.com:80/",
|
| + "http",
|
| + "example.com",
|
| + 80,
|
| + false,
|
| + "http://example.com"},
|
| + {"http://example.com:81/",
|
| + "http",
|
| + "example.com",
|
| + 81,
|
| + false,
|
| + "http://example.com:81"},
|
| + {"http://user:pass@example.com:81/blah#baz",
|
| + "http",
|
| + "example.com",
|
| + 81,
|
| + false,
|
| + "http://example.com:81"},
|
| + {"https://example.com/",
|
| + "https",
|
| + "example.com",
|
| + 443,
|
| + false,
|
| + "https://example.com"},
|
| + {"https://example.com:443/",
|
| + "https",
|
| + "example.com",
|
| + 443,
|
| + false,
|
| + "https://example.com"},
|
| + {"https://example.com:444/",
|
| + "https",
|
| + "example.com",
|
| + 444,
|
| + false,
|
| + "https://example.com:444"},
|
| + {"https://user:pass@example.com:444/blah#baz",
|
| + "https",
|
| + "example.com",
|
| + 444,
|
| + false,
|
| + "https://example.com:444"},
|
| +
|
| + // Inner URLs
|
| + {"filesystem:http://example.com/temporary/",
|
| + "http",
|
| + "example.com",
|
| + 80,
|
| + false,
|
| + "http://example.com"},
|
| + {"filesystem:http://user:pass@example.com:21/blah#baz",
|
| + "http",
|
| + "example.com",
|
| + 21,
|
| + false,
|
| + "http://example.com:21"}};
|
| +
|
| + for (const auto& test : cases) {
|
| + SCOPED_TRACE(test.url);
|
| + GURL url(test.url);
|
| + Origin origin_from_gurl(url);
|
| + Origin origin_from_string(url);
|
| +
|
| + EXPECT_EQ(!test.unique, origin_from_gurl == origin_from_string);
|
| + EXPECT_EQ(!test.unique, origin_from_string == origin_from_gurl);
|
| +
|
| + EXPECT_EQ(test.scheme, origin_from_gurl.scheme());
|
| + EXPECT_EQ(test.host, origin_from_gurl.host());
|
| + EXPECT_EQ(test.port, origin_from_gurl.port());
|
| + EXPECT_EQ(test.unique, origin_from_gurl.unique());
|
| + EXPECT_EQ(test.serialized, origin_from_gurl.serialize());
|
| +
|
| + EXPECT_EQ(test.scheme, origin_from_string.scheme());
|
| + EXPECT_EQ(test.host, origin_from_string.host());
|
| + EXPECT_EQ(test.port, origin_from_string.port());
|
| + EXPECT_EQ(test.serialized, origin_from_string.serialize());
|
| + }
|
| }
|
|
|
| } // namespace
|
|
|