| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Tests where the beginInstallWithManifest dialog would be auto-accepted | 5 // Tests where the beginInstallWithManifest2 dialog would be auto-accepted |
| 6 // (including a few cases where this does not matter). | 6 // (including a few cases where this does not matter). |
| 7 | 7 |
| 8 var tests = [ | 8 var tests = [ |
| 9 | 9 |
| 10 function completeBeforeBegin() { | 10 function completeBeforeBegin() { |
| 11 var expectedError = | 11 var expectedError = |
| 12 extensionId + " does not match a previous call to beginInstall"; | 12 extensionId + " does not match a previous call to beginInstall"; |
| 13 chrome.webstorePrivate.completeInstall(extensionId, | 13 chrome.webstorePrivate.completeInstall(extensionId, |
| 14 callbackFail(expectedError)); | 14 callbackFail(expectedError)); |
| 15 }, | 15 }, |
| 16 | 16 |
| 17 function invalidID() { | 17 function invalidID() { |
| 18 var expectedError = "Invalid id"; | 18 var expectedError = "Invalid id"; |
| 19 var id = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"; | 19 var id = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"; |
| 20 chrome.webstorePrivate.beginInstallWithManifest( | 20 chrome.webstorePrivate.beginInstallWithManifest2( |
| 21 id, "", getManifest(), callbackFail(expectedError)); | 21 { 'id':id, 'manifest':getManifest() }, callbackFail(expectedError)); |
| 22 }, | 22 }, |
| 23 | 23 |
| 24 function missingVersion() { | 24 function missingVersion() { |
| 25 var manifestObj = JSON.parse(getManifest()); | 25 var manifestObj = JSON.parse(getManifest()); |
| 26 delete manifestObj["version"]; | 26 delete manifestObj["version"]; |
| 27 var manifest = JSON.stringify(manifestObj); | 27 var manifest = JSON.stringify(manifestObj); |
| 28 chrome.webstorePrivate.beginInstallWithManifest( | 28 chrome.webstorePrivate.beginInstallWithManifest2( |
| 29 extensionId, | 29 { 'id':extensionId, 'manifest': manifest }, |
| 30 "", | |
| 31 manifest, | |
| 32 callbackFail("Invalid manifest", function(result) { | 30 callbackFail("Invalid manifest", function(result) { |
| 33 assertEq("manifest_error", result); | 31 assertEq("manifest_error", result); |
| 34 })); | 32 })); |
| 35 }, | 33 }, |
| 36 | 34 |
| 37 function successfulInstall() { | 35 function successfulInstall() { |
| 38 // See things through all the way to a successful install, and then we | 36 // See things through all the way to a successful install. |
| 39 // uninstall the extension to clean up. | 37 listenOnce(chrome.management.onInstalled, callbackPass(function(info) { |
| 40 listenOnce(chrome.management.onInstalled, function(info) { | |
| 41 assertEq(info.id, extensionId); | 38 assertEq(info.id, extensionId); |
| 42 chrome.management.uninstall(extensionId, callbackPass()); | 39 })); |
| 43 }); | |
| 44 | 40 |
| 45 var manifest = getManifest(); | 41 var manifest = getManifest(); |
| 46 getIconData(function(icon) { | 42 getIconData(function(icon) { |
| 47 | 43 |
| 48 // Begin installing. | 44 // Begin installing. |
| 49 chrome.webstorePrivate.beginInstallWithManifest(extensionId, | 45 chrome.webstorePrivate.beginInstallWithManifest2( |
| 50 icon, | 46 {'id': extensionId,'iconData': icon, 'manifest': manifest }, |
| 51 manifest, | 47 function(result) { |
| 52 function(result) { | |
| 53 assertNoLastError(); | 48 assertNoLastError(); |
| 54 assertEq(result, ""); | 49 assertEq(result, ""); |
| 55 | 50 |
| 56 // Now complete the installation. | 51 // Now complete the installation. |
| 57 chrome.webstorePrivate.completeInstall(extensionId, function() { | 52 chrome.webstorePrivate.completeInstall(extensionId, callbackPass()); |
| 58 assertNoLastError(); | |
| 59 }); | |
| 60 }); | 53 }); |
| 61 }); | 54 }); |
| 62 } | 55 } |
| 63 ]; | 56 ]; |
| 64 | 57 |
| 65 runTests(tests); | 58 runTests(tests); |
| OLD | NEW |