kinuko | 8cbea05 | 2015-04-25 13:35:43 | [diff] [blame^] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
palmer | 6c3473c | 2015-04-16 19:23:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
kinuko | 8cbea05 | 2015-04-25 13:35:43 | [diff] [blame^] | 5 | #include "base/basictypes.h" |
| 6 | #include "content/public/common/origin_util.h" |
palmer | 6c3473c | 2015-04-16 19:23:31 | [diff] [blame] | 7 | #include "testing/gtest/include/gtest/gtest.h" |
| 8 | #include "url/gurl.h" |
| 9 | |
kinuko | 8cbea05 | 2015-04-25 13:35:43 | [diff] [blame^] | 10 | namespace content { |
| 11 | |
palmer | 6c3473c | 2015-04-16 19:23:31 | [diff] [blame] | 12 | TEST(URLSchemesTest, IsOriginSecure) { |
| 13 | EXPECT_TRUE(IsOriginSecure(GURL("file:///test/fun.html"))); |
| 14 | EXPECT_TRUE(IsOriginSecure(GURL("file:///test/"))); |
| 15 | |
| 16 | EXPECT_TRUE(IsOriginSecure(GURL("https://example.com/fun.html"))); |
| 17 | EXPECT_FALSE(IsOriginSecure(GURL("http://example.com/fun.html"))); |
| 18 | |
| 19 | EXPECT_TRUE(IsOriginSecure(GURL("wss://example.com/fun.html"))); |
| 20 | EXPECT_FALSE(IsOriginSecure(GURL("ws://example.com/fun.html"))); |
| 21 | |
| 22 | EXPECT_TRUE(IsOriginSecure(GURL("http://localhost/fun.html"))); |
| 23 | EXPECT_FALSE(IsOriginSecure(GURL("http://localhost.com/fun.html"))); |
| 24 | EXPECT_TRUE(IsOriginSecure(GURL("https://localhost.com/fun.html"))); |
| 25 | |
| 26 | EXPECT_TRUE(IsOriginSecure(GURL("http://127.0.0.1/fun.html"))); |
| 27 | EXPECT_TRUE(IsOriginSecure(GURL("ftp://127.0.0.1/fun.html"))); |
| 28 | EXPECT_TRUE(IsOriginSecure(GURL("http://127.3.0.1/fun.html"))); |
kinuko | 8cbea05 | 2015-04-25 13:35:43 | [diff] [blame^] | 29 | EXPECT_FALSE(IsOriginSecure(GURL("http://127.example.com/fun.html"))); |
| 30 | EXPECT_TRUE(IsOriginSecure(GURL("https://127.example.com/fun.html"))); |
palmer | 6c3473c | 2015-04-16 19:23:31 | [diff] [blame] | 31 | |
| 32 | EXPECT_TRUE(IsOriginSecure(GURL("http://[::1]/fun.html"))); |
| 33 | EXPECT_FALSE(IsOriginSecure(GURL("http://[::2]/fun.html"))); |
kinuko | 8cbea05 | 2015-04-25 13:35:43 | [diff] [blame^] | 34 | EXPECT_FALSE(IsOriginSecure(GURL("http://[::1].example.com/fun.html"))); |
palmer | 6c3473c | 2015-04-16 19:23:31 | [diff] [blame] | 35 | |
kinuko | 8cbea05 | 2015-04-25 13:35:43 | [diff] [blame^] | 36 | EXPECT_FALSE( |
| 37 | IsOriginSecure(GURL("filesystem:http://www.example.com/temporary/"))); |
| 38 | EXPECT_FALSE( |
| 39 | IsOriginSecure(GURL("filesystem:ftp://www.example.com/temporary/"))); |
| 40 | EXPECT_TRUE(IsOriginSecure(GURL("filesystem:ftp://127.0.0.1/temporary/"))); |
| 41 | EXPECT_TRUE( |
| 42 | IsOriginSecure(GURL("filesystem:https://www.example.com/temporary/"))); |
palmer | 6c3473c | 2015-04-16 19:23:31 | [diff] [blame] | 43 | } |
kinuko | 8cbea05 | 2015-04-25 13:35:43 | [diff] [blame^] | 44 | |
| 45 | } // namespace content |