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

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

Issue 8380006: Exempt component and policy-installed extensions from policy blacklist check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, add comment regarding policy check on startup. Created 9 years, 2 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') | no next file » | 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 b2da4aa2f3df7279317699e9fdf39888b49d9010..b9083a21ae2a6068b0e42c53df7d27687253fda9 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -2599,6 +2599,93 @@ TEST_F(ExtensionServiceTest, BlacklistedByPolicyRemovedIfRunning) {
EXPECT_EQ(0u, service_->extensions()->size());
}
+// Tests that component extensions are not blacklisted by policy.
+TEST_F(ExtensionServiceTest, ComponentExtensionWhitelisted) {
+ InitializeEmptyExtensionService();
+
+ // Blacklist everything.
+ {
+ ListPrefUpdate update(profile_->GetPrefs(),
+ prefs::kExtensionInstallDenyList);
+ ListValue* blacklist = update.Get();
+ blacklist->Append(Value::CreateStringValue("*"));
+ }
+
+ // Install a component extension.
+ FilePath path = data_dir_
+ .AppendASCII("good")
+ .AppendASCII("Extensions")
+ .AppendASCII(good0)
+ .AppendASCII("1.0.0.0");
+ std::string manifest;
+ ASSERT_TRUE(file_util::ReadFileToString(
+ path.Append(Extension::kManifestFilename), &manifest));
+ service_->register_component_extension(
+ ExtensionService::ComponentExtensionInfo(manifest, path));
+ service_->Init();
+
+ // Extension should be installed despite blacklist.
+ ASSERT_EQ(1u, service_->extensions()->size());
+ EXPECT_EQ(good0, service_->extensions()->at(0)->id());
+
+ // Poke external providers and make sure the extension is still present.
+ service_->CheckForExternalUpdates();
+ ASSERT_EQ(1u, service_->extensions()->size());
+ EXPECT_EQ(good0, service_->extensions()->at(0)->id());
+
+ // Extension should not be uninstalled on blacklist changes.
+ {
+ ListPrefUpdate update(profile_->GetPrefs(),
+ prefs::kExtensionInstallDenyList);
+ ListValue* blacklist = update.Get();
+ blacklist->Append(Value::CreateStringValue(good0));
+ }
+ loop_.RunAllPending();
+ ASSERT_EQ(1u, service_->extensions()->size());
+ EXPECT_EQ(good0, service_->extensions()->at(0)->id());
+}
+
+// Tests that policy-installed extensions are not blacklisted by policy.
+TEST_F(ExtensionServiceTest, PolicyInstalledExtensionsWhitelisted) {
+ InitializeEmptyExtensionService();
+
+ // Blacklist everything.
+ {
+ ListPrefUpdate update(profile_->GetPrefs(),
+ prefs::kExtensionInstallDenyList);
+ ListValue* blacklist = update.Get();
+ blacklist->Append(Value::CreateStringValue("*"));
+ }
+
+ // Have policy force-install an extension.
+ MockExtensionProvider* provider =
+ new MockExtensionProvider(service_,
+ Extension::EXTERNAL_POLICY_DOWNLOAD);
+ AddMockExternalProvider(provider);
+ provider->UpdateOrAddExtension(good_crx, "1.0.0.0",
+ data_dir_.AppendASCII("good.crx"));
+
+ // Reloading extensions should find our externally registered extension
+ // and install it.
+ service_->CheckForExternalUpdates();
+ loop_.RunAllPending();
+
+ // Extension should be installed despite blacklist.
+ ASSERT_EQ(1u, service_->extensions()->size());
+ EXPECT_EQ(good_crx, service_->extensions()->at(0)->id());
+
+ // Blacklist update should not uninstall the extension.
+ {
+ ListPrefUpdate update(profile_->GetPrefs(),
+ prefs::kExtensionInstallDenyList);
+ ListValue* blacklist = update.Get();
+ blacklist->Append(Value::CreateStringValue(good0));
+ }
+ loop_.RunAllPending();
+ ASSERT_EQ(1u, service_->extensions()->size());
+ EXPECT_EQ(good_crx, service_->extensions()->at(0)->id());
+}
+
// Tests disabling extensions
TEST_F(ExtensionServiceTest, DisableExtension) {
InitializeEmptyExtensionService();
@@ -3145,8 +3232,7 @@ void ExtensionServiceTest::TestExternalProvider(
// Now test the case where user uninstalls and then the extension is removed
// from the external provider.
-
- provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path);
+ provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path);
service_->CheckForExternalUpdates();
loop_.RunAllPending();
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698