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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 291603002: Don't try to reload blacklisted extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: expect_eq Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 3000 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 EXPECT_EQ(0u, registry_->disabled_extensions().size()); 3011 EXPECT_EQ(0u, registry_->disabled_extensions().size());
3012 } 3012 }
3013 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) 3013 #endif // !defined(OS_POSIX) || defined(OS_MACOSX)
3014 3014
3015 namespace { 3015 namespace {
3016 3016
3017 bool IsExtension(const Extension* extension) { 3017 bool IsExtension(const Extension* extension) {
3018 return extension->GetType() == Manifest::TYPE_EXTENSION; 3018 return extension->GetType() == Manifest::TYPE_EXTENSION;
3019 } 3019 }
3020 3020
3021 std::set<std::string> StringSet(const std::string& s) {
3022 std::set<std::string> set;
3023 set.insert(s);
3024 return set;
3025 }
3026
3027 std::set<std::string> StringSet(const std::string& s1, const std::string& s2) {
3028 std::set<std::string> set = StringSet(s1);
3029 set.insert(s2);
3030 return set;
3031 }
3032
3021 } // namespace 3033 } // namespace
3022 3034
3023 // Test adding a pending extension. 3035 // Test adding a pending extension.
3024 TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) { 3036 TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) {
3025 InitializeEmptyExtensionService(); 3037 InitializeEmptyExtensionService();
3026 3038
3027 const std::string kFakeId(all_zero); 3039 const std::string kFakeId(all_zero);
3028 const GURL kFakeUpdateURL("http:://fake.update/url"); 3040 const GURL kFakeUpdateURL("http:://fake.update/url");
3029 const bool kFakeInstallSilently(true); 3041 const bool kFakeInstallSilently(true);
3030 const bool kFakeRemoteInstall(false); 3042 const bool kFakeRemoteInstall(false);
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
3629 base::RunLoop().RunUntilIdle(); 3641 base::RunLoop().RunUntilIdle();
3630 3642
3631 // good0 re-enabled, other remain as they were. 3643 // good0 re-enabled, other remain as they were.
3632 EXPECT_TRUE(enabled_extensions.Contains(good0)); 3644 EXPECT_TRUE(enabled_extensions.Contains(good0));
3633 EXPECT_FALSE(disabled_extensions.Contains(good0)); 3645 EXPECT_FALSE(disabled_extensions.Contains(good0));
3634 EXPECT_FALSE(enabled_extensions.Contains(good1)); 3646 EXPECT_FALSE(enabled_extensions.Contains(good1));
3635 EXPECT_TRUE(disabled_extensions.Contains(good1)); 3647 EXPECT_TRUE(disabled_extensions.Contains(good1));
3636 EXPECT_TRUE(enabled_extensions.Contains(good2)); 3648 EXPECT_TRUE(enabled_extensions.Contains(good2));
3637 EXPECT_FALSE(disabled_extensions.Contains(good2)); 3649 EXPECT_FALSE(disabled_extensions.Contains(good2));
3638 } 3650 }
3651
3652 // Tests that blacklisted extensions cannot be reloaded, both those loaded
3653 // before and after extension service startup.
3654 TEST_F(ExtensionServiceTest, ReloadBlacklistedExtension) {
3655 extensions::TestBlacklist test_blacklist;
3656
3657 InitializeGoodInstalledExtensionService();
3658 test_blacklist.Attach(service_->blacklist_);
3659
3660 test_blacklist.SetBlacklistState(
3661 good1, extensions::BLACKLISTED_MALWARE, false);
3662 service_->Init();
3663 test_blacklist.SetBlacklistState(
3664 good2, extensions::BLACKLISTED_MALWARE, false);
3665 base::RunLoop().RunUntilIdle();
3666
3667 EXPECT_EQ(StringSet(good0), registry_->enabled_extensions().GetIDs());
3668 EXPECT_EQ(StringSet(good1, good2),
3669 registry_->blacklisted_extensions().GetIDs());
3670
3671 service_->ReloadExtension(good1);
3672 service_->ReloadExtension(good2);
3673 base::RunLoop().RunUntilIdle();
3674
3675 EXPECT_EQ(StringSet(good0), registry_->enabled_extensions().GetIDs());
3676 EXPECT_EQ(StringSet(good1, good2),
3677 registry_->blacklisted_extensions().GetIDs());
3678 }
3679
3639 #endif // defined(ENABLE_BLACKLIST_TESTS) 3680 #endif // defined(ENABLE_BLACKLIST_TESTS)
3640 3681
3641 // Will not install extension blacklisted by policy. 3682 // Will not install extension blacklisted by policy.
3642 TEST_F(ExtensionServiceTest, BlacklistedByPolicyWillNotInstall) { 3683 TEST_F(ExtensionServiceTest, BlacklistedByPolicyWillNotInstall) {
3643 InitializeEmptyExtensionService(); 3684 InitializeEmptyExtensionService();
3644 3685
3645 // Blacklist everything. 3686 // Blacklist everything.
3646 { 3687 {
3647 ListPrefUpdate update(profile_->GetPrefs(), 3688 ListPrefUpdate update(profile_->GetPrefs(),
3648 extensions::pref_names::kInstallDenyList); 3689 extensions::pref_names::kInstallDenyList);
(...skipping 3318 matching lines...) Expand 10 before | Expand all | Expand 10 after
6967 7008
6968 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 7009 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
6969 content::Source<Profile>(profile_.get()), 7010 content::Source<Profile>(profile_.get()),
6970 content::NotificationService::NoDetails()); 7011 content::NotificationService::NoDetails());
6971 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 7012 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
6972 EXPECT_EQ(0u, registry_->enabled_extensions().size()); 7013 EXPECT_EQ(0u, registry_->enabled_extensions().size());
6973 EXPECT_EQ(0u, registry_->disabled_extensions().size()); 7014 EXPECT_EQ(0u, registry_->disabled_extensions().size());
6974 EXPECT_EQ(0u, registry_->terminated_extensions().size()); 7015 EXPECT_EQ(0u, registry_->terminated_extensions().size());
6975 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); 7016 EXPECT_EQ(0u, registry_->blacklisted_extensions().size());
6976 } 7017 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698