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
3 // found in the LICENSE file.
5 // Tests where the beginInstallWithManifest3 dialog would be auto-accepted
6 // (including a few cases where this does not matter).
10 function completeBeforeBegin() {
11 var expectedError = extensionId +
12 " does not match a previous call to beginInstallWithManifest3";
13 chrome.webstorePrivate.completeInstall(extensionId,
14 callbackFail(expectedError));
17 function invalidID() {
18 var expectedError = "Invalid id";
19 var id = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
20 chrome.webstorePrivate.beginInstallWithManifest3(
21 { 'id':id, 'manifest':getManifest() }, callbackFail(expectedError));
24 function missingVersion() {
25 var manifestObj = JSON.parse(getManifest());
26 delete manifestObj["version"];
27 var manifest = JSON.stringify(manifestObj);
28 chrome.webstorePrivate.beginInstallWithManifest3(
29 { 'id':extensionId, 'manifest': manifest },
30 callbackFail("Invalid manifest", function(result) {
31 assertEq("manifest_error", result);
35 function successfulInstall() {
36 // See things through all the way to a successful install.
37 listenOnce(chrome.management.onInstalled, function(info) {
38 assertEq(info.id, extensionId);
41 var manifest = getManifest();
42 getIconData(function(icon) {
44 {'id': extensionId, 'iconData': icon, 'manifest': manifest},
49 function duplicateInstall() {
50 // See things through all the way to a successful install.
51 listenOnce(chrome.management.onInstalled, function(info) {
52 assertEq(info.id, extensionId);
55 var manifest = getManifest();
56 getIconData(function(icon) {
58 {'id': extensionId, 'iconData': icon, 'manifest': manifest},
60 // Kick off a serial second install. This should fail.
61 var expectedError = "This item is already installed";
62 chrome.webstorePrivate.beginInstallWithManifest3(
63 {'id': extensionId, 'iconData': icon, 'manifest': manifest},
64 callbackFail(expectedError));
67 // Kick off a simultaneous second install. This should fail.
68 var expectedError = "This item is already installed";
69 chrome.webstorePrivate.beginInstallWithManifest3(
70 {'id': extensionId, 'iconData': icon, 'manifest': manifest},
71 callbackFail(expectedError));