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

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

Issue 2136173002: Make sure Shared Modules cannot be disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 6758 matching lines...) Expand 10 before | Expand all | Expand 10 after
6769 EXPECT_TRUE(registry()->blacklisted_extensions().Contains(id)); 6769 EXPECT_TRUE(registry()->blacklisted_extensions().Contains(id));
6770 EXPECT_TRUE(ExtensionPrefs::Get(profile())->IsExtensionBlacklisted(id)); 6770 EXPECT_TRUE(ExtensionPrefs::Get(profile())->IsExtensionBlacklisted(id));
6771 6771
6772 service()->DisableExtension(id, Extension::DISABLE_USER_ACTION); 6772 service()->DisableExtension(id, Extension::DISABLE_USER_ACTION);
6773 EXPECT_FALSE(registry()->enabled_extensions().Contains(id)); 6773 EXPECT_FALSE(registry()->enabled_extensions().Contains(id));
6774 EXPECT_FALSE(registry()->disabled_extensions().Contains(id)); 6774 EXPECT_FALSE(registry()->disabled_extensions().Contains(id));
6775 EXPECT_TRUE(registry()->blacklisted_extensions().Contains(id)); 6775 EXPECT_TRUE(registry()->blacklisted_extensions().Contains(id));
6776 EXPECT_TRUE(ExtensionPrefs::Get(profile())->IsExtensionBlacklisted(id)); 6776 EXPECT_TRUE(ExtensionPrefs::Get(profile())->IsExtensionBlacklisted(id));
6777 } 6777 }
6778 6778
6779 // Test that calls to disable Shared Modules do not work.
6780 TEST_F(ExtensionServiceTest, CannotDisableSharedModules) {
6781 InitializeEmptyExtensionService();
6782 std::unique_ptr<base::DictionaryValue> manifest =
6783 extensions::DictionaryBuilder()
6784 .Set("name", "Shared Module")
6785 .Set("version", "1.0")
6786 .Set("manifest_version", 2)
6787 .Set("export",
6788 extensions::DictionaryBuilder()
6789 .Set("resources",
6790 extensions::ListBuilder().Append("foo.js").Build())
6791 .Build())
6792 .Build();
6793
6794 scoped_refptr<Extension> extension = extensions::ExtensionBuilder()
6795 .SetManifest(std::move(manifest))
6796 .AddFlags(Extension::FROM_WEBSTORE)
6797 .Build();
6798
6799 service()->OnExtensionInstalled(extension.get(), syncer::StringOrdinal(),
6800 extensions::kInstallFlagInstallImmediately);
6801
6802 ASSERT_TRUE(registry()->enabled_extensions().Contains(extension->id()));
6803 // Try to disable the extension.
6804 service()->DisableExtension(extension->id(), Extension::DISABLE_USER_ACTION);
6805 // Shared Module should still be enabled.
6806 EXPECT_TRUE(registry()->enabled_extensions().Contains(extension->id()));
6807 }
6808
6779 // Make sure we can uninstall a blacklisted extension 6809 // Make sure we can uninstall a blacklisted extension
6780 TEST_F(ExtensionServiceTest, UninstallBlacklistedExtension) { 6810 TEST_F(ExtensionServiceTest, UninstallBlacklistedExtension) {
6781 InitializeGoodInstalledExtensionService(); 6811 InitializeGoodInstalledExtensionService();
6782 service()->Init(); 6812 service()->Init();
6783 ASSERT_FALSE(registry()->enabled_extensions().is_empty()); 6813 ASSERT_FALSE(registry()->enabled_extensions().is_empty());
6784 6814
6785 // Blacklist the first extension; then try uninstalling it. 6815 // Blacklist the first extension; then try uninstalling it.
6786 std::string id = (*(registry()->enabled_extensions().begin()))->id(); 6816 std::string id = (*(registry()->enabled_extensions().begin()))->id();
6787 service()->BlacklistExtensionForTest(id); 6817 service()->BlacklistExtensionForTest(id);
6788 EXPECT_NE(nullptr, registry()->GetInstalledExtension(id)); 6818 EXPECT_NE(nullptr, registry()->GetInstalledExtension(id));
(...skipping 17 matching lines...) Expand all
6806 6836
6807 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 6837 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
6808 content::Source<Profile>(profile()), 6838 content::Source<Profile>(profile()),
6809 content::NotificationService::NoDetails()); 6839 content::NotificationService::NoDetails());
6810 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 6840 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
6811 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 6841 EXPECT_EQ(0u, registry()->enabled_extensions().size());
6812 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 6842 EXPECT_EQ(0u, registry()->disabled_extensions().size());
6813 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 6843 EXPECT_EQ(0u, registry()->terminated_extensions().size());
6814 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 6844 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
6815 } 6845 }
OLDNEW
« 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