| OLD | NEW |
| 1 <script src="common.js"></script> |
| 1 <script> | 2 <script> |
| 2 // This tests that the management install and uninstall functions work | 3 // This tests the webstorePrivate beginInstall and completeInstall functions. |
| 3 // properly when called by the gallery. Additionally, it implicitly tests | |
| 4 // that the install() function, when called from the gallery, avoids the | |
| 5 // dangerous download prompt and the extension permissions install prompt. | |
| 6 // If either were to appear, this test wouldn't complete. | |
| 7 // Note that for the purposes of this test the gallery url is "www.a.com" | |
| 8 // which is set in extension_gallery_install_apitest.cc. | |
| 9 | 4 |
| 10 var id = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 5 // Register a listener for when the install is completed. |
| 6 chrome.management.onInstalled.addListener(function(info) { |
| 7 assertEq(info.id, extension_id); |
| 8 succeed(); |
| 9 }); |
| 11 | 10 |
| 12 function checkInstalled(callback) { | 11 // Make sure our extension isn't yet installed. |
| 13 chrome.management.getAll(function(extensions) { | 12 checkInstalled(function(installed) { |
| 14 var found = false; | 13 assertEq(false, installed); |
| 15 extensions.forEach(function(extension) { | |
| 16 if (id == extension.id) | |
| 17 found = true; | |
| 18 }); | |
| 19 | |
| 20 callback(found); | |
| 21 }); | |
| 22 } | |
| 23 | 14 |
| 24 // Make sure our "gallery" extension isn't yet installed. | 15 // Begin installing. |
| 25 checkInstalled(function(installed) { | 16 chrome.webstorePrivate.beginInstall(extension_id, function() { |
| 26 chrome.test.assertEq(false, installed); | 17 assertNoLastError(); |
| 27 | 18 |
| 28 // Install "gallery" extensions. | 19 // Now complete the installation. |
| 29 chrome.management.onInstalled.addListener(function(info) { | 20 chrome.webstorePrivate.completeInstall(extension_id, function() { |
| 30 chrome.test.assertEq(id, info.id); | 21 assertNoLastError(); |
| 31 console.log("Installed " + info.id); | |
| 32 | |
| 33 // Double check it is installed. | |
| 34 checkInstalled(function(installed) { | |
| 35 chrome.test.assertEq(true, installed); | |
| 36 | |
| 37 // Now uninstall | |
| 38 chrome.management.onUninstalled.addListener(function() { | |
| 39 // And check that it's gone. | |
| 40 checkInstalled(function(installed) { | |
| 41 chrome.test.assertEq(false, installed); | |
| 42 | |
| 43 chrome.test.succeed(); | |
| 44 }); | |
| 45 }); | |
| 46 | |
| 47 console.log("Uninstalling..."); | |
| 48 chrome.management.uninstall(id, function() { | |
| 49 chrome.test.assertNoLastError(); | |
| 50 }); | |
| 51 }); | 22 }); |
| 52 }); | 23 }); |
| 53 chrome.webstorePrivate.install(id, function() { | |
| 54 chrome.test.assertNoLastError(); | |
| 55 }); | |
| 56 console.log("Installing..."); | |
| 57 }); | 24 }); |
| 58 </script> | 25 </script> |
| OLD | NEW |