diff options
author | ricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-22 07:40:46 +0000 |
---|---|---|
committer | ricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-22 07:40:46 +0000 |
commit | 9690b9973408b5f84206a9688f84dedc27747f6e (patch) | |
tree | 3888e75ebb3491e4deebc1c4bfc11bae757e22a9 /url | |
parent | 62e41ba50f8f19053e126fee543e70147615ba81 (diff) | |
download | chromium_src-9690b9973408b5f84206a9688f84dedc27747f6e.zip chromium_src-9690b9973408b5f84206a9688f84dedc27747f6e.tar.gz chromium_src-9690b9973408b5f84206a9688f84dedc27747f6e.tar.bz2 |
Fix some debugging checks that expect HTTP protocol schemes to also
accept WebSocket protocol schemes.
No functional change to release builds. Debug builds will stop
crashing when the new WebSocket implementation is used.
BUG=
TEST=net_unittests
Review URL: https://codereview.chromium.org/68213017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'url')
-rw-r--r-- | url/gurl.cc | 4 | ||||
-rw-r--r-- | url/gurl.h | 3 | ||||
-rw-r--r-- | url/gurl_unittest.cc | 12 |
3 files changed, 19 insertions, 0 deletions
diff --git a/url/gurl.cc b/url/gurl.cc index 15de85a..a550c46 100644 --- a/url/gurl.cc +++ b/url/gurl.cc @@ -364,6 +364,10 @@ bool GURL::SchemeIsHTTPOrHTTPS() const { return SchemeIs("http") || SchemeIs("https"); } +bool GURL::SchemeIsWSOrWSS() const { + return SchemeIs("ws") || SchemeIs("wss"); +} + int GURL::IntPort() const { if (parsed_.port.is_nonempty()) return url_parse::ParsePort(spec_.data(), parsed_.port); @@ -210,6 +210,9 @@ class URL_EXPORT GURL { // Returns true if the scheme is "http" or "https". bool SchemeIsHTTPOrHTTPS() const; + // Returns true is the scheme is "ws" or "wss". + bool SchemeIsWSOrWSS() const; + // We often need to know if this is a file URL. File URLs are "standard", but // are often treated separately by some programs. bool SchemeIsFile() const { diff --git a/url/gurl_unittest.cc b/url/gurl_unittest.cc index 67da8e4..767333c 100644 --- a/url/gurl_unittest.cc +++ b/url/gurl_unittest.cc @@ -529,3 +529,15 @@ TEST(GURLTest, IsStandard) { GURL c("foo://bar/baz"); EXPECT_FALSE(c.IsStandard()); } + +TEST(GURLTest, SchemeIsHTTPOrHTTPS) { + EXPECT_TRUE(GURL("http://bar/").SchemeIsHTTPOrHTTPS()); + EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS()); + EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); +} + +TEST(GURLTest, SchemeIsWSOrWSS) { + EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); + EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); + EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); +} |