OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 EXPECT_EQ(Manifest::INTERNAL, loaded_[1]->location()); | 1300 EXPECT_EQ(Manifest::INTERNAL, loaded_[1]->location()); |
1301 | 1301 |
1302 int index = expected_num_extensions - 1; | 1302 int index = expected_num_extensions - 1; |
1303 EXPECT_EQ(std::string(good2), loaded_[index]->id()); | 1303 EXPECT_EQ(std::string(good2), loaded_[index]->id()); |
1304 EXPECT_EQ(std::string("My extension 3"), loaded_[index]->name()); | 1304 EXPECT_EQ(std::string("My extension 3"), loaded_[index]->name()); |
1305 EXPECT_EQ(std::string(), loaded_[index]->description()); | 1305 EXPECT_EQ(std::string(), loaded_[index]->description()); |
1306 EXPECT_EQ(0u, | 1306 EXPECT_EQ(0u, |
1307 extensions::ContentScriptsInfo::GetContentScripts( | 1307 extensions::ContentScriptsInfo::GetContentScripts( |
1308 loaded_[index].get()).size()); | 1308 loaded_[index].get()).size()); |
1309 EXPECT_EQ(Manifest::INTERNAL, loaded_[index]->location()); | 1309 EXPECT_EQ(Manifest::INTERNAL, loaded_[index]->location()); |
1310 }; | 1310 } |
1311 | 1311 |
1312 // Test loading bad extensions from the profile directory. | 1312 // Test loading bad extensions from the profile directory. |
1313 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) { | 1313 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) { |
1314 // Initialize the test dir with a bad Preferences/extensions. | 1314 // Initialize the test dir with a bad Preferences/extensions. |
1315 base::FilePath source_install_dir = | 1315 base::FilePath source_install_dir = |
1316 data_dir().AppendASCII("bad").AppendASCII("Extensions"); | 1316 data_dir().AppendASCII("bad").AppendASCII("Extensions"); |
1317 base::FilePath pref_path = | 1317 base::FilePath pref_path = |
1318 source_install_dir.DirName().Append(chrome::kPreferencesFilename); | 1318 source_install_dir.DirName().Append(chrome::kPreferencesFilename); |
1319 | 1319 |
1320 InitializeInstalledExtensionService(pref_path, source_install_dir); | 1320 InitializeInstalledExtensionService(pref_path, source_install_dir); |
(...skipping 15 matching lines...) Expand all Loading... |
1336 | 1336 |
1337 EXPECT_TRUE(MatchPattern(base::UTF16ToUTF8(GetErrors()[2]), | 1337 EXPECT_TRUE(MatchPattern(base::UTF16ToUTF8(GetErrors()[2]), |
1338 std::string("Could not load extension from '*'. ") + | 1338 std::string("Could not load extension from '*'. ") + |
1339 extensions::manifest_errors::kMissingFile)) << | 1339 extensions::manifest_errors::kMissingFile)) << |
1340 base::UTF16ToUTF8(GetErrors()[2]); | 1340 base::UTF16ToUTF8(GetErrors()[2]); |
1341 | 1341 |
1342 EXPECT_TRUE(MatchPattern(base::UTF16ToUTF8(GetErrors()[3]), | 1342 EXPECT_TRUE(MatchPattern(base::UTF16ToUTF8(GetErrors()[3]), |
1343 std::string("Could not load extension from '*'. ") + | 1343 std::string("Could not load extension from '*'. ") + |
1344 extensions::manifest_errors::kManifestUnreadable)) << | 1344 extensions::manifest_errors::kManifestUnreadable)) << |
1345 base::UTF16ToUTF8(GetErrors()[3]); | 1345 base::UTF16ToUTF8(GetErrors()[3]); |
1346 }; | 1346 } |
1347 | 1347 |
1348 // Test various cases for delayed install because of missing imports. | 1348 // Test various cases for delayed install because of missing imports. |
1349 TEST_F(ExtensionServiceTest, PendingImports) { | 1349 TEST_F(ExtensionServiceTest, PendingImports) { |
1350 InitPluginService(); | 1350 InitPluginService(); |
1351 | 1351 |
1352 base::FilePath source_install_dir = | 1352 base::FilePath source_install_dir = |
1353 data_dir().AppendASCII("pending_updates_with_imports").AppendASCII( | 1353 data_dir().AppendASCII("pending_updates_with_imports").AppendASCII( |
1354 "Extensions"); | 1354 "Extensions"); |
1355 base::FilePath pref_path = | 1355 base::FilePath pref_path = |
1356 source_install_dir.DirName().Append(chrome::kPreferencesFilename); | 1356 source_install_dir.DirName().Append(chrome::kPreferencesFilename); |
(...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4251 } | 4251 } |
4252 | 4252 |
4253 // Tests reloading extensions. | 4253 // Tests reloading extensions. |
4254 TEST_F(ExtensionServiceTest, ReloadExtensions) { | 4254 TEST_F(ExtensionServiceTest, ReloadExtensions) { |
4255 InitializeEmptyExtensionService(); | 4255 InitializeEmptyExtensionService(); |
4256 | 4256 |
4257 // Simple extension that should install without error. | 4257 // Simple extension that should install without error. |
4258 base::FilePath path = data_dir().AppendASCII("good.crx"); | 4258 base::FilePath path = data_dir().AppendASCII("good.crx"); |
4259 InstallCRX(path, INSTALL_NEW, | 4259 InstallCRX(path, INSTALL_NEW, |
4260 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT); | 4260 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT); |
4261 const char* extension_id = good_crx; | 4261 const char* const extension_id = good_crx; |
4262 service()->DisableExtension(extension_id, Extension::DISABLE_USER_ACTION); | 4262 service()->DisableExtension(extension_id, Extension::DISABLE_USER_ACTION); |
4263 | 4263 |
4264 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 4264 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
4265 EXPECT_EQ(1u, registry()->disabled_extensions().size()); | 4265 EXPECT_EQ(1u, registry()->disabled_extensions().size()); |
4266 | 4266 |
4267 service()->ReloadExtensionsForTest(); | 4267 service()->ReloadExtensionsForTest(); |
4268 | 4268 |
4269 // The creation flags should not change when reloading the extension. | 4269 // The creation flags should not change when reloading the extension. |
4270 const Extension* extension = service()->GetExtensionById(good_crx, true); | 4270 const Extension* extension = service()->GetExtensionById(good_crx, true); |
4271 EXPECT_TRUE(extension->from_webstore()); | 4271 EXPECT_TRUE(extension->from_webstore()); |
(...skipping 18 matching lines...) Expand all Loading... |
4290 // Extension counts shouldn't change. | 4290 // Extension counts shouldn't change. |
4291 EXPECT_EQ(1u, registry()->enabled_extensions().size()); | 4291 EXPECT_EQ(1u, registry()->enabled_extensions().size()); |
4292 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 4292 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
4293 } | 4293 } |
4294 | 4294 |
4295 // Tests reloading an extension. | 4295 // Tests reloading an extension. |
4296 TEST_F(ExtensionServiceTest, ReloadExtension) { | 4296 TEST_F(ExtensionServiceTest, ReloadExtension) { |
4297 InitializeEmptyExtensionService(); | 4297 InitializeEmptyExtensionService(); |
4298 | 4298 |
4299 // Simple extension that should install without error. | 4299 // Simple extension that should install without error. |
4300 const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 4300 const char extension_id[] = "behllobkkfkfnphdnhnkndlbkcpglgmj"; |
4301 base::FilePath ext = data_dir() | 4301 base::FilePath ext = data_dir() |
4302 .AppendASCII("good") | 4302 .AppendASCII("good") |
4303 .AppendASCII("Extensions") | 4303 .AppendASCII("Extensions") |
4304 .AppendASCII(extension_id) | 4304 .AppendASCII(extension_id) |
4305 .AppendASCII("1.0.0.0"); | 4305 .AppendASCII("1.0.0.0"); |
4306 extensions::UnpackedInstaller::Create(service())->Load(ext); | 4306 extensions::UnpackedInstaller::Create(service())->Load(ext); |
4307 base::RunLoop().RunUntilIdle(); | 4307 base::RunLoop().RunUntilIdle(); |
4308 | 4308 |
4309 EXPECT_EQ(1u, registry()->enabled_extensions().size()); | 4309 EXPECT_EQ(1u, registry()->enabled_extensions().size()); |
4310 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 4310 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6467 extension_sync_service()->ProcessSyncChanges(FROM_HERE, change_list); | 6467 extension_sync_service()->ProcessSyncChanges(FROM_HERE, change_list); |
6468 | 6468 |
6469 // Uninstalling the extension without installed_by_custodian should have been | 6469 // Uninstalling the extension without installed_by_custodian should have been |
6470 // blocked by policy, so it should still be there. | 6470 // blocked by policy, so it should still be there. |
6471 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_ids[0])); | 6471 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension_ids[0])); |
6472 | 6472 |
6473 // But installed_by_custodian should result in bypassing the policy check. | 6473 // But installed_by_custodian should result in bypassing the policy check. |
6474 EXPECT_FALSE( | 6474 EXPECT_FALSE( |
6475 registry()->GenerateInstalledExtensionsSet()->Contains(extension_ids[1])); | 6475 registry()->GenerateInstalledExtensionsSet()->Contains(extension_ids[1])); |
6476 } | 6476 } |
6477 #endif // defined(ENABLE_MANAGED_USERS) | 6477 #endif // defined(ENABLE_MANAGED_USERS) |
6478 | 6478 |
6479 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) { | 6479 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) { |
6480 InitializeEmptyExtensionService(); | 6480 InitializeEmptyExtensionService(); |
6481 | 6481 |
6482 base::FilePath path = data_dir().AppendASCII("good.crx"); | 6482 base::FilePath path = data_dir().AppendASCII("good.crx"); |
6483 InstallCRX(path, INSTALL_NEW); | 6483 InstallCRX(path, INSTALL_NEW); |
6484 ValidatePrefKeyCount(1u); | 6484 ValidatePrefKeyCount(1u); |
6485 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); | 6485 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); |
6486 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); | 6486 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); |
6487 | 6487 |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7353 | 7353 |
7354 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 7354 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
7355 content::Source<Profile>(profile()), | 7355 content::Source<Profile>(profile()), |
7356 content::NotificationService::NoDetails()); | 7356 content::NotificationService::NoDetails()); |
7357 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 7357 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
7358 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 7358 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
7359 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 7359 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
7360 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 7360 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
7361 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 7361 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
7362 } | 7362 } |
OLD | NEW |