- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / webstore_private / accepted.js
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.
4
5 // Tests where the beginInstallWithManifest3 dialog would be auto-accepted
6 // (including a few cases where this does not matter).
7
8 var tests = [
9
10   function completeBeforeBegin() {
11     var expectedError = extensionId +
12         " does not match a previous call to beginInstallWithManifest3";
13     chrome.webstorePrivate.completeInstall(extensionId,
14                                            callbackFail(expectedError));
15   },
16
17   function invalidID() {
18     var expectedError = "Invalid id";
19     var id = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
20     chrome.webstorePrivate.beginInstallWithManifest3(
21         { 'id':id, 'manifest':getManifest() }, callbackFail(expectedError));
22   },
23
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);
32     }));
33   },
34
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);
39     });
40
41     var manifest = getManifest();
42     getIconData(function(icon) {
43         installAndCleanUp(
44             {'id': extensionId, 'iconData': icon, 'manifest': manifest},
45             function() {});
46     });
47   },
48
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);
53     });
54
55     var manifest = getManifest();
56     getIconData(function(icon) {
57         installAndCleanUp(
58             {'id': extensionId, 'iconData': icon, 'manifest': manifest},
59             function() {
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));
65             });
66
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));
72     });
73   }
74 ];
75
76 runTests(tests);