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

Unified Diff: url/origin_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 | « url/origin.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/origin_unittest.cc
diff --git a/url/origin_unittest.cc b/url/origin_unittest.cc
index d925ce00a614e96af5826452295a7022d3936148..0f17c26ef50c40660995d818967f9db402322ef6 100644
--- a/url/origin_unittest.cc
+++ b/url/origin_unittest.cc
@@ -65,6 +65,52 @@ TEST(OriginTest, UniqueOriginComparison) {
}
}
+TEST(OriginTest, ConstructFromTuple) {
+ struct TestCases {
+ const char* const scheme;
+ const char* const host;
+ const uint16_t port;
+ const char* const suborigin;
+ } cases[] = {
+ {"http", "example.com", 80, ""},
+ {"http", "example.com", 123, ""},
+ {"https", "example.com", 443, ""},
+ {"http-so", "foobar.example.com", 80, "foobar"},
+ {"http-so", "foobar.example.com", 123, "foobar"},
+ {"https-so", "foobar.example.com", 443, "foobar"},
+ };
+
+ for (const auto& test_case : cases) {
+ testing::Message scope_message;
+ if (test_case.suborigin != std::string()) {
+ scope_message << test_case.scheme << "-so://" << test_case.suborigin
+ << "." << test_case.host << ":" << test_case.port;
+ } else {
+ scope_message << test_case.scheme << "://" << test_case.host << ":"
+ << test_case.port;
+ }
+ SCOPED_TRACE(scope_message);
+
+ url::Origin origin_without_suborigin =
+ url::Origin::CreateFromNormalizedTuple(test_case.scheme, test_case.host,
+ test_case.port);
+
+ url::Origin origin_with_suborigin =
+ url::Origin::CreateFromNormalizedTupleWithSuborigin(
+ test_case.scheme, test_case.host, test_case.port,
+ test_case.suborigin);
+
+ EXPECT_EQ(test_case.scheme, origin_without_suborigin.scheme());
+ EXPECT_EQ(test_case.host, origin_without_suborigin.host());
+ EXPECT_EQ(test_case.port, origin_without_suborigin.port());
+
+ EXPECT_EQ(test_case.scheme, origin_with_suborigin.scheme());
+ EXPECT_EQ(test_case.host, origin_with_suborigin.host());
+ EXPECT_EQ(test_case.port, origin_with_suborigin.port());
+ EXPECT_EQ(test_case.suborigin, origin_with_suborigin.suborigin());
+ }
+}
+
TEST(OriginTest, ConstructFromGURL) {
url::Origin different_origin(GURL("https://not-in-the-list.test/"));
« no previous file with comments | « url/origin.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698