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"); |
}, |