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

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

Issue 11415216: Make Blacklist::IsBlacklist asynchronous (it will need to be for safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another test Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_system.cc » ('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 847c9870d68dec1a2cfb81dd35ef90507879e606..def4e8a05b6c0423b257f407bccd5e12d1fc0a73 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -626,7 +626,8 @@ class ExtensionServiceTest
enum InstallState {
INSTALL_FAILED,
INSTALL_UPDATED,
- INSTALL_NEW
+ INSTALL_NEW,
+ INSTALL_WITHOUT_LOAD,
};
const Extension* PackAndInstallCRX(const FilePath& dir_path,
@@ -701,14 +702,19 @@ class ExtensionServiceTest
++expected_extensions_count_;
EXPECT_TRUE(installed_) << path.value();
-
- EXPECT_EQ(1u, loaded_.size()) << path.value();
EXPECT_EQ(0u, errors.size()) << path.value();
- EXPECT_EQ(expected_extensions_count_, service_->extensions()->size()) <<
- path.value();
- extension = loaded_[0];
- EXPECT_TRUE(service_->GetExtensionById(extension->id(), false)) <<
- path.value();
+
+ if (install_state == INSTALL_WITHOUT_LOAD) {
+ EXPECT_EQ(0u, loaded_.size()) << path.value();
+ } else {
+ EXPECT_EQ(1u, loaded_.size()) << path.value();
+ EXPECT_EQ(expected_extensions_count_, service_->extensions()->size()) <<
+ path.value();
+ extension = loaded_[0];
+ EXPECT_TRUE(service_->GetExtensionById(extension->id(), false)) <<
+ path.value();
+ }
+
for (std::vector<string16>::iterator err = errors.begin();
err != errors.end(); ++err) {
LOG(ERROR) << *err;
@@ -2998,7 +3004,7 @@ TEST_F(ExtensionServiceTest, BlacklistedExtensionWillNotInstall) {
// We can not install good_crx.
FilePath path = data_dir_.AppendASCII("good.crx");
- InstallCRX(path, INSTALL_FAILED);
+ InstallCRX(path, INSTALL_WITHOUT_LOAD);
EXPECT_EQ(0u, service_->extensions()->size());
ValidateBooleanPref(good_crx, "blacklist", true);
}
@@ -3024,97 +3030,13 @@ TEST_F(ExtensionServiceTest, UnloadBlacklistedExtensionPolicy) {
"v1");
// Make sure pref is updated
+ loop_.RunUntilIdle();
- // Now, the good_crx is blacklisted but whitelist negates it.
- ValidateBooleanPref(good_crx, "blacklist", true);
- EXPECT_EQ(1u, service_->extensions()->size());
-
- whitelist.Clear();
- prefs->Set(prefs::kExtensionInstallAllowList, whitelist);
-
- // Now, the good_crx is blacklisted for good.
+ // The good_crx is blacklisted and the whitelist doesn't negate it.
ValidateBooleanPref(good_crx, "blacklist", true);
EXPECT_EQ(0u, service_->extensions()->size());
}
-// Allow Google-blacklisted extension if policy explicitly allows it (blacklist
-// then set policy).
-TEST_F(ExtensionServiceTest, WhitelistGoogleBlacklistedExtension) {
- InitializeEmptyExtensionService();
-
- std::vector<std::string> blacklist;
- blacklist.push_back(good_crx);
- ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
- "v1");
-
- FilePath path = data_dir_.AppendASCII("good.crx");
- InstallCRX(path, INSTALL_FAILED);
-
- base::ListValue whitelist;
- whitelist.Append(base::Value::CreateStringValue(good_crx));
- service_->extension_prefs()->pref_service()->Set(
- prefs::kExtensionInstallAllowList, whitelist);
-
- InstallCRX(path, INSTALL_NEW);
-}
-
-// Allow Google-blacklisted extension if policy requires it (blacklist then set
-// policy).
-TEST_F(ExtensionServiceTest, ForcelistGoogleBlacklistedExtension) {
- InitializeEmptyExtensionService();
-
- std::vector<std::string> blacklist;
- blacklist.push_back(good_crx);
- ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
- "v1");
-
- FilePath path = data_dir_.AppendASCII("good.crx");
- InstallCRX(path, INSTALL_FAILED);
-
- base::ListValue forcelist;
- forcelist.Append(base::Value::CreateStringValue(good_crx));
- service_->extension_prefs()->pref_service()->Set(
- prefs::kExtensionInstallAllowList, forcelist);
-
- InstallCRX(path, INSTALL_NEW);
-}
-
-// Allow Google-blacklisted extension if policy explicitly allows it (set policy
-// then blacklist).
-TEST_F(ExtensionServiceTest, GoogleBlacklistWhitelistedExtension) {
- InitializeEmptyExtensionService();
-
- base::ListValue whitelist;
- whitelist.Append(base::Value::CreateStringValue(good_crx));
- service_->extension_prefs()->pref_service()->Set(
- prefs::kExtensionInstallAllowList, whitelist);
-
- std::vector<std::string> blacklist;
- blacklist.push_back(good_crx);
- ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
- "v1");
-
- InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
-}
-
-// Allow Google-blacklisted extension if policy requires it (set policy then
-// blacklist).
-TEST_F(ExtensionServiceTest, GoogleBlacklistForcelistedExtension) {
- InitializeEmptyExtensionService();
-
- base::ListValue forcelist;
- forcelist.Append(base::Value::CreateStringValue(good_crx));
- service_->extension_prefs()->pref_service()->Set(
- prefs::kExtensionInstallAllowList, forcelist);
-
- std::vector<std::string> blacklist;
- blacklist.push_back(good_crx);
- ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
- "v1");
-
- InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
-}
-
// Test loading extensions from the profile directory, except
// blacklisted ones.
TEST_F(ExtensionServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) {
@@ -3148,7 +3070,10 @@ TEST_F(ExtensionServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) {
}
ASSERT_EQ(2u, loaded_.size());
- EXPECT_FALSE(service_->GetExtensionById(good1, true));
+ EXPECT_TRUE(service_->GetInstalledExtension(good1));
+ int include_mask = ExtensionService::INCLUDE_EVERYTHING &
+ ~ExtensionService::INCLUDE_BLACKLISTED;
+ EXPECT_FALSE(service_->GetExtensionById(good1, include_mask));
}
// Will not install extension blacklisted by policy.
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698