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

Unified Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 2147923002: [Extensions] Fixed removing from blacklist. (Closed) Base URL: ssh://bitbucket.browser.yandex-team.ru/chromium/src.git@master
Patch Set: Unnecessary extensions:: namespace is removed. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | extensions/browser/extension_prefs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a64f20837c5f0919c7226ccdb002ca0218bafe76 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 blacklisted extension will be enabled if it is removed
+// from the blacklist. Also checks that all blacklisted preferences will be
+// cleared 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 to the blacklist.
+ 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 the blacklist.
+ test_blacklist.SetBlacklistState(good0, extensions::NOT_BLACKLISTED, true);
+ observer.WaitForExtensionLoaded()->id();
+
+ // The extension should be enabled, both "blacklist" and "blacklist_state"
+ // should be 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);
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | extensions/browser/extension_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698