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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4
5 var EXPECTED_ERROR = 'chrome.management.uninstall requires a user gesture.';
6
4 function uninstall(name) { 7 function uninstall(name) {
5 var expected_id; 8 var expected_id;
6 listenOnce(chrome.management.onUninstalled, function(id) { 9 listenOnce(chrome.management.onUninstalled, function(id) {
7 assertEq(expected_id, id); 10 assertEq(expected_id, id);
8 }); 11 });
9 12
10 chrome.management.getAll(callback(function(items) { 13 chrome.management.getAll(callback(function(items) {
11 var old_count = items.length; 14 var old_count = items.length;
12 var item = getItemNamed(items, name); 15 var item = getItemNamed(items, name);
13 expected_id = item.id; 16 expected_id = item.id;
17 chrome.test.runWithUserGesture(function() {
18 chrome.management.uninstall(item.id, callback(function() {
19 chrome.management.getAll(callback(function(items2) {
20 assertEq(old_count - 1, items2.length);
21 for (var i = 0; i < items2.length; i++) {
22 assertFalse(items2[i].name == name);
23 }
24 }));
25 }));
26 });
27 }));
28 }
29
30 function uninstallWithoutUserGesture(name) {
31 chrome.management.getAll(callback(function(items) {
32 var old_count = items.length;
33 var item = getItemNamed(items, name);
14 chrome.management.uninstall(item.id, callback(function() { 34 chrome.management.uninstall(item.id, callback(function() {
15 chrome.management.getAll(callback(function(items2) { 35 chrome.management.getAll(callback(function(items2) {
16 assertEq(old_count - 1, items2.length); 36 assertEq(old_count, items2.length);
17 for (var i = 0; i < items2.length; i++) {
18 assertFalse(items2[i].name == name);
19 }
20 })); 37 }));
21 })); 38 }, EXPECTED_ERROR));
22 })); 39 }));
23 } 40 }
24 41
25 var tests = [ 42 var tests = [
43
44 function uninstallEnabledAppWithoutUserGesture() {
45 uninstallWithoutUserGesture("enabled_app");
46 },
47
26 function uninstallEnabledApp() { 48 function uninstallEnabledApp() {
27 uninstall("enabled_app"); 49 uninstall("enabled_app");
28 }, 50 },
29 51
30 function uninstallDisabledApp() { 52 function uninstallDisabledApp() {
31 uninstall("disabled_app"); 53 uninstall("disabled_app");
32 }, 54 },
33 55
34 function uninstallEnabledExtension() { 56 function uninstallEnabledExtension() {
35 uninstall("enabled_extension"); 57 uninstall("enabled_extension");
36 }, 58 },
37 59
38 function uninstallDisabledExtension() { 60 function uninstallDisabledExtension() {
39 uninstall("disabled_extension"); 61 uninstall("disabled_extension");
40 } 62 }
41 ]; 63 ];
42 64
43 chrome.test.runTests(tests); 65 chrome.test.runTests(tests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698