Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: chrome/common/extensions/extension_permission_set_unittest.cc

Issue 7253001: Added a private chromeAuthPrivate API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unittest failure Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_permission_set.h" 5 #include "chrome/common/extensions/extension_permission_set.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXPECT_EQ(ExtensionAPIPermission::kUnlimitedStorage, 155 EXPECT_EQ(ExtensionAPIPermission::kUnlimitedStorage,
156 info->GetByName("unlimited_storage")->id()); 156 info->GetByName("unlimited_storage")->id());
157 } 157 }
158 158
159 TEST(ExtensionAPIPermissionTest, HostedAppPermissions) { 159 TEST(ExtensionAPIPermissionTest, HostedAppPermissions) {
160 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); 160 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance();
161 ExtensionAPIPermissionSet hosted_perms; 161 ExtensionAPIPermissionSet hosted_perms;
162 hosted_perms.insert(ExtensionAPIPermission::kBackground); 162 hosted_perms.insert(ExtensionAPIPermission::kBackground);
163 hosted_perms.insert(ExtensionAPIPermission::kClipboardRead); 163 hosted_perms.insert(ExtensionAPIPermission::kClipboardRead);
164 hosted_perms.insert(ExtensionAPIPermission::kClipboardWrite); 164 hosted_perms.insert(ExtensionAPIPermission::kClipboardWrite);
165 hosted_perms.insert(ExtensionAPIPermission::kChromeAuthPrivate);
165 hosted_perms.insert(ExtensionAPIPermission::kChromePrivate); 166 hosted_perms.insert(ExtensionAPIPermission::kChromePrivate);
166 hosted_perms.insert(ExtensionAPIPermission::kExperimental); 167 hosted_perms.insert(ExtensionAPIPermission::kExperimental);
167 hosted_perms.insert(ExtensionAPIPermission::kGeolocation); 168 hosted_perms.insert(ExtensionAPIPermission::kGeolocation);
168 hosted_perms.insert(ExtensionAPIPermission::kNotification); 169 hosted_perms.insert(ExtensionAPIPermission::kNotification);
169 hosted_perms.insert(ExtensionAPIPermission::kUnlimitedStorage); 170 hosted_perms.insert(ExtensionAPIPermission::kUnlimitedStorage);
170 hosted_perms.insert(ExtensionAPIPermission::kWebstorePrivate); 171 hosted_perms.insert(ExtensionAPIPermission::kWebstorePrivate);
171 172
172 ExtensionAPIPermissionSet perms = info->GetAll(); 173 ExtensionAPIPermissionSet perms = info->GetAll();
173 size_t count = 0; 174 size_t count = 0;
174 for (ExtensionAPIPermissionSet::iterator i = perms.begin(); 175 for (ExtensionAPIPermissionSet::iterator i = perms.begin();
175 i != perms.end(); ++i) { 176 i != perms.end(); ++i) {
176 count += hosted_perms.count(*i); 177 count += hosted_perms.count(*i);
177 EXPECT_EQ(hosted_perms.count(*i) > 0, info->GetByID(*i)->is_hosted_app()); 178 EXPECT_EQ(hosted_perms.count(*i) > 0, info->GetByID(*i)->is_hosted_app());
178 } 179 }
179 180
180 EXPECT_EQ(9u, count); 181 EXPECT_EQ(10u, count);
181 EXPECT_EQ(9u, info->get_hosted_app_permission_count()); 182 EXPECT_EQ(10u, info->get_hosted_app_permission_count());
182 } 183 }
183 184
184 TEST(ExtensionAPIPermissionTest, ComponentOnlyPermissions) { 185 TEST(ExtensionAPIPermissionTest, ComponentOnlyPermissions) {
185 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); 186 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance();
186 ExtensionAPIPermissionSet private_perms; 187 ExtensionAPIPermissionSet private_perms;
188 private_perms.insert(ExtensionAPIPermission::kChromeAuthPrivate);
187 private_perms.insert(ExtensionAPIPermission::kChromeosInfoPrivate); 189 private_perms.insert(ExtensionAPIPermission::kChromeosInfoPrivate);
188 private_perms.insert(ExtensionAPIPermission::kFileBrowserPrivate); 190 private_perms.insert(ExtensionAPIPermission::kFileBrowserPrivate);
189 private_perms.insert(ExtensionAPIPermission::kMediaPlayerPrivate); 191 private_perms.insert(ExtensionAPIPermission::kMediaPlayerPrivate);
190 private_perms.insert(ExtensionAPIPermission::kWebstorePrivate); 192 private_perms.insert(ExtensionAPIPermission::kWebstorePrivate);
191 193
192 ExtensionAPIPermissionSet perms = info->GetAll(); 194 ExtensionAPIPermissionSet perms = info->GetAll();
193 int count = 0; 195 int count = 0;
194 for (ExtensionAPIPermissionSet::iterator i = perms.begin(); 196 for (ExtensionAPIPermissionSet::iterator i = perms.begin();
195 i != perms.end(); ++i) { 197 i != perms.end(); ++i) {
196 count += private_perms.count(*i); 198 count += private_perms.count(*i);
197 EXPECT_EQ(private_perms.count(*i) > 0, 199 EXPECT_EQ(private_perms.count(*i) > 0,
198 info->GetByID(*i)->is_component_only()); 200 info->GetByID(*i)->is_component_only());
199 } 201 }
200 202
201 EXPECT_EQ(4, count); 203 EXPECT_EQ(5, count);
202 } 204 }
203 205
204 TEST(ExtensionPermissionSetTest, EffectiveHostPermissions) { 206 TEST(ExtensionPermissionSetTest, EffectiveHostPermissions) {
205 scoped_refptr<Extension> extension; 207 scoped_refptr<Extension> extension;
206 const ExtensionPermissionSet* permissions = NULL; 208 const ExtensionPermissionSet* permissions = NULL;
207 209
208 extension = LoadManifest("effective_host_permissions", "empty.json"); 210 extension = LoadManifest("effective_host_permissions", "empty.json");
209 permissions = extension->permission_set(); 211 permissions = extension->permission_set();
210 EXPECT_EQ(0u, extension->GetEffectiveHostPermissions().patterns().size()); 212 EXPECT_EQ(0u, extension->GetEffectiveHostPermissions().patterns().size());
211 EXPECT_FALSE(permissions->HasEffectiveAccessToURL( 213 EXPECT_FALSE(permissions->HasEffectiveAccessToURL(
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 skip.insert(ExtensionAPIPermission::kFileBrowserHandler); 492 skip.insert(ExtensionAPIPermission::kFileBrowserHandler);
491 493
492 // If you've turned on the experimental command-line flag, we don't need 494 // If you've turned on the experimental command-line flag, we don't need
493 // to warn you further. 495 // to warn you further.
494 skip.insert(ExtensionAPIPermission::kExperimental); 496 skip.insert(ExtensionAPIPermission::kExperimental);
495 497
496 // These are private. 498 // These are private.
497 skip.insert(ExtensionAPIPermission::kWebstorePrivate); 499 skip.insert(ExtensionAPIPermission::kWebstorePrivate);
498 skip.insert(ExtensionAPIPermission::kFileBrowserPrivate); 500 skip.insert(ExtensionAPIPermission::kFileBrowserPrivate);
499 skip.insert(ExtensionAPIPermission::kMediaPlayerPrivate); 501 skip.insert(ExtensionAPIPermission::kMediaPlayerPrivate);
502 skip.insert(ExtensionAPIPermission::kChromeAuthPrivate);
500 skip.insert(ExtensionAPIPermission::kChromePrivate); 503 skip.insert(ExtensionAPIPermission::kChromePrivate);
501 skip.insert(ExtensionAPIPermission::kChromeosInfoPrivate); 504 skip.insert(ExtensionAPIPermission::kChromeosInfoPrivate);
502 skip.insert(ExtensionAPIPermission::kWebSocketProxyPrivate); 505 skip.insert(ExtensionAPIPermission::kWebSocketProxyPrivate);
503 506
504 // Warned as part of host permissions. 507 // Warned as part of host permissions.
505 skip.insert(ExtensionAPIPermission::kDevtools); 508 skip.insert(ExtensionAPIPermission::kDevtools);
506 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); 509 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance();
507 ExtensionAPIPermissionSet permissions = info->GetAll(); 510 ExtensionAPIPermissionSet permissions = info->GetAll();
508 for (ExtensionAPIPermissionSet::const_iterator i = permissions.begin(); 511 for (ExtensionAPIPermissionSet::const_iterator i = permissions.begin();
509 i != permissions.end(); ++i) { 512 i != permissions.end(); ++i) {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 AddPattern(&non_empty_extent, "http://www.google.com/*"); 935 AddPattern(&non_empty_extent, "http://www.google.com/*");
933 936
934 perm_set = ExtensionPermissionSet( 937 perm_set = ExtensionPermissionSet(
935 empty_apis, non_empty_extent, empty_extent); 938 empty_apis, non_empty_extent, empty_extent);
936 EXPECT_FALSE(perm_set.IsEmpty()); 939 EXPECT_FALSE(perm_set.IsEmpty());
937 940
938 perm_set = ExtensionPermissionSet( 941 perm_set = ExtensionPermissionSet(
939 empty_apis, empty_extent, non_empty_extent); 942 empty_apis, empty_extent, non_empty_extent);
940 EXPECT_FALSE(perm_set.IsEmpty()); 943 EXPECT_FALSE(perm_set.IsEmpty());
941 } 944 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_permission_set.cc ('k') | chrome/renderer/resources/renderer_extension_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698