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

Side by Side Diff: url/gurl_unittest.cc

Issue 2403713002: Add suborigin logic to url::Origin (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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 #include "url/url_canon.h" 10 #include "url/url_canon.h"
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS()); 670 EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS());
671 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); 671 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS());
672 } 672 }
673 673
674 TEST(GURLTest, SchemeIsWSOrWSS) { 674 TEST(GURLTest, SchemeIsWSOrWSS) {
675 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); 675 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS());
676 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); 676 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS());
677 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); 677 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS());
678 } 678 }
679 679
680 TEST(GURLTest, SchemeIsCryptographic) {
681 EXPECT_TRUE(GURL("https://foo.bar.com/").SchemeIsCryptographic());
682 EXPECT_TRUE(GURL("HTTPS://foo.bar.com/").SchemeIsCryptographic());
683 EXPECT_TRUE(GURL("HtTpS://foo.bar.com/").SchemeIsCryptographic());
684
685 EXPECT_TRUE(GURL("wss://foo.bar.com/").SchemeIsCryptographic());
686 EXPECT_TRUE(GURL("WSS://foo.bar.com/").SchemeIsCryptographic());
687 EXPECT_TRUE(GURL("WsS://foo.bar.com/").SchemeIsCryptographic());
688
689 EXPECT_TRUE(GURL("https-so://foo.bar.com/").SchemeIsCryptographic());
690 EXPECT_TRUE(GURL("HTTPS-SO://foo.bar.com/").SchemeIsCryptographic());
691 EXPECT_TRUE(GURL("HtTpS-So://foo.bar.com/").SchemeIsCryptographic());
692
693 EXPECT_FALSE(GURL("http://foo.bar.com/").SchemeIsCryptographic());
694 EXPECT_FALSE(GURL("ws://foo.bar.com/").SchemeIsCryptographic());
695 EXPECT_FALSE(GURL("http-so://foo.bar.com/").SchemeIsCryptographic());
696 }
697
680 TEST(GURLTest, SchemeIsBlob) { 698 TEST(GURLTest, SchemeIsBlob) {
681 EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob()); 699 EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob());
682 EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob()); 700 EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob());
683 EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob()); 701 EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob());
684 } 702 }
685 703
704 TEST(GURLTest, SchemeIsSuborigin) {
705 EXPECT_TRUE(GURL("http-so://foo.bar.com/").SchemeIsSuborigin());
706 EXPECT_TRUE(GURL("HTTP-SO://foo.bar.com/").SchemeIsSuborigin());
707 EXPECT_TRUE(GURL("HtTp-So://foo.bar.com/").SchemeIsSuborigin());
708 EXPECT_FALSE(GURL("http://foo.bar.com/").SchemeIsSuborigin());
709
710 EXPECT_TRUE(GURL("https-so://foo.bar.com/").SchemeIsSuborigin());
711 EXPECT_TRUE(GURL("HTTPS-SO://foo.bar.com/").SchemeIsSuborigin());
712 EXPECT_TRUE(GURL("HpTpS-So://foo.bar.com/").SchemeIsSuborigin());
713 EXPECT_FALSE(GURL("https://foo.bar.com/").SchemeIsSuborigin());
714 }
715
686 TEST(GURLTest, ContentAndPathForNonStandardURLs) { 716 TEST(GURLTest, ContentAndPathForNonStandardURLs) {
687 struct TestCase { 717 struct TestCase {
688 const char* url; 718 const char* url;
689 const char* expected; 719 const char* expected;
690 } cases[] = { 720 } cases[] = {
691 {"null", ""}, 721 {"null", ""},
692 {"not-a-standard-scheme:this is arbitrary content", 722 {"not-a-standard-scheme:this is arbitrary content",
693 "this is arbitrary content"}, 723 "this is arbitrary content"},
694 {"view-source:http://example.com/path", "http://example.com/path"}, 724 {"view-source:http://example.com/path", "http://example.com/path"},
695 {"blob:http://example.com/GUID", "http://example.com/GUID"}, 725 {"blob:http://example.com/GUID", "http://example.com/GUID"},
696 {"blob://http://example.com/GUID", "//http://example.com/GUID"}, 726 {"blob://http://example.com/GUID", "//http://example.com/GUID"},
697 {"blob:http://user:password@example.com/GUID", 727 {"blob:http://user:password@example.com/GUID",
698 "http://user:password@example.com/GUID"}, 728 "http://user:password@example.com/GUID"},
699 729
700 // TODO(mkwst): This seems like a bug. https://crbug.com/513600 730 // TODO(mkwst): This seems like a bug. https://crbug.com/513600
701 {"filesystem:http://example.com/path", "/"}, 731 {"filesystem:http://example.com/path", "/"},
702 }; 732 };
703 733
704 for (const auto& test : cases) { 734 for (const auto& test : cases) {
705 GURL url(test.url); 735 GURL url(test.url);
706 EXPECT_EQ(test.expected, url.path()) << test.url; 736 EXPECT_EQ(test.expected, url.path()) << test.url;
707 EXPECT_EQ(test.expected, url.GetContent()) << test.url; 737 EXPECT_EQ(test.expected, url.GetContent()) << test.url;
708 } 738 }
709 } 739 }
710 740
711 } // namespace url 741 } // namespace url
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698