| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/common/origin_util.h" | 5 #include "chrome/common/origin_util.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 8 #include "chrome/common/chrome_switches.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 9 | 11 |
| 10 TEST(URLSchemesTest, IsOriginSecure) { | 12 TEST(URLSchemesTest, IsOriginSecure) { |
| 11 EXPECT_TRUE(IsOriginSecure(GURL("file:///test/fun.html"))); | 13 EXPECT_TRUE(IsOriginSecure(GURL("file:///test/fun.html"))); |
| 12 EXPECT_TRUE(IsOriginSecure(GURL("file:///test/"))); | 14 EXPECT_TRUE(IsOriginSecure(GURL("file:///test/"))); |
| 13 | 15 |
| 14 EXPECT_TRUE(IsOriginSecure(GURL("https://example.com/fun.html"))); | 16 EXPECT_TRUE(IsOriginSecure(GURL("https://example.com/fun.html"))); |
| 15 EXPECT_FALSE(IsOriginSecure(GURL("http://example.com/fun.html"))); | 17 EXPECT_FALSE(IsOriginSecure(GURL("http://example.com/fun.html"))); |
| 16 | 18 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 35 IsOriginSecure(GURL("http://[::1].example.com/fun.html"))); | 37 IsOriginSecure(GURL("http://[::1].example.com/fun.html"))); |
| 36 | 38 |
| 37 EXPECT_FALSE(IsOriginSecure( | 39 EXPECT_FALSE(IsOriginSecure( |
| 38 GURL("filesystem:http://www.example.com/temporary/"))); | 40 GURL("filesystem:http://www.example.com/temporary/"))); |
| 39 EXPECT_FALSE(IsOriginSecure( | 41 EXPECT_FALSE(IsOriginSecure( |
| 40 GURL("filesystem:ftp://www.example.com/temporary/"))); | 42 GURL("filesystem:ftp://www.example.com/temporary/"))); |
| 41 EXPECT_TRUE(IsOriginSecure( | 43 EXPECT_TRUE(IsOriginSecure( |
| 42 GURL("filesystem:ftp://127.0.0.1/temporary/"))); | 44 GURL("filesystem:ftp://127.0.0.1/temporary/"))); |
| 43 EXPECT_TRUE(IsOriginSecure( | 45 EXPECT_TRUE(IsOriginSecure( |
| 44 GURL("filesystem:https://www.example.com/temporary/"))); | 46 GURL("filesystem:https://www.example.com/temporary/"))); |
| 47 |
| 48 // Add http://example.com and http://127.example.com to whitelist and |
| 49 // check if they are now considered secure origins. |
| 50 ClearWhiteListedSecureOrigins(); |
| 51 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 52 command_line->AppendSwitchASCII( |
| 53 switches::kUnsafetyTreatInsecureOriginAsSecure, |
| 54 "http://example.com,http://127.example.com"); |
| 55 command_line->AppendSwitch(switches::kUserDataDir); |
| 56 EXPECT_TRUE(IsOriginSecure(GURL("http://example.com/fun.html"))); |
| 57 EXPECT_TRUE(IsOriginSecure(GURL("http://127.example.com/fun.html"))); |
| 58 ClearWhiteListedSecureOrigins(); |
| 45 } | 59 } |
| OLD | NEW |