summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 22:53:50 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 22:53:50 +0000
commit1e81a3485960cf7593e6cfc389dbe56b72d52821 (patch)
tree20eff51c4747ca630272f88f237aaa8264da6700 /chrome/browser/extensions/extension_disabled_ui_browsertest.cc
parent1ca52a3ad58d6f7bfc3a12922491ae7908c97a02 (diff)
downloadchromium_src-1e81a3485960cf7593e6cfc389dbe56b72d52821.zip
chromium_src-1e81a3485960cf7593e6cfc389dbe56b72d52821.tar.gz
chromium_src-1e81a3485960cf7593e6cfc389dbe56b72d52821.tar.bz2
Delay determination of why a synced disabled extension was disabled.
Also simplify handling of legacy disabled extensions. BUG=162062 Review URL: https://chromiumcodereview.appspot.com/11412239 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_disabled_ui_browsertest.cc')
-rw-r--r--chrome/browser/extensions/extension_disabled_ui_browsertest.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
index f2fea19..1f88dd9 100644
--- a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
+++ b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
@@ -5,20 +5,30 @@
#include "base/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/extensions/autoupdate_interceptor.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/global_error/global_error.h"
#include "chrome/browser/ui/global_error/global_error_service.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
+#include "net/url_request/url_fetcher.h"
using extensions::Extension;
class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest {
protected:
+ void SetUpCommandLine(CommandLine* command_line) {
+ ExtensionBrowserTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL,
+ "http://localhost/autoupdate/updates.xml");
+ }
+
void SetUpOnMainThread() {
EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
service_ = browser()->profile()->GetExtensionService();
@@ -161,3 +171,49 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
ASSERT_TRUE(extension);
ASSERT_TRUE(GetExtensionDisabledGlobalError());
}
+
+// Test that an error appears if the extension gets disabled because a
+// version with higher permissions was installed by sync.
+IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
+ HigherPermissionsFromSync) {
+ // Get data for extension v2 (disabled) into sync.
+ const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension();
+ std::string extension_id = extension->id();
+ // service_->GrantPermissionsAndEnableExtension(extension, false);
+ extensions::ExtensionSyncData sync_data =
+ service_->GetExtensionSyncData(*extension);
+ UninstallExtension(extension_id);
+ extension = NULL;
+
+ // Install extension v1.
+ InstallIncreasingPermissionExtensionV1();
+
+ // Note: This interceptor gets requests on the IO thread.
+ scoped_refptr<extensions::AutoUpdateInterceptor> interceptor(
+ new extensions::AutoUpdateInterceptor());
+ net::URLFetcher::SetEnableInterceptionForTests(true);
+ interceptor->SetResponseOnIOThread(
+ "http://localhost/autoupdate/updates.xml",
+ test_data_dir_.AppendASCII("permissions_increase")
+ .AppendASCII("updates.xml"));
+ interceptor->SetResponseOnIOThread(
+ "http://localhost/autoupdate/v2.crx",
+ scoped_temp_dir_.path().AppendASCII("permissions2.crx"));
+
+ extensions::ExtensionUpdater::CheckParams params;
+ params.check_blacklist = false;
+ service_->updater()->set_default_check_params(params);
+
+ // Sync is replacing an older version, so it pends.
+ EXPECT_FALSE(service_->ProcessExtensionSyncData(sync_data));
+
+ WaitForExtensionInstall();
+
+ extension = service_->GetExtensionById(extension_id, true);
+ ASSERT_TRUE(extension);
+ EXPECT_EQ("2", extension->VersionString());
+ EXPECT_EQ(1u, service_->disabled_extensions()->size());
+ EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE,
+ service_->extension_prefs()->GetDisableReasons(extension_id));
+ EXPECT_TRUE(GetExtensionDisabledGlobalError());
+}