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

Side by Side Diff: chrome/test/data/extensions/api_test/permissions/optional/background.js

Issue 2937333002: [Extensions Bindings] Update optional permissions tests (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var assertEq = chrome.test.assertEq; 5 var assertEq = chrome.test.assertEq;
6 var assertFalse = chrome.test.assertFalse; 6 var assertFalse = chrome.test.assertFalse;
7 var assertTrue = chrome.test.assertTrue; 7 var assertTrue = chrome.test.assertTrue;
8 var assertThrows = chrome.test.assertThrows; 8 var assertThrows = chrome.test.assertThrows;
9 var fail = chrome.test.callbackFail; 9 var fail = chrome.test.callbackFail;
10 var pass = chrome.test.callbackPass; 10 var pass = chrome.test.callbackPass;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 assertTrue(permissions.permissions[0] == 'bookmarks'); 189 assertTrue(permissions.permissions[0] == 'bookmarks');
190 }); 190 });
191 chrome.permissions.remove( 191 chrome.permissions.remove(
192 {permissions:['bookmarks']}, 192 {permissions:['bookmarks']},
193 pass(function() { 193 pass(function() {
194 chrome.permissions.getAll(pass(function(permissions) { 194 chrome.permissions.getAll(pass(function(permissions) {
195 assertTrue(checkPermSetsEq(initialPermissions, permissions)); 195 assertTrue(checkPermSetsEq(initialPermissions, permissions));
196 })); 196 }));
197 assertTrue(typeof chrome.bookmarks == 'object' && 197 assertTrue(typeof chrome.bookmarks == 'object' &&
198 chrome.bookmarks != null); 198 chrome.bookmarks != null);
199 assertThrows( 199 var nativeBindingsError =
200 chrome.bookmarks.getTree, [function(){}], 200 "'bookmarks.getTree' is not available in this context.";
201 "'bookmarks' requires a different Feature that is not present."); 201 var jsBindingsError =
202 "'bookmarks' requires a different Feature that is not present.";
203 var regexp =
204 new RegExp(nativeBindingsError + '|' + jsBindingsError);
205 assertThrows(chrome.bookmarks.getTree, [function(){}], regexp);
202 } 206 }
203 )); 207 ));
204 }, 208 },
205 209
206 // The user shouldn't have to approve permissions that have no warnings. 210 // The user shouldn't have to approve permissions that have no warnings.
207 function noPromptForNoWarnings() { 211 function noPromptForNoWarnings() {
208 chrome.permissions.request( 212 chrome.permissions.request(
209 {permissions: ['cookies']}, 213 {permissions: ['cookies']},
210 pass(function(granted) { 214 pass(function(granted) {
211 assertTrue(granted); 215 assertTrue(granted);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 listenOnce(chrome.permissions.onAdded, 292 listenOnce(chrome.permissions.onAdded,
289 function(permissions) { 293 function(permissions) {
290 chrome.bookmarks.getTree(pass(function() { 294 chrome.bookmarks.getTree(pass(function() {
291 assertTrue(true); 295 assertTrue(true);
292 })); 296 }));
293 }); 297 });
294 listenOnce(chrome.permissions.onRemoved, 298 listenOnce(chrome.permissions.onRemoved,
295 function(permissions) { 299 function(permissions) {
296 assertTrue(typeof chrome.bookmarks == 'object' && 300 assertTrue(typeof chrome.bookmarks == 'object' &&
297 chrome.bookmarks != null); 301 chrome.bookmarks != null);
298 assertThrows( 302 var nativeBindingsError =
299 chrome.bookmarks.getTree, [function(){}], 303 "'bookmarks.getTree' is not available in this context.";
300 "'bookmarks' requires a different Feature that is not present."); 304 var jsBindingsError =
305 "'bookmarks' requires a different Feature that is not present.";
306 var regexp = new RegExp(nativeBindingsError + '|' + jsBindingsError);
307 assertThrows(chrome.bookmarks.getTree, [function(){}], regexp);
301 }); 308 });
302 309
303 chrome.permissions.request( 310 chrome.permissions.request(
304 {permissions: ['bookmarks', 'management']}, pass(function(granted) { 311 {permissions: ['bookmarks', 'management']}, pass(function(granted) {
305 assertTrue(granted); 312 assertTrue(granted);
306 chrome.permissions.remove( 313 chrome.permissions.remove(
307 {permissions: ['bookmarks']}, pass(function() { 314 {permissions: ['bookmarks']}, pass(function() {
308 assertTrue(true); 315 assertTrue(true);
309 })); 316 }));
310 })); 317 }));
311 } 318 }
312 319
313 ]); 320 ]);
314 }); 321 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698