Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: chrome/test/data/extensions/api_test/management/test/basics.js

Issue 10825310: Add a 'type' property to ExtensionInfo (chrome.management). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: s/new_// Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 function checkIcon(item, size, path) { 5 function checkIcon(item, size, path) {
6 var icons = item.icons; 6 var icons = item.icons;
7 for (var i = 0; i < icons.length; i++) { 7 for (var i = 0; i < icons.length; i++) {
8 var icon = icons[i]; 8 var icon = icons[i];
9 if (icon.size == size) { 9 if (icon.size == size) {
10 var expected_url = 10 var expected_url =
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 } 41 }
42 fail("didn't find permission " + perm); 42 fail("didn't find permission " + perm);
43 } 43 }
44 44
45 var tests = [ 45 var tests = [
46 function simple() { 46 function simple() {
47 chrome.management.getAll(callback(function(items) { 47 chrome.management.getAll(callback(function(items) {
48 chrome.test.assertEq(10, items.length); 48 chrome.test.assertEq(10, items.length);
49 49
50 checkItemInList(items, "Extension Management API Test", true, false); 50 checkItemInList(items, "Extension Management API Test", true,
51 checkItemInList(items, "description", true, false, 51 "extension");
52 checkItemInList(items, "description", true, "extension",
52 { "description": "a short description" }); 53 { "description": "a short description" });
53 checkItemInList(items, "enabled_app", true, true, 54 checkItemInList(items, "enabled_app", true, "hosted_app",
54 { "appLaunchUrl": "http://www.google.com/", 55 { "appLaunchUrl": "http://www.google.com/",
55 "offlineEnabled": true, 56 "offlineEnabled": true,
56 "updateUrl": "http://example.com/update.xml" }); 57 "updateUrl": "http://example.com/update.xml" });
57 checkItemInList(items, "disabled_app", false, true, 58 checkItemInList(items, "disabled_app", false, "hosted_app",
58 { "disabledReason": "unknown" }); 59 { "disabledReason": "unknown" });
59 checkItemInList(items, "enabled_extension", true, false, 60 checkItemInList(items, "enabled_extension", true, "extension",
60 { "homepageUrl": "http://example.com/" }); 61 { "homepageUrl": "http://example.com/" });
61 checkItemInList(items, "disabled_extension", false, false, 62 checkItemInList(items, "disabled_extension", false, "extension",
62 { "optionsUrl": "chrome-extension://<ID>/pages/options.html", 63 { "optionsUrl": "chrome-extension://<ID>/pages/options.html",
63 "disabledReason": "unknown" }); 64 "disabledReason": "unknown" });
64 checkItemInList(items, "description", true, false, 65 checkItemInList(items, "description", true, "extension",
65 { "installType": "development" }); 66 { "installType": "development" });
66 checkItemInList(items, "internal_extension", true, false, 67 checkItemInList(items, "internal_extension", true, "extension",
67 { "installType": "normal" }); 68 { "installType": "normal" });
68 checkItemInList(items, "external_extension", true, false, 69 checkItemInList(items, "external_extension", true, "extension",
69 { "installType": "sideload" }); 70 { "installType": "sideload" });
70 checkItemInList(items, "admin_extension", true, false, 71 checkItemInList(items, "admin_extension", true, "extension",
71 { "installType": "admin" }); 72 { "installType": "admin" });
72 73
73 // Check that we got the icons correctly 74 // Check that we got the icons correctly
74 var extension = getItemNamed(items, "enabled_extension"); 75 var extension = getItemNamed(items, "enabled_extension");
75 assertEq(3, extension.icons.length); 76 assertEq(3, extension.icons.length);
76 checkIcon(extension, 128, "icon_128.png"); 77 checkIcon(extension, 128, "icon_128.png");
77 checkIcon(extension, 48, "icon_48.png"); 78 checkIcon(extension, 48, "icon_48.png");
78 checkIcon(extension, 16, "icon_16.png"); 79 checkIcon(extension, 16, "icon_16.png");
79 80
80 // Check that we can retrieve this extension by ID. 81 // Check that we can retrieve this extension by ID.
81 chrome.management.get(extension.id, callback(function(same_extension) { 82 chrome.management.get(extension.id, callback(function(same_extension) {
82 checkItem(same_extension, extension.name, extension.enabled, 83 checkItem(same_extension, extension.name, extension.enabled,
83 extension.isApp, extension.additional_properties); 84 extension.type, extension.additional_properties);
84 })); 85 }));
85 86
86 // Check that we have a permission defined. 87 // Check that we have a permission defined.
87 var testExtension = getItemNamed(items, "Extension Management API Test"); 88 var testExtension = getItemNamed(items, "Extension Management API Test");
88 checkPermission(testExtension, "management"); 89 checkPermission(testExtension, "management");
89 90
90 var permExtension = getItemNamed(items, "permissions"); 91 var permExtension = getItemNamed(items, "permissions");
91 checkPermission(permExtension, "unlimitedStorage"); 92 checkPermission(permExtension, "unlimitedStorage");
92 checkPermission(permExtension, "notifications"); 93 checkPermission(permExtension, "notifications");
93 checkHostPermission(permExtension, "http://*/*"); 94 checkHostPermission(permExtension, "http://*/*");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 }, 128 },
128 129
129 // Disables an enabled app. 130 // Disables an enabled app.
130 function disable() { 131 function disable() {
131 listenOnce(chrome.management.onDisabled, function(info) { 132 listenOnce(chrome.management.onDisabled, function(info) {
132 assertEq(info.name, "enabled_app"); 133 assertEq(info.name, "enabled_app");
133 }); 134 });
134 135
135 chrome.management.getAll(callback(function(items) { 136 chrome.management.getAll(callback(function(items) {
136 var enabled_app = getItemNamed(items, "enabled_app"); 137 var enabled_app = getItemNamed(items, "enabled_app");
137 checkItem(enabled_app, "enabled_app", true, true); 138 checkItem(enabled_app, "enabled_app", true, "hosted_app");
138 chrome.management.setEnabled(enabled_app.id, false, callback(function() { 139 chrome.management.setEnabled(enabled_app.id, false, callback(function() {
139 chrome.management.get(enabled_app.id, callback(function(now_disabled) { 140 chrome.management.get(enabled_app.id, callback(function(now_disabled) {
140 checkItem(now_disabled, "enabled_app", false, true); 141 checkItem(now_disabled, "enabled_app", false, "hosted_app");
141 })); 142 }));
142 })); 143 }));
143 })); 144 }));
144 }, 145 },
145 146
146 // Enables a disabled extension. 147 // Enables a disabled extension.
147 function enable() { 148 function enable() {
148 listenOnce(chrome.management.onEnabled, function(info) { 149 listenOnce(chrome.management.onEnabled, function(info) {
149 assertEq(info.name, "disabled_extension"); 150 assertEq(info.name, "disabled_extension");
150 }); 151 });
151 chrome.management.getAll(callback(function(items) { 152 chrome.management.getAll(callback(function(items) {
152 var disabled = getItemNamed(items, "disabled_extension"); 153 var disabled = getItemNamed(items, "disabled_extension");
153 checkItem(disabled, "disabled_extension", false, false); 154 checkItem(disabled, "disabled_extension", false, "extension");
154 chrome.management.setEnabled(disabled.id, true, callback(function() { 155 chrome.management.setEnabled(disabled.id, true, callback(function() {
155 chrome.management.get(disabled.id, callback(function(now_enabled) { 156 chrome.management.get(disabled.id, callback(function(now_enabled) {
156 checkItem(now_enabled, "disabled_extension", true, false); 157 checkItem(now_enabled, "disabled_extension", true, "extension");
157 })); 158 }));
158 })); 159 }));
159 })); 160 }));
160 } 161 }
161 ]; 162 ];
162 163
163 chrome.test.runTests(tests); 164 chrome.test.runTests(tests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698