OLD | NEW |
(Empty) | |
| 1 <script> |
| 2 // This tests that the management install and uninstall functions work |
| 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 |
| 10 var id = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; |
| 11 |
| 12 function checkInstalled(callback) { |
| 13 chrome.experimental.management.getAll(function(extensions) { |
| 14 var found = false; |
| 15 extensions.forEach(function(extension) { |
| 16 if (id == extension.id) |
| 17 found = true; |
| 18 }); |
| 19 |
| 20 callback(found); |
| 21 }); |
| 22 } |
| 23 |
| 24 // Make sure our "gallery" extension isn't yet installed. |
| 25 checkInstalled(function(installed) { |
| 26 chrome.test.assertEq(false, installed); |
| 27 |
| 28 // Install "gallery" extensions. |
| 29 chrome.experimental.management.onInstalled.addListener(function(info) { |
| 30 chrome.test.assertEq(id, info.id); |
| 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.experimental.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.experimental.management.uninstall(id, function() { |
| 49 chrome.test.assertNoLastError(); |
| 50 }); |
| 51 }); |
| 52 }); |
| 53 chrome.webstorePrivate.install(id, function() { |
| 54 chrome.test.assertNoLastError(); |
| 55 }); |
| 56 console.log("Installing..."); |
| 57 }); |
| 58 </script> |
OLD | NEW |