summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_management_api_browsertest.cc
diff options
context:
space:
mode:
authormitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-01 23:01:12 +0000
committermitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-01 23:01:12 +0000
commit1740711d70adabe4a662362b366e33e9a53de643 (patch)
tree20dad9a285c024f598a7e066bb764acf36b97140 /chrome/browser/extensions/extension_management_api_browsertest.cc
parent394bd2e5dbeb4cf09005027a257395a9af9ddce2 (diff)
downloadchromium_src-1740711d70adabe4a662362b366e33e9a53de643.zip
chromium_src-1740711d70adabe4a662362b366e33e9a53de643.tar.gz
chromium_src-1740711d70adabe4a662362b366e33e9a53de643.tar.bz2
Add a management.uninstallWithDialog function
Added a boolean arg to management.uninstall (true = show dialog; defaults to false). Canceled uninstalls are reported to the developer via chrome.extension.lastError BUG=104352 TEST=ExtensionManagementTest.UninstallWithConfirmDialog Review URL: https://chromiumcodereview.appspot.com/9802021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_management_api_browsertest.cc')
-rw-r--r--chrome/browser/extensions/extension_management_api_browsertest.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_management_api_browsertest.cc b/chrome/browser/extensions/extension_management_api_browsertest.cc
index 499fbe9..cb0207a 100644
--- a/chrome/browser/extensions/extension_management_api_browsertest.cc
+++ b/chrome/browser/extensions/extension_management_api_browsertest.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/scoped_temp_dir.h"
+#include "base/string_util.h"
#include "base/stringprintf.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
@@ -70,6 +71,45 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest,
ASSERT_TRUE(listener1.WaitUntilSatisfied());
}
+IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest,
+ UninstallWithConfirmDialog) {
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+
+ // Install an extension.
+ const extensions::Extension* extension = InstallExtension(
+ test_data_dir_.AppendASCII("api_test/management/enabled_extension"), 1);
+ ASSERT_TRUE(extension);
+
+ const std::string id = extension->id();
+
+ // Uninstall, then cancel via the confirm dialog.
+ scoped_refptr<UninstallFunction> uninstall_function(new UninstallFunction());
+ UninstallFunction::SetAutoConfirmForTest(false);
+
+ EXPECT_TRUE(MatchPattern(
+ util::RunFunctionAndReturnError(
+ uninstall_function,
+ base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]",
+ id.c_str()),
+ browser()),
+ keys::kUninstallCanceledError));
+
+ // Make sure the extension wasn't uninstalled.
+ EXPECT_TRUE(service->GetExtensionById(id, false) != NULL);
+
+ // Uninstall, then accept via the confirm dialog.
+ uninstall_function = new UninstallFunction();
+ UninstallFunction::SetAutoConfirmForTest(true);
+
+ util::RunFunctionAndReturnResult(
+ uninstall_function,
+ base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()),
+ browser());
+
+ // Make sure the extension was uninstalled.
+ EXPECT_TRUE(service->GetExtensionById(id, false) == NULL);
+}
+
class ExtensionManagementApiEscalationTest : public ExtensionBrowserTest {
protected:
// The id of the permissions escalation test extension we use.