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

Unified Diff: chrome/test/data/extensions/api_test/management/test/uninstall.js

Issue 137793011: Require user confirmation for chrome.management.uninstall except when uninstalling self. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ExtensionManagementApiBrowserTest.LaunchApp Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/management/test/uninstall.js
diff --git a/chrome/test/data/extensions/api_test/management/test/uninstall.js b/chrome/test/data/extensions/api_test/management/test/uninstall.js
index 252291dbef64ace5f779faf2fee52965e78f4d4c..7875d7ae85c50596a2d388b6217e07d284f9f8d5 100644
--- a/chrome/test/data/extensions/api_test/management/test/uninstall.js
+++ b/chrome/test/data/extensions/api_test/management/test/uninstall.js
@@ -1,6 +1,9 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
+var EXPECTED_ERROR = 'chrome.management.uninstall requires a user gesture.';
+
function uninstall(name) {
var expected_id;
listenOnce(chrome.management.onUninstalled, function(id) {
@@ -11,18 +14,37 @@ function uninstall(name) {
var old_count = items.length;
var item = getItemNamed(items, name);
expected_id = item.id;
+ chrome.test.runWithUserGesture(function() {
+ chrome.management.uninstall(item.id, callback(function() {
+ chrome.management.getAll(callback(function(items2) {
+ assertEq(old_count - 1, items2.length);
+ for (var i = 0; i < items2.length; i++) {
+ assertFalse(items2[i].name == name);
+ }
+ }));
+ }));
+ });
+ }));
+}
+
+function uninstallWithoutUserGesture(name) {
+ chrome.management.getAll(callback(function(items) {
+ var old_count = items.length;
+ var item = getItemNamed(items, name);
chrome.management.uninstall(item.id, callback(function() {
chrome.management.getAll(callback(function(items2) {
- assertEq(old_count - 1, items2.length);
- for (var i = 0; i < items2.length; i++) {
- assertFalse(items2[i].name == name);
- }
+ assertEq(old_count, items2.length);
}));
- }));
+ }, EXPECTED_ERROR));
}));
}
var tests = [
+
+ function uninstallEnabledAppWithoutUserGesture() {
+ uninstallWithoutUserGesture("enabled_app");
+ },
+
function uninstallEnabledApp() {
uninstall("enabled_app");
},

Powered by Google App Engine
This is Rietveld 408576698