| OLD | NEW | 
|   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  |   4  | 
|   5 var callback = chrome.test.callback; |   5 var callback = chrome.test.callback; | 
|   6  |   6  | 
|   7 // The names of the extensions to operate on, from their manifest.json files. |   7 // The names of the extensions to operate on, from their manifest.json files. | 
|   8 var ENABLED_NAME = 'enabled_extension'; |   8 var ENABLED_NAME = 'enabled_extension'; | 
|   9 var DISABLED_NAME = 'disabled_extension'; |   9 var DISABLED_NAME = 'disabled_extension'; | 
|  10 var UNINSTALL_NAME = 'enabled_extension'; |  10 var UNINSTALL_NAME = 'enabled_extension'; | 
|  11  |  11  | 
|  12 var EXPECTED_ERROR = 'Extension * cannot be modified by user'; |  12 var EXPECTED_ERROR = 'Extension * cannot be modified by user.'; | 
|  13  |  13  | 
|  14 // Given a list of extension items, finds the one with the given name. |  14 // Given a list of extension items, finds the one with the given name. | 
|  15 function findByName(items, name) { |  15 function findByName(items, name) { | 
|  16   var item; |  16   var item; | 
|  17   for (var i = 0; i < items.length; i++) { |  17   for (var i = 0; i < items.length; i++) { | 
|  18     item = items[i]; |  18     item = items[i]; | 
|  19     if (item.name == name) |  19     if (item.name == name) | 
|  20       break; |  20       break; | 
|  21   } |  21   } | 
|  22   if (name != item.name) |  22   if (name != item.name) | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  62   }, |  62   }, | 
|  63  |  63  | 
|  64   // Tests uninstalling an extension, expecting it to fail. |  64   // Tests uninstalling an extension, expecting it to fail. | 
|  65   function prohibitedUninstall() { |  65   function prohibitedUninstall() { | 
|  66     chrome.management.getAll(callback(function(items) { |  66     chrome.management.getAll(callback(function(items) { | 
|  67       var item = findByName(items, UNINSTALL_NAME); |  67       var item = findByName(items, UNINSTALL_NAME); | 
|  68       chrome.test.assertEq(false, item.mayDisable); |  68       chrome.test.assertEq(false, item.mayDisable); | 
|  69  |  69  | 
|  70       var id = item.id; |  70       var id = item.id; | 
|  71       var expectedError = EXPECTED_ERROR.replace('*', id); |  71       var expectedError = EXPECTED_ERROR.replace('*', id); | 
|  72       chrome.management.uninstall(id, |  72       chrome.test.runWithUserGesture(function() { | 
|  73           callback(function() { checkEnabled(id, true); }, expectedError)); |  73         chrome.management.uninstall(id, | 
 |  74             callback(function() { checkEnabled(id, true); }, expectedError)); | 
 |  75       }); | 
|  74     })); |  76     })); | 
|  75   } |  77   } | 
|  76 ]; |  78 ]; | 
|  77  |  79  | 
|  78 chrome.test.runTests(tests); |  80 chrome.test.runTests(tests); | 
| OLD | NEW |