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/common/extensions/api/extension_api.h" | 5 #include "chrome/common/extensions/api/extension_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 namespace { | 17 namespace { |
18 | 18 |
19 TEST(ExtensionAPI, IsPrivileged) { | 19 TEST(ExtensionAPI, IsPrivileged) { |
20 ExtensionAPI extension_api; | 20 ExtensionAPI extension_api; |
21 | 21 |
22 EXPECT_FALSE(extension_api.IsPrivileged("extension.connect")); | 22 EXPECT_FALSE(extension_api.IsPrivileged("extension.connect")); |
23 EXPECT_FALSE(extension_api.IsPrivileged("extension.onConnect")); | 23 EXPECT_FALSE(extension_api.IsPrivileged("extension.onConnect")); |
24 | 24 |
25 // Properties are not supported yet. | 25 // Properties are not supported yet. |
26 EXPECT_TRUE(extension_api.IsPrivileged("extension.lastError")); | 26 EXPECT_TRUE(extension_api.IsPrivileged("extension.lastError")); |
27 | 27 |
28 // Default unknown names to privileged for paranoia's sake. | 28 // Default unknown names to privileged for paranoia's sake. |
| 29 EXPECT_TRUE(extension_api.IsPrivileged("")); |
29 EXPECT_TRUE(extension_api.IsPrivileged("<unknown-namespace>")); | 30 EXPECT_TRUE(extension_api.IsPrivileged("<unknown-namespace>")); |
30 EXPECT_TRUE(extension_api.IsPrivileged("extension.<unknown-member>")); | 31 EXPECT_TRUE(extension_api.IsPrivileged("extension.<unknown-member>")); |
31 | 32 |
32 // Exists, but privileged. | 33 // Exists, but privileged. |
33 EXPECT_TRUE(extension_api.IsPrivileged("extension.getViews")); | 34 EXPECT_TRUE(extension_api.IsPrivileged("extension.getViews")); |
34 EXPECT_TRUE(extension_api.IsPrivileged("history.search")); | 35 EXPECT_TRUE(extension_api.IsPrivileged("history.search")); |
35 | 36 |
36 // Whole APIs that are unprivileged. | 37 // Whole APIs that are unprivileged. |
37 EXPECT_FALSE(extension_api.IsPrivileged("app.getDetails")); | 38 EXPECT_FALSE(extension_api.IsPrivileged("app.getDetails")); |
38 EXPECT_FALSE(extension_api.IsPrivileged("app.isInstalled")); | 39 EXPECT_FALSE(extension_api.IsPrivileged("app.isInstalled")); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 EXPECT_FALSE(MatchesURL(&api, "storage", "http://example.com/example.html")); | 187 EXPECT_FALSE(MatchesURL(&api, "storage", "http://example.com/example.html")); |
187 EXPECT_FALSE(MatchesURL(&api, "storage", "https://blah.net")); | 188 EXPECT_FALSE(MatchesURL(&api, "storage", "https://blah.net")); |
188 EXPECT_FALSE(MatchesURL(&api, "storage", "file://somefile.html")); | 189 EXPECT_FALSE(MatchesURL(&api, "storage", "file://somefile.html")); |
189 EXPECT_FALSE(MatchesURL(&api, "storage", "about:flags")); | 190 EXPECT_FALSE(MatchesURL(&api, "storage", "about:flags")); |
190 EXPECT_FALSE(MatchesURL(&api, "storage", "chrome://flags")); | 191 EXPECT_FALSE(MatchesURL(&api, "storage", "chrome://flags")); |
191 EXPECT_FALSE(MatchesURL(&api, "storage", "chrome-extension://fakeextension")); | 192 EXPECT_FALSE(MatchesURL(&api, "storage", "chrome-extension://fakeextension")); |
192 } | 193 } |
193 | 194 |
194 } // namespace | 195 } // namespace |
195 } // namespace extensions | 196 } // namespace extensions |
OLD | NEW |