Allow url::SchemeHostPort to hold non-file scheme without port
WebSockets use url::Origin to pass origin info between renderer and
browser. Currently, it cannot hold an origin with non-file scheme and
no port. Chrome extensions have been using such origins, so we need
to keep the channel to convey origin info work for such origins.
BUG=516971
R=sleevi,brettw
Committed: https://crrev.com/1ac9ec7bccd1b5178b18338b10149f36292f5fb6
Cr-Commit-Position: refs/heads/master@{#343895}
Review URL: https://codereview.chromium.org/1272113002
Cr-Commit-Position: refs/heads/master@{#344181}
diff --git a/url/url_util_unittest.cc b/url/url_util_unittest.cc
index 92977658..b89bfa16 100644
--- a/url/url_util_unittest.cc
+++ b/url/url_util_unittest.cc
@@ -61,6 +61,38 @@
EXPECT_TRUE(found_scheme == Component(1, 11));
}
+TEST(URLUtilTest, IsStandard) {
+ const char kHTTPScheme[] = "http";
+ EXPECT_TRUE(IsStandard(kHTTPScheme, Component(0, strlen(kHTTPScheme))));
+
+ const char kFooScheme[] = "foo";
+ EXPECT_FALSE(IsStandard(kFooScheme, Component(0, strlen(kFooScheme))));
+}
+
+TEST(URLUtilTest, GetStandardSchemeType) {
+ url::SchemeType scheme_type;
+
+ const char kHTTPScheme[] = "http";
+ scheme_type = url::SCHEME_WITHOUT_AUTHORITY;
+ EXPECT_TRUE(GetStandardSchemeType(kHTTPScheme,
+ Component(0, strlen(kHTTPScheme)),
+ &scheme_type));
+ EXPECT_EQ(url::SCHEME_WITH_PORT, scheme_type);
+
+ const char kFilesystemScheme[] = "filesystem";
+ scheme_type = url::SCHEME_WITH_PORT;
+ EXPECT_TRUE(GetStandardSchemeType(kFilesystemScheme,
+ Component(0, strlen(kFilesystemScheme)),
+ &scheme_type));
+ EXPECT_EQ(url::SCHEME_WITHOUT_AUTHORITY, scheme_type);
+
+ const char kFooScheme[] = "foo";
+ scheme_type = url::SCHEME_WITH_PORT;
+ EXPECT_FALSE(GetStandardSchemeType(kFooScheme,
+ Component(0, strlen(kFooScheme)),
+ &scheme_type));
+}
+
TEST(URLUtilTest, ReplaceComponents) {
Parsed parsed;
RawCanonOutputT<char> output;
@@ -220,7 +252,7 @@
}
TEST(URLUtilTest, TestResolveRelativeWithNonStandardBase) {
- // This tests non-standard (in the sense that GIsStandard() == false)
+ // This tests non-standard (in the sense that IsStandard() == false)
// hierarchical schemes.
struct ResolveRelativeCase {
const char* base;