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

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

Issue 4147007: Don't stomp on non-sync pending updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase for commit Created 10 years, 1 month 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/extensions_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/extensions_service_unittest.cc
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index bcb3f86f9112cbe54e4fa598b1e3f95661dd8331..dab980d201a7c780b9616deec8a0b020c3e13b46 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -1663,6 +1663,45 @@ TEST_F(ExtensionsServiceTest, UpdatePendingExternalCrx) {
EXPECT_FALSE(service_->IsIncognitoEnabled(extension));
}
+// Test updating a pending CRX as if the source is an external extension
+// with an update URL. The external update should overwrite a sync update,
+// but a sync update should not overwrite a non-sync update.
+TEST_F(ExtensionsServiceTest, UpdatePendingExternalCrxWinsOverSync) {
+ InitializeEmptyExtensionsService();
+
+ // Add a crx to be installed from the update mechanism.
+ service_->AddPendingExtensionFromSync(
+ kGoodId, GURL(kGoodUpdateURL), kCrxTypeExtension,
+ kGoodInstallSilently, kGoodInitialState,
+ kGoodInitialIncognitoEnabled);
+
+ // Check that there is a pending crx, with is_from_sync set to true.
+ PendingExtensionMap::const_iterator it;
+ it = service_->pending_extensions().find(kGoodId);
+ ASSERT_TRUE(it != service_->pending_extensions().end());
+ EXPECT_TRUE(it->second.is_from_sync);
+
+ // Add a crx to be updated, with the same ID, from a non-sync source.
+ service_->AddPendingExtensionFromExternalUpdateUrl(
+ kGoodId, GURL(kGoodUpdateURL));
+
+ // Check that there is a pending crx, with is_from_sync set to false.
+ it = service_->pending_extensions().find(kGoodId);
+ ASSERT_TRUE(it != service_->pending_extensions().end());
+ EXPECT_FALSE(it->second.is_from_sync);
+
+ // Add a crx to be installed from the update mechanism.
+ service_->AddPendingExtensionFromSync(
+ kGoodId, GURL(kGoodUpdateURL), kCrxTypeExtension,
+ kGoodInstallSilently, kGoodInitialState,
+ kGoodInitialIncognitoEnabled);
+
+ // Check that the external, non-sync update was not overridden.
+ it = service_->pending_extensions().find(kGoodId);
+ ASSERT_TRUE(it != service_->pending_extensions().end());
+ EXPECT_FALSE(it->second.is_from_sync);
+}
+
// Updating a theme should fail if the updater is explicitly told that
// the CRX is not a theme.
TEST_F(ExtensionsServiceTest, UpdatePendingCrxThemeMismatch) {
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698