Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/public/common/origin_util.h" | 5 #include "content/public/common/origin_util.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "url/gurl.h" | 7 #include "url/gurl.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 | 40 |
| 41 EXPECT_FALSE( | 41 EXPECT_FALSE( |
| 42 IsOriginSecure(GURL("filesystem:http://www.example.com/temporary/"))); | 42 IsOriginSecure(GURL("filesystem:http://www.example.com/temporary/"))); |
| 43 EXPECT_FALSE( | 43 EXPECT_FALSE( |
| 44 IsOriginSecure(GURL("filesystem:ftp://www.example.com/temporary/"))); | 44 IsOriginSecure(GURL("filesystem:ftp://www.example.com/temporary/"))); |
| 45 EXPECT_TRUE(IsOriginSecure(GURL("filesystem:ftp://127.0.0.1/temporary/"))); | 45 EXPECT_TRUE(IsOriginSecure(GURL("filesystem:ftp://127.0.0.1/temporary/"))); |
| 46 EXPECT_TRUE( | 46 EXPECT_TRUE( |
| 47 IsOriginSecure(GURL("filesystem:https://www.example.com/temporary/"))); | 47 IsOriginSecure(GURL("filesystem:https://www.example.com/temporary/"))); |
| 48 } | 48 } |
| 49 | 49 |
| 50 TEST(OriginUtilTest, Suborigins) { | |
| 51 GURL no_suborigin_simple_url("https://b"); | |
| 52 GURL suborigin_simple_url("https-so://a.b"); | |
| 53 GURL no_suborigin_bigger_url("https://example.com/some/path"); | |
| 54 GURL suborigin_bigger_url("https-so://foobar.example.com/some/path"); | |
|
nasko
2016/09/29 16:49:56
Why not throw in all the parts of an URL to ensure
jww
2016/09/29 22:21:00
Done.
| |
| 55 | |
| 56 EXPECT_FALSE(HasSuborigin(no_suborigin_simple_url)); | |
| 57 EXPECT_FALSE(HasSuborigin(no_suborigin_bigger_url)); | |
| 58 EXPECT_TRUE(HasSuborigin(suborigin_simple_url)); | |
| 59 EXPECT_TRUE(HasSuborigin(suborigin_bigger_url)); | |
| 60 | |
| 61 EXPECT_EQ("", SuboriginFromUrl(no_suborigin_simple_url)); | |
| 62 EXPECT_EQ("", SuboriginFromUrl(no_suborigin_bigger_url)); | |
| 63 EXPECT_EQ("a", SuboriginFromUrl(suborigin_simple_url)); | |
| 64 EXPECT_EQ("foobar", SuboriginFromUrl(suborigin_bigger_url)); | |
| 65 | |
| 66 EXPECT_EQ(no_suborigin_simple_url, | |
| 67 StripSuboriginFromUrl(no_suborigin_simple_url)); | |
| 68 EXPECT_EQ(no_suborigin_bigger_url, | |
| 69 StripSuboriginFromUrl(no_suborigin_bigger_url)); | |
| 70 EXPECT_EQ(no_suborigin_simple_url, | |
| 71 StripSuboriginFromUrl(suborigin_simple_url)); | |
| 72 EXPECT_EQ(no_suborigin_bigger_url, | |
| 73 StripSuboriginFromUrl(suborigin_bigger_url)); | |
| 74 | |
| 75 GURL just_dot_url("https-so://."); | |
| 76 GURL empty_hostname_url("https-so://"); | |
| 77 GURL empty_suborigin_url("https-so://.foo"); | |
| 78 GURL suborigin_but_empty_host_url("https-so://foo."); | |
|
nasko
2016/09/29 16:49:56
What about testing StripSuboriginFromUrl and Subor
jww
2016/09/29 22:21:00
Done.
| |
| 79 EXPECT_FALSE(HasSuborigin(just_dot_url)); | |
| 80 EXPECT_FALSE(HasSuborigin(empty_hostname_url)); | |
| 81 EXPECT_FALSE(HasSuborigin(empty_suborigin_url)); | |
| 82 EXPECT_FALSE(HasSuborigin(suborigin_but_empty_host_url)); | |
| 83 } | |
| 84 | |
| 50 } // namespace content | 85 } // namespace content |
| OLD | NEW |