Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: content/child/blink_platform_impl_unittest.cc

Issue 2449233002: Add suborigins to WebSecurityOrigin (Closed)
Patch Set: Rebase on ToT Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/exported/WebSecurityOrigin.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/blink_platform_impl_unittest.cc
diff --git a/content/child/blink_platform_impl_unittest.cc b/content/child/blink_platform_impl_unittest.cc
index 34fb1000f28fad100a28b2769de83d8fb55d5658..423dc17abc956f7c7be2dfd61649efd21ac2f01f 100644
--- a/content/child/blink_platform_impl_unittest.cc
+++ b/content/child/blink_platform_impl_unittest.cc
@@ -34,89 +34,113 @@ TEST(BlinkPlatformTest, CastWebSecurityOrigin) {
const char* scheme;
const char* host;
uint16_t port;
+ const char* suborigin;
} cases[] = {
- {"http://example.com", "http", "example.com", 80},
- {"http://example.com:80", "http", "example.com", 80},
- {"http://example.com:81", "http", "example.com", 81},
- {"https://example.com", "https", "example.com", 443},
- {"https://example.com:443", "https", "example.com", 443},
- {"https://example.com:444", "https", "example.com", 444},
+ {"http://example.com", "http", "example.com", 80, ""},
+ {"http://example.com:80", "http", "example.com", 80, ""},
+ {"http://example.com:81", "http", "example.com", 81, ""},
+ {"https://example.com", "https", "example.com", 443, ""},
+ {"https://example.com:443", "https", "example.com", 443, ""},
+ {"https://example.com:444", "https", "example.com", 444, ""},
// Copied from url/origin_unittest.cc
// IP Addresses
- {"http://192.168.9.1/", "http", "192.168.9.1", 80},
- {"http://[2001:db8::1]/", "http", "[2001:db8::1]", 80},
+ {"http://192.168.9.1/", "http", "192.168.9.1", 80, ""},
+ {"http://[2001:db8::1]/", "http", "[2001:db8::1]", 80, ""},
// Punycode
- {"http://☃.net/", "http", "xn--n3h.net", 80},
- {"blob:http://☃.net/", "http", "xn--n3h.net", 80},
+ {"http://☃.net/", "http", "xn--n3h.net", 80, ""},
+ {"blob:http://☃.net/", "http", "xn--n3h.net", 80, ""},
// Generic URLs
- {"http://example.com/", "http", "example.com", 80},
- {"http://example.com:123/", "http", "example.com", 123},
- {"https://example.com/", "https", "example.com", 443},
- {"https://example.com:123/", "https", "example.com", 123},
- {"http://user:pass@example.com/", "http", "example.com", 80},
- {"http://example.com:123/?query", "http", "example.com", 123},
- {"https://example.com/#1234", "https", "example.com", 443},
- {"https://u:p@example.com:123/?query#1234", "https", "example.com", 123},
+ {"http://example.com/", "http", "example.com", 80, ""},
+ {"http://example.com:123/", "http", "example.com", 123, ""},
+ {"https://example.com/", "https", "example.com", 443, ""},
+ {"https://example.com:123/", "https", "example.com", 123, ""},
+ {"http://user:pass@example.com/", "http", "example.com", 80, ""},
+ {"http://example.com:123/?query", "http", "example.com", 123, ""},
+ {"https://example.com/#1234", "https", "example.com", 443, ""},
+ {"https://u:p@example.com:123/?query#1234", "https", "example.com", 123,
+ ""},
// Registered URLs
- {"ftp://example.com/", "ftp", "example.com", 21},
- {"ws://example.com/", "ws", "example.com", 80},
- {"wss://example.com/", "wss", "example.com", 443},
+ {"ftp://example.com/", "ftp", "example.com", 21, ""},
+ {"ws://example.com/", "ws", "example.com", 80, ""},
+ {"wss://example.com/", "wss", "example.com", 443, ""},
// file: URLs
- {"file:///etc/passwd", "file", "", 0},
- {"file://example.com/etc/passwd", "file", "example.com", 0},
+ {"file:///etc/passwd", "file", "", 0, ""},
+ {"file://example.com/etc/passwd", "file", "example.com", 0, ""},
// Filesystem:
- {"filesystem:http://example.com/type/", "http", "example.com", 80},
- {"filesystem:http://example.com:123/type/", "http", "example.com", 123},
- {"filesystem:https://example.com/type/", "https", "example.com", 443},
- {"filesystem:https://example.com:123/type/", "https", "example.com", 123},
+ {"filesystem:http://example.com/type/", "http", "example.com", 80, ""},
+ {"filesystem:http://example.com:123/type/", "http", "example.com", 123,
+ ""},
+ {"filesystem:https://example.com/type/", "https", "example.com", 443, ""},
+ {"filesystem:https://example.com:123/type/", "https", "example.com", 123,
+ ""},
// Blob:
- {"blob:http://example.com/guid-goes-here", "http", "example.com", 80},
- {"blob:http://example.com:123/guid-goes-here", "http", "example.com",
- 123},
- {"blob:https://example.com/guid-goes-here", "https", "example.com", 443},
- {"blob:http://u:p@example.com/guid-goes-here", "http", "example.com", 80},
+ {"blob:http://example.com/guid-goes-here", "http", "example.com", 80, ""},
+ {"blob:http://example.com:123/guid-goes-here", "http", "example.com", 123,
+ ""},
+ {"blob:https://example.com/guid-goes-here", "https", "example.com", 443,
+ ""},
+ {"blob:http://u:p@example.com/guid-goes-here", "http", "example.com", 80,
+ ""},
{"blob:https://example.co.uk/guid-goes-here", "https", "example.co.uk",
- 443},
+ 443, ""},
+
+ // Suborigins
+ {"http-so://foobar.example.com", "http", "example.com", 80, "foobar"},
+ {"http-so://foobar.example.com:80", "http", "example.com", 80, "foobar"},
+ {"http-so://foobar.example.com:81", "http", "example.com", 81, "foobar"},
+ {"https-so://foobar.example.com", "https", "example.com", 443, "foobar"},
+ {"https-so://foobar.example.com:443", "https", "example.com", 443,
+ "foobar"},
+ {"https-so://foobar.example.com:444", "https", "example.com", 444,
+ "foobar"},
};
for (const auto& test : cases) {
+ SCOPED_TRACE(testing::Message() << test.url);
blink::WebSecurityOrigin web_origin =
blink::WebSecurityOrigin::createFromString(
blink::WebString::fromUTF8(test.url));
EXPECT_EQ(test.scheme, web_origin.protocol().utf8());
EXPECT_EQ(test.host, web_origin.host().utf8());
EXPECT_EQ(test.port, web_origin.effectivePort());
+ EXPECT_EQ(test.suborigin, web_origin.suborigin().utf8());
url::Origin url_origin = web_origin;
EXPECT_EQ(test.scheme, url_origin.scheme());
EXPECT_EQ(test.host, url_origin.host());
EXPECT_EQ(test.port, url_origin.port());
+ EXPECT_EQ(test.suborigin, url_origin.suborigin());
web_origin = url::Origin(GURL(test.url));
EXPECT_EQ(test.scheme, web_origin.protocol().utf8());
EXPECT_EQ(test.host, web_origin.host().utf8());
EXPECT_EQ(test.port, web_origin.effectivePort());
+ EXPECT_EQ(test.suborigin, web_origin.suborigin().utf8());
CheckCastedOriginsAlreadyNormalized(web_origin);
}
- blink::WebSecurityOrigin web_origin =
- blink::WebSecurityOrigin::createUnique();
- EXPECT_TRUE(web_origin.isUnique());
+ {
+ SCOPED_TRACE(testing::Message() << "null");
+ blink::WebSecurityOrigin web_origin =
+ blink::WebSecurityOrigin::createUnique();
+ EXPECT_TRUE(web_origin.isUnique());
- url::Origin url_origin = web_origin;
- EXPECT_TRUE(url_origin.unique());
+ url::Origin url_origin = web_origin;
+ EXPECT_TRUE(url_origin.unique());
+ EXPECT_EQ("", url_origin.suborigin());
- web_origin = url::Origin(GURL(""));
- EXPECT_TRUE(web_origin.isUnique());
+ web_origin = url::Origin(GURL(""));
+ EXPECT_TRUE(web_origin.isUnique());
+ }
}
// This test ensures that WebSecurityOrigins can safely use
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/exported/WebSecurityOrigin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698