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

Side by Side Diff: chrome/browser/extensions/extensions_service_unittest.cc

Issue 4687005: Track permissions granted to extensions in prefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed updating a method call Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extensions/extensions_service_unittest.h" 5 #include "chrome/browser/extensions/extensions_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Extension ids used during testing. 65 // Extension ids used during testing.
66 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; 66 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
67 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"; 67 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
68 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj"; 68 const char* const good0 = "behllobkkfkfnphdnhnkndlbkcpglgmj";
69 const char* const good1 = "hpiknbiabeeppbpihjehijgoemciehgk"; 69 const char* const good1 = "hpiknbiabeeppbpihjehijgoemciehgk";
70 const char* const good2 = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; 70 const char* const good2 = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
71 const char* const good_crx = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; 71 const char* const good_crx = "ldnnhddmnhbkjipkidpdiheffobcpfmf";
72 const char* const page_action = "obcimlgaoabeegjmmpldobjndiealpln"; 72 const char* const page_action = "obcimlgaoabeegjmmpldobjndiealpln";
73 const char* const theme_crx = "iamefpfkojoapidjnbafmgkgncegbkad"; 73 const char* const theme_crx = "iamefpfkojoapidjnbafmgkgncegbkad";
74 const char* const theme2_crx = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; 74 const char* const theme2_crx = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf";
75 const char* const permissions_crx = "eagpmdpfmaekmmcejjbmjoecnejeiiin";
75 76
76 struct ExtensionsOrder { 77 struct ExtensionsOrder {
77 bool operator()(const Extension* a, const Extension* b) { 78 bool operator()(const Extension* a, const Extension* b) {
78 return a->name() < b->name(); 79 return a->name() < b->name();
79 } 80 }
80 }; 81 };
81 82
82 static std::vector<std::string> GetErrors() { 83 static std::vector<std::string> GetErrors() {
83 const std::vector<std::string>* errors = 84 const std::vector<std::string>* errors =
84 ExtensionErrorReporter::GetInstance()->GetErrors(); 85 ExtensionErrorReporter::GetInstance()->GetErrors();
85 std::vector<std::string> ret_val; 86 std::vector<std::string> ret_val;
86 87
87 for (std::vector<std::string>::const_iterator iter = errors->begin(); 88 for (std::vector<std::string>::const_iterator iter = errors->begin();
88 iter != errors->end(); ++iter) { 89 iter != errors->end(); ++iter) {
89 if (iter->find(".svn") == std::string::npos) { 90 if (iter->find(".svn") == std::string::npos) {
90 ret_val.push_back(*iter); 91 ret_val.push_back(*iter);
91 } 92 }
92 } 93 }
93 94
94 // The tests rely on the errors being in a certain order, which can vary 95 // The tests rely on the errors being in a certain order, which can vary
95 // depending on how filesystem iteration works. 96 // depending on how filesystem iteration works.
96 std::stable_sort(ret_val.begin(), ret_val.end()); 97 std::stable_sort(ret_val.begin(), ret_val.end());
97 98
98 return ret_val; 99 return ret_val;
99 } 100 }
100 101
102 static void AddPattern(ExtensionExtent* extent, const std::string& pattern) {
103 int schemes = URLPattern::SCHEME_ALL;
104 extent->AddPattern(URLPattern(schemes, pattern));
105 }
106
107 static void AssertEqualExtents(ExtensionExtent* extent1,
108 ExtensionExtent* extent2) {
109 std::vector<URLPattern> patterns1 = extent1->patterns();
110 std::vector<URLPattern> patterns2 = extent2->patterns();
111 std::set<std::string> strings1;
112 EXPECT_EQ(patterns1.size(), patterns2.size());
113
114 for (size_t i = 0; i < patterns1.size(); ++i)
115 strings1.insert(patterns1.at(i).GetAsString());
116
117 std::set<std::string> strings2;
118 for (size_t i = 0; i < patterns2.size(); ++i)
119 strings2.insert(patterns2.at(i).GetAsString());
120
121 EXPECT_EQ(strings1, strings2);
122 }
123
101 } // namespace 124 } // namespace
102 125
103 class MockExtensionProvider : public ExternalExtensionProvider { 126 class MockExtensionProvider : public ExternalExtensionProvider {
104 public: 127 public:
105 explicit MockExtensionProvider(Extension::Location location) 128 explicit MockExtensionProvider(Extension::Location location)
106 : location_(location), visit_count_(0) {} 129 : location_(location), visit_count_(0) {}
107 virtual ~MockExtensionProvider() {} 130 virtual ~MockExtensionProvider() {}
108 131
109 void UpdateOrAddExtension(const std::string& id, 132 void UpdateOrAddExtension(const std::string& id,
110 const std::string& version, 133 const std::string& version,
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 474
452 void AddMockExternalProvider(ExternalExtensionProvider* provider) { 475 void AddMockExternalProvider(ExternalExtensionProvider* provider) {
453 service_->AddProviderForTesting(provider); 476 service_->AddProviderForTesting(provider);
454 } 477 }
455 478
456 protected: 479 protected:
457 void TestExternalProvider(MockExtensionProvider* provider, 480 void TestExternalProvider(MockExtensionProvider* provider,
458 Extension::Location location); 481 Extension::Location location);
459 482
460 void PackAndInstallExtension(const FilePath& dir_path, 483 void PackAndInstallExtension(const FilePath& dir_path,
484 const FilePath& pem_path,
461 bool should_succeed) { 485 bool should_succeed) {
462 FilePath crx_path; 486 FilePath crx_path;
463 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &crx_path)); 487 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &crx_path));
464 crx_path = crx_path.AppendASCII("temp.crx"); 488 crx_path = crx_path.AppendASCII("temp.crx");
465 FilePath pem_path = crx_path.DirName().AppendASCII("temp.pem"); 489
490 // Use the existing pem key, if provided.
491 FilePath pem_output_path;
492 if (pem_path.value().empty()) {
493 pem_output_path = crx_path.DirName().AppendASCII("temp.pem");
494 ASSERT_TRUE(file_util::Delete(pem_output_path, false));
495 } else {
496 ASSERT_TRUE(file_util::PathExists(pem_path));
497 }
466 498
467 ASSERT_TRUE(file_util::Delete(crx_path, false)); 499 ASSERT_TRUE(file_util::Delete(crx_path, false));
468 ASSERT_TRUE(file_util::Delete(pem_path, false)); 500
469 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); 501 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
470 ASSERT_TRUE(creator->Run(dir_path, crx_path, FilePath(), pem_path)); 502 ASSERT_TRUE(creator->Run(dir_path,
503 crx_path,
504 pem_path,
505 pem_output_path));
506
471 ASSERT_TRUE(file_util::PathExists(crx_path)); 507 ASSERT_TRUE(file_util::PathExists(crx_path));
472 508
473 InstallExtension(crx_path, should_succeed); 509 InstallExtension(crx_path, should_succeed);
474 } 510 }
475 511
512 void PackAndInstallExtension(const FilePath& dir_path,
513 bool should_succeed) {
514 PackAndInstallExtension(dir_path, FilePath(), should_succeed);
515 }
516
476 void InstallExtension(const FilePath& path, 517 void InstallExtension(const FilePath& path,
477 bool should_succeed) { 518 bool should_succeed) {
478 ASSERT_TRUE(file_util::PathExists(path)); 519 ASSERT_TRUE(file_util::PathExists(path));
479 service_->InstallExtension(path); 520 service_->InstallExtension(path);
480 loop_.RunAllPending(); 521 loop_.RunAllPending();
481 std::vector<std::string> errors = GetErrors(); 522 std::vector<std::string> errors = GetErrors();
482 if (should_succeed) { 523 if (should_succeed) {
483 ++total_successes_; 524 ++total_successes_;
484 525
485 EXPECT_TRUE(installed_) << path.value(); 526 EXPECT_TRUE(installed_) << path.value();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 ASSERT_TRUE(dict != NULL) << msg; 688 ASSERT_TRUE(dict != NULL) << msg;
648 DictionaryValue* pref = NULL; 689 DictionaryValue* pref = NULL;
649 std::string manifest_path = extension_id + ".manifest"; 690 std::string manifest_path = extension_id + ".manifest";
650 ASSERT_TRUE(dict->GetDictionary(manifest_path, &pref)) << msg; 691 ASSERT_TRUE(dict->GetDictionary(manifest_path, &pref)) << msg;
651 EXPECT_TRUE(pref != NULL) << msg; 692 EXPECT_TRUE(pref != NULL) << msg;
652 std::string val; 693 std::string val;
653 ASSERT_TRUE(pref->GetString(pref_path, &val)) << msg; 694 ASSERT_TRUE(pref->GetString(pref_path, &val)) << msg;
654 EXPECT_EQ(expected_val, val) << msg; 695 EXPECT_EQ(expected_val, val) << msg;
655 } 696 }
656 697
698 void SetPref(const std::string& extension_id,
699 const std::string& pref_path,
700 Value* value,
701 const std::string& msg) {
702 const DictionaryValue* dict =
703 profile_->GetPrefs()->GetMutableDictionary("extensions.settings");
704 ASSERT_TRUE(dict != NULL) << msg;
705 DictionaryValue* pref = NULL;
706 ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg;
707 EXPECT_TRUE(pref != NULL) << msg;
708 pref->Set(pref_path, value);
709 }
710
657 void SetPrefInteg(const std::string& extension_id, 711 void SetPrefInteg(const std::string& extension_id,
658 const std::string& pref_path, 712 const std::string& pref_path,
659 int value) { 713 int value) {
660 std::string msg = " while setting: "; 714 std::string msg = " while setting: ";
661 msg += extension_id; 715 msg += extension_id;
662 msg += " "; 716 msg += " ";
663 msg += pref_path; 717 msg += pref_path;
664 msg += " = "; 718 msg += " = ";
665 msg += base::IntToString(value); 719 msg += base::IntToString(value);
666 720
721 SetPref(extension_id, pref_path, Value::CreateIntegerValue(value), msg);
722 }
723
724 void SetPrefBool(const std::string& extension_id,
725 const std::string& pref_path,
726 bool value) {
727 std::string msg = " while setting: ";
728 msg += extension_id + " " + pref_path;
729 msg += " = ";
730 msg += (value ? "true" : "false");
731
732 SetPref(extension_id, pref_path, Value::CreateBooleanValue(value), msg);
733 }
734
735 void ClearPref(const std::string& extension_id,
736 const std::string& pref_path) {
737 std::string msg = " while clearing: ";
738 msg += extension_id + " " + pref_path;
739
667 const DictionaryValue* dict = 740 const DictionaryValue* dict =
668 profile_->GetPrefs()->GetMutableDictionary("extensions.settings"); 741 profile_->GetPrefs()->GetMutableDictionary("extensions.settings");
669 ASSERT_TRUE(dict != NULL) << msg; 742 ASSERT_TRUE(dict != NULL) << msg;
670 DictionaryValue* pref = NULL; 743 DictionaryValue* pref = NULL;
671 ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg; 744 ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg;
672 EXPECT_TRUE(pref != NULL) << msg; 745 EXPECT_TRUE(pref != NULL) << msg;
673 pref->SetInteger(pref_path, value); 746 pref->Remove(pref_path, NULL);
747 }
748
749 void SetPrefStringSet(const std::string& extension_id,
750 const std::string& pref_path,
751 const std::set<std::string>& value) {
752 std::string msg = " while setting: ";
753 msg += extension_id + " " + pref_path;
754
755 ListValue* list_value = new ListValue();
756 for (std::set<std::string>::const_iterator iter = value.begin();
757 iter != value.end(); ++iter)
758 list_value->Append(Value::CreateStringValue(*iter));
759
760 SetPref(extension_id, pref_path, list_value, msg);
674 } 761 }
675 762
676 protected: 763 protected:
677 ExtensionList loaded_; 764 ExtensionList loaded_;
678 std::string unloaded_id_; 765 std::string unloaded_id_;
679 const Extension* installed_; 766 const Extension* installed_;
680 767
681 private: 768 private:
682 NotificationRegistrar registrar_; 769 NotificationRegistrar registrar_;
683 }; 770 };
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 EXPECT_EQ(0u, errors.size()) << "There were errors: " 1089 EXPECT_EQ(0u, errors.size()) << "There were errors: "
1003 << JoinString(errors, ','); 1090 << JoinString(errors, ',');
1004 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false)) << 1091 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false)) <<
1005 path.value(); 1092 path.value();
1006 1093
1007 installed_ = NULL; 1094 installed_ = NULL;
1008 loaded_.clear(); 1095 loaded_.clear();
1009 ExtensionErrorReporter::GetInstance()->ClearErrors(); 1096 ExtensionErrorReporter::GetInstance()->ClearErrors();
1010 } 1097 }
1011 1098
1099 // This tests that the granted permissions preferences are correctly set when
1100 // installing an extension.
1101 TEST_F(ExtensionsServiceTest, GrantedPermissions) {
1102 InitializeEmptyExtensionsService();
1103 FilePath path;
1104 FilePath pem_path;
1105 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
1106 path = path.AppendASCII("extensions")
1107 .AppendASCII("permissions");
1108
1109 pem_path = path.AppendASCII("unknown.pem");
1110 path = path.AppendASCII("unknown");
1111
1112 ASSERT_TRUE(file_util::PathExists(pem_path));
1113 ASSERT_TRUE(file_util::PathExists(path));
1114
1115 ExtensionPrefs* prefs = service_->extension_prefs();
1116
1117 std::set<std::string> expected_api_perms;
1118 std::set<std::string> known_api_perms;
1119 bool full_access;
1120 ExtensionExtent expected_host_perms;
1121 ExtensionExtent known_host_perms;
1122
1123 // Make sure there aren't any granted permissions before the
1124 // extension is installed.
1125 EXPECT_FALSE(prefs->GetGrantedPermissions(
1126 permissions_crx, &full_access, &known_api_perms, &known_host_perms));
1127 EXPECT_TRUE(known_api_perms.empty());
1128 EXPECT_TRUE(known_host_perms.is_empty());
1129 EXPECT_FALSE(full_access);
1130
1131 PackAndInstallExtension(path, pem_path, true);
1132
1133 EXPECT_EQ(0u, GetErrors().size());
1134 ASSERT_EQ(1u, service_->extensions()->size());
1135 std::string extension_id = service_->extensions()->at(0)->id();
1136 EXPECT_EQ(permissions_crx, extension_id);
1137
1138
1139 // Verify that the valid API permissions have been recognized.
1140 expected_api_perms.insert("tabs");
1141
1142 AddPattern(&expected_host_perms, "http://*.google.com/*");
1143 AddPattern(&expected_host_perms, "https://*.google.com/*");
1144 AddPattern(&expected_host_perms, "http://www.example.com/*");
1145
1146 EXPECT_TRUE(prefs->GetGrantedPermissions(extension_id,
1147 &full_access,
1148 &known_api_perms,
1149 &known_host_perms));
1150
1151 EXPECT_EQ(expected_api_perms, known_api_perms);
1152 EXPECT_FALSE(full_access);
1153 AssertEqualExtents(&expected_host_perms, &known_host_perms);
1154 }
1155
1156
1157 // Tests that the granted permissions full_access bit gets set correctly when
1158 // an extension contains an NPAPI plugin.
1159 TEST_F(ExtensionsServiceTest, GrantedFullAccessPermissions) {
1160 InitializeEmptyExtensionsService();
1161
1162 FilePath path;
1163 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
1164 path = path.AppendASCII("extensions")
1165 .AppendASCII("good")
1166 .AppendASCII("Extensions")
1167 .AppendASCII("hpiknbiabeeppbpihjehijgoemciehgk")
1168 .AppendASCII("2");
1169
1170 ASSERT_TRUE(file_util::PathExists(path));
1171
1172 PackAndInstallExtension(path, true);
1173
1174 EXPECT_EQ(0u, GetErrors().size());
1175 EXPECT_EQ(1u, service_->extensions()->size());
1176 const Extension* extension = service_->extensions()->at(0);
1177 std::string extension_id = extension->id();
1178 ExtensionPrefs* prefs = service_->extension_prefs();
1179
1180 bool full_access;
1181 std::set<std::string> api_permissions;
1182 ExtensionExtent host_permissions;
1183 EXPECT_TRUE(prefs->GetGrantedPermissions(
1184 extension_id, &full_access, &api_permissions, &host_permissions));
1185
1186 EXPECT_TRUE(full_access);
1187 EXPECT_TRUE(api_permissions.empty());
1188 EXPECT_TRUE(host_permissions.is_empty());
1189 }
1190
1191 // Tests that the extension is disabled when permissions are missing from
1192 // the extension's granted permissions preferences. (This simulates updating
1193 // the browser to a version which recognizes more permissions).
1194 TEST_F(ExtensionsServiceTest, GrantedAPIAndHostPermissions) {
1195 InitializeEmptyExtensionsService();
1196
1197 FilePath path;
1198 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
1199 path = path.AppendASCII("extensions")
1200 .AppendASCII("permissions")
1201 .AppendASCII("unknown");
1202
1203 ASSERT_TRUE(file_util::PathExists(path));
1204
1205 PackAndInstallExtension(path, true);
1206
1207 EXPECT_EQ(0u, GetErrors().size());
1208 EXPECT_EQ(1u, service_->extensions()->size());
1209 const Extension* extension = service_->extensions()->at(0);
1210 std::string extension_id = extension->id();
1211
1212 ExtensionPrefs* prefs = service_->extension_prefs();
1213
1214 std::set<std::string> expected_api_permissions;
1215 ExtensionExtent expected_host_permissions;
1216
1217 expected_api_permissions.insert("tabs");
1218 AddPattern(&expected_host_permissions, "http://*.google.com/*");
1219 AddPattern(&expected_host_permissions, "https://*.google.com/*");
1220 AddPattern(&expected_host_permissions, "http://www.example.com/*");
1221
1222 std::set<std::string> api_permissions;
1223 std::set<std::string> host_permissions;
1224
1225 // Test that the extension is disabled when an API permission is missing from
1226 // the extension's granted api permissions preference. (This simulates
1227 // updating the browser to a version which recognizes a new API permission).
1228 host_permissions.insert("http://*.google.com/*");
1229 host_permissions.insert("https://*.google.com/*");
1230 host_permissions.insert("http://www.example.com/*");
1231
1232 SetPrefBool(extension_id, "granted_permissions.initialized", true);
1233 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions);
1234 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions);
1235
1236 service_->ReloadExtensions();
1237
1238 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED);
1239 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id));
1240
1241 // Now grant and re-enable the extension, making sure the prefs are updated.
1242 service_->GrantPermissionsAndEnableExtension(extension);
1243
1244 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED);
1245 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id));
1246
1247 std::set<std::string> current_api_permissions;
1248 ExtensionExtent current_host_permissions;
1249 bool current_full_access;
1250
1251 ASSERT_TRUE(prefs->GetGrantedPermissions(extension_id,
1252 &current_full_access,
1253 &current_api_permissions,
1254 &current_host_permissions));
1255
1256 ASSERT_FALSE(current_full_access);
1257 ASSERT_EQ(expected_api_permissions, current_api_permissions);
1258 AssertEqualExtents(&expected_host_permissions, &current_host_permissions);
1259
1260 // Tests that the extension is disabled when a host permission is missing from
1261 // the extension's granted host permissions preference. (This simulates
1262 // updating the browser to a version which recognizes additional host
1263 // permissions).
1264 api_permissions.clear();
1265 host_permissions.clear();
1266 current_api_permissions.clear();
1267 current_host_permissions.ClearPaths();
1268
1269 api_permissions.insert("tabs");
1270 host_permissions.insert("http://*.google.com/*");
1271 host_permissions.insert("https://*.google.com/*");
1272
1273 SetPrefBool(extension_id, "granted_permissions.initialized", true);
1274 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions);
1275 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions);
1276
1277 service_->ReloadExtensions();
1278
1279 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED);
1280 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id));
1281
1282 // Now grant and re-enable the extension, making sure the prefs are updated.
1283 service_->GrantPermissionsAndEnableExtension(extension);
1284
1285 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED);
1286 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id));
1287
1288 ASSERT_TRUE(prefs->GetGrantedPermissions(extension_id,
1289 &current_full_access,
1290 &current_api_permissions,
1291 &current_host_permissions));
1292
1293 ASSERT_FALSE(current_full_access);
1294 ASSERT_EQ(expected_api_permissions, current_api_permissions);
1295 AssertEqualExtents(&expected_host_permissions, &current_host_permissions);
1296
1297 // Tests that the granted permissions preferences are initialized when
1298 // migrating from the old pref schema.
1299 current_api_permissions.clear();
1300 current_host_permissions.ClearPaths();
1301
1302 ClearPref(extension_id, "granted_permissions");
1303
1304 service_->ReloadExtensions();
1305
1306 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED);
1307 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id));
1308
1309 ASSERT_TRUE(prefs->GetGrantedPermissions(extension_id,
1310 &current_full_access,
1311 &current_api_permissions,
1312 &current_host_permissions));
1313
1314 ASSERT_FALSE(current_full_access);
1315 ASSERT_EQ(expected_api_permissions, current_api_permissions);
1316 AssertEqualExtents(&expected_host_permissions, &current_host_permissions);
1317 }
1318
1012 // Test Packaging and installing an extension. 1319 // Test Packaging and installing an extension.
1013 TEST_F(ExtensionsServiceTest, PackExtension) { 1320 TEST_F(ExtensionsServiceTest, PackExtension) {
1014 InitializeEmptyExtensionsService(); 1321 InitializeEmptyExtensionsService();
1015 FilePath extensions_path; 1322 FilePath extensions_path;
1016 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); 1323 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
1017 extensions_path = extensions_path.AppendASCII("extensions"); 1324 extensions_path = extensions_path.AppendASCII("extensions");
1018 FilePath input_directory = extensions_path 1325 FilePath input_directory = extensions_path
1019 .AppendASCII("good") 1326 .AppendASCII("good")
1020 .AppendASCII("Extensions") 1327 .AppendASCII("Extensions")
1021 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 1328 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 // Component extensions shouldn't get recourded in the prefs. 3071 // Component extensions shouldn't get recourded in the prefs.
2765 ValidatePrefKeyCount(0); 3072 ValidatePrefKeyCount(0);
2766 3073
2767 // Reload all extensions, and make sure it comes back. 3074 // Reload all extensions, and make sure it comes back.
2768 std::string extension_id = service_->extensions()->at(0)->id(); 3075 std::string extension_id = service_->extensions()->at(0)->id();
2769 loaded_.clear(); 3076 loaded_.clear();
2770 service_->ReloadExtensions(); 3077 service_->ReloadExtensions();
2771 ASSERT_EQ(1u, service_->extensions()->size()); 3078 ASSERT_EQ(1u, service_->extensions()->size());
2772 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); 3079 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id());
2773 } 3080 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698