OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/browsing_data/browsing_data_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" | 8 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
11 #include "extensions/common/constants.h" | 11 #include "extensions/common/constants.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 #include "url/url_constants.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 const char kTestOrigin1[] = "http://host1:1/"; | 18 const char kTestOrigin1[] = "http://host1:1/"; |
18 const char kTestOrigin2[] = "http://host2:1/"; | 19 const char kTestOrigin2[] = "http://host2:1/"; |
19 const char kTestOrigin3[] = "http://host3:1/"; | 20 const char kTestOrigin3[] = "http://host3:1/"; |
20 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/"; | 21 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/"; |
21 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; | 22 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; |
22 | 23 |
23 const GURL kOrigin1(kTestOrigin1); | 24 const GURL kOrigin1(kTestOrigin1); |
(...skipping 27 matching lines...) Expand all Loading... |
51 int mask, | 52 int mask, |
52 ExtensionSpecialStoragePolicy* policy) { | 53 ExtensionSpecialStoragePolicy* policy) { |
53 return BrowsingDataHelper::DoesOriginMatchMask(origin, mask, policy); | 54 return BrowsingDataHelper::DoesOriginMatchMask(origin, mask, policy); |
54 } | 55 } |
55 | 56 |
56 private: | 57 private: |
57 DISALLOW_COPY_AND_ASSIGN(BrowsingDataHelperTest); | 58 DISALLOW_COPY_AND_ASSIGN(BrowsingDataHelperTest); |
58 }; | 59 }; |
59 | 60 |
60 TEST_F(BrowsingDataHelperTest, WebSafeSchemesAreWebSafe) { | 61 TEST_F(BrowsingDataHelperTest, WebSafeSchemesAreWebSafe) { |
61 EXPECT_TRUE(IsWebScheme(content::kHttpScheme)); | 62 EXPECT_TRUE(IsWebScheme(url::kHttpScheme)); |
62 EXPECT_TRUE(IsWebScheme(content::kHttpsScheme)); | 63 EXPECT_TRUE(IsWebScheme(url::kHttpsScheme)); |
63 EXPECT_TRUE(IsWebScheme(content::kFtpScheme)); | 64 EXPECT_TRUE(IsWebScheme(content::kFtpScheme)); |
64 EXPECT_TRUE(IsWebScheme(content::kDataScheme)); | 65 EXPECT_TRUE(IsWebScheme(content::kDataScheme)); |
65 EXPECT_TRUE(IsWebScheme("feed")); | 66 EXPECT_TRUE(IsWebScheme("feed")); |
66 EXPECT_TRUE(IsWebScheme(content::kBlobScheme)); | 67 EXPECT_TRUE(IsWebScheme(content::kBlobScheme)); |
67 EXPECT_TRUE(IsWebScheme(content::kFileSystemScheme)); | 68 EXPECT_TRUE(IsWebScheme(content::kFileSystemScheme)); |
68 EXPECT_FALSE(IsWebScheme("invalid-scheme-i-just-made-up")); | 69 EXPECT_FALSE(IsWebScheme("invalid-scheme-i-just-made-up")); |
69 } | 70 } |
70 | 71 |
71 TEST_F(BrowsingDataHelperTest, ChromeSchemesAreNotWebSafe) { | 72 TEST_F(BrowsingDataHelperTest, ChromeSchemesAreNotWebSafe) { |
72 EXPECT_FALSE(IsWebScheme(extensions::kExtensionScheme)); | 73 EXPECT_FALSE(IsWebScheme(extensions::kExtensionScheme)); |
73 EXPECT_FALSE(IsWebScheme(content::kAboutScheme)); | 74 EXPECT_FALSE(IsWebScheme(content::kAboutScheme)); |
74 EXPECT_FALSE(IsWebScheme(content::kChromeDevToolsScheme)); | 75 EXPECT_FALSE(IsWebScheme(content::kChromeDevToolsScheme)); |
75 EXPECT_FALSE(IsWebScheme(content::kChromeUIScheme)); | 76 EXPECT_FALSE(IsWebScheme(content::kChromeUIScheme)); |
76 EXPECT_FALSE(IsWebScheme(content::kJavaScriptScheme)); | 77 EXPECT_FALSE(IsWebScheme(content::kJavaScriptScheme)); |
77 EXPECT_FALSE(IsWebScheme(content::kMailToScheme)); | 78 EXPECT_FALSE(IsWebScheme(content::kMailToScheme)); |
78 EXPECT_FALSE(IsWebScheme(content::kMetadataScheme)); | 79 EXPECT_FALSE(IsWebScheme(content::kMetadataScheme)); |
79 EXPECT_FALSE(IsWebScheme(content::kSwappedOutScheme)); | 80 EXPECT_FALSE(IsWebScheme(content::kSwappedOutScheme)); |
80 EXPECT_FALSE(IsWebScheme(content::kViewSourceScheme)); | 81 EXPECT_FALSE(IsWebScheme(content::kViewSourceScheme)); |
81 } | 82 } |
82 | 83 |
83 TEST_F(BrowsingDataHelperTest, WebSafeSchemesAreNotExtensions) { | 84 TEST_F(BrowsingDataHelperTest, WebSafeSchemesAreNotExtensions) { |
84 EXPECT_FALSE(IsExtensionScheme(content::kHttpScheme)); | 85 EXPECT_FALSE(IsExtensionScheme(url::kHttpScheme)); |
85 EXPECT_FALSE(IsExtensionScheme(content::kHttpsScheme)); | 86 EXPECT_FALSE(IsExtensionScheme(url::kHttpsScheme)); |
86 EXPECT_FALSE(IsExtensionScheme(content::kFtpScheme)); | 87 EXPECT_FALSE(IsExtensionScheme(content::kFtpScheme)); |
87 EXPECT_FALSE(IsExtensionScheme(content::kDataScheme)); | 88 EXPECT_FALSE(IsExtensionScheme(content::kDataScheme)); |
88 EXPECT_FALSE(IsExtensionScheme("feed")); | 89 EXPECT_FALSE(IsExtensionScheme("feed")); |
89 EXPECT_FALSE(IsExtensionScheme(content::kBlobScheme)); | 90 EXPECT_FALSE(IsExtensionScheme(content::kBlobScheme)); |
90 EXPECT_FALSE(IsExtensionScheme(content::kFileSystemScheme)); | 91 EXPECT_FALSE(IsExtensionScheme(content::kFileSystemScheme)); |
91 EXPECT_FALSE(IsExtensionScheme("invalid-scheme-i-just-made-up")); | 92 EXPECT_FALSE(IsExtensionScheme("invalid-scheme-i-just-made-up")); |
92 } | 93 } |
93 | 94 |
94 TEST_F(BrowsingDataHelperTest, ChromeSchemesAreNotAllExtension) { | 95 TEST_F(BrowsingDataHelperTest, ChromeSchemesAreNotAllExtension) { |
95 EXPECT_TRUE(IsExtensionScheme(extensions::kExtensionScheme)); | 96 EXPECT_TRUE(IsExtensionScheme(extensions::kExtensionScheme)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 EXPECT_TRUE(Match( | 149 EXPECT_TRUE(Match( |
149 kOrigin2, kUnprotected | kProtected | kExtension, mock_policy.get())); | 150 kOrigin2, kUnprotected | kProtected | kExtension, mock_policy.get())); |
150 EXPECT_TRUE(Match( | 151 EXPECT_TRUE(Match( |
151 kOriginExt, kUnprotected | kProtected | kExtension, mock_policy.get())); | 152 kOriginExt, kUnprotected | kProtected | kExtension, mock_policy.get())); |
152 EXPECT_FALSE(Match(kOriginDevTools, | 153 EXPECT_FALSE(Match(kOriginDevTools, |
153 kUnprotected | kProtected | kExtension, | 154 kUnprotected | kProtected | kExtension, |
154 mock_policy.get())); | 155 mock_policy.get())); |
155 } | 156 } |
156 | 157 |
157 } // namespace | 158 } // namespace |
OLD | NEW |