Chromium Code Reviews| Index: chrome/browser/extensions/extension_service_unittest.cc |
| diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc |
| index 471cd5d7890f8ca26532a3a9a26bb607beed0376..e2a0db13f7aaef995d112e92119826191bd70207 100644 |
| --- a/chrome/browser/extensions/extension_service_unittest.cc |
| +++ b/chrome/browser/extensions/extension_service_unittest.cc |
| @@ -3121,6 +3121,47 @@ TEST_F(ExtensionServiceTest, BlacklistedExtensionWillNotInstall) { |
| #endif // defined(ENABLE_BLACKLIST_TESTS) |
| #if defined(ENABLE_BLACKLIST_TESTS) |
| +// Tests that previously blackisted extension will be enabled if it is removed |
| +// from blacklist. Also checks that all blacklisted preferences will be cleaned |
|
Devlin
2016/07/18 16:22:17
nit: from *the* blacklist
|
| +// in that case. |
| +TEST_F(ExtensionServiceTest, RemoveExtensionFromBlacklist) { |
| + extensions::TestBlacklist test_blacklist; |
| + // A profile with 3 extensions installed: good0, good1, and good2. |
| + InitializeGoodInstalledExtensionService(); |
| + test_blacklist.Attach(service()->blacklist_); |
| + service()->Init(); |
| + |
| + ASSERT_TRUE(registry()->enabled_extensions().Contains(good0)); |
| + extensions::TestExtensionRegistryObserver observer( |
| + extensions::ExtensionRegistry::Get(profile()), good0); |
| + |
| + // Add the extension from blacklist. |
|
Devlin
2016/07/18 16:22:17
nit: s/from/to the
|
| + test_blacklist.SetBlacklistState(good0, extensions::BLACKLISTED_MALWARE, |
| + true); |
| + observer.WaitForExtensionUnloaded(); |
| + |
| + // The extension should be disabled, both "blacklist" and "blacklist_state" |
| + // prefs should be set. |
| + const auto prefs = ExtensionPrefs::Get(profile()); |
| + EXPECT_FALSE(registry()->enabled_extensions().Contains(good0)); |
| + EXPECT_TRUE(prefs->IsExtensionBlacklisted(good0)); |
| + EXPECT_EQ(extensions::BLACKLISTED_MALWARE, |
| + prefs->GetExtensionBlacklistState(good0)); |
| + |
| + // Remove the extension from blacklist. |
| + test_blacklist.SetBlacklistState(good0, extensions::NOT_BLACKLISTED, true); |
| + observer.WaitForExtensionLoaded()->id(); |
| + |
| + // The extension should be enabled, both "blacklist" and "blacklist_state" |
| + // should be cleaned. |
|
Devlin
2016/07/18 16:22:17
s/cleaned/cleared
|
| + EXPECT_TRUE(registry()->enabled_extensions().Contains(good0)); |
| + EXPECT_FALSE(prefs->IsExtensionBlacklisted(good0)); |
| + EXPECT_EQ(extensions::NOT_BLACKLISTED, |
| + prefs->GetExtensionBlacklistState(good0)); |
| +} |
| +#endif // defined(ENABLE_BLACKLIST_TESTS) |
| + |
| +#if defined(ENABLE_BLACKLIST_TESTS) |
| // Unload blacklisted extension on policy change. |
| TEST_F(ExtensionServiceTest, UnloadBlacklistedExtensionPolicy) { |
| extensions::TestBlacklist test_blacklist; |
| @@ -3188,8 +3229,10 @@ TEST_F(ExtensionServiceTest, BlacklistedInPrefsFromStartup) { |
| InitializeGoodInstalledExtensionService(); |
| test_blacklist.Attach(service()->blacklist_); |
| - ExtensionPrefs::Get(profile())->SetExtensionBlacklisted(good0, true); |
| - ExtensionPrefs::Get(profile())->SetExtensionBlacklisted(good1, true); |
| + ExtensionPrefs::Get(profile())->SetExtensionBlacklistState( |
| + good0, extensions::BLACKLISTED_MALWARE); |
| + ExtensionPrefs::Get(profile())->SetExtensionBlacklistState( |
| + good1, extensions::BLACKLISTED_MALWARE); |
| test_blacklist.SetBlacklistState( |
| good1, extensions::BLACKLISTED_MALWARE, false); |