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

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

Issue 9222013: Prevent unnecessary prompts when unpacked extensions use chrome.permissions.request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reword comment Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
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 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 fail = chrome.test.callbackFail; 8 var fail = chrome.test.callbackFail;
9 var pass = chrome.test.callbackPass; 9 var pass = chrome.test.callbackPass;
10 var listenOnce = chrome.test.listenOnce; 10 var listenOnce = chrome.test.listenOnce;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 assertTrue(granted); 148 assertTrue(granted);
149 chrome.windows.getAll({populate: true}, pass(function(windows) { 149 chrome.windows.getAll({populate: true}, pass(function(windows) {
150 assertTrue(true); 150 assertTrue(true);
151 })); 151 }));
152 chrome.permissions.getAll(pass(function(permissions) { 152 chrome.permissions.getAll(pass(function(permissions) {
153 assertTrue(checkPermSetsEq(permissionsWithTabs, permissions)); 153 assertTrue(checkPermSetsEq(permissionsWithTabs, permissions));
154 })); 154 }));
155 })); 155 }));
156 }, 156 },
157 157
158 // These permissions should be on the granted list because they're on the
159 // extension's default permission list.
160 function requestGrantedPermission() {
161 chrome.permissions.request(
162 {permissions: ['management'], origins: ['http://a.com/*']},
163 pass(function(granted) {
164 assertTrue(granted);
165 }));
166 },
167
158 // You can't remove required permissions. 168 // You can't remove required permissions.
159 function removeRequired() { 169 function removeRequired() {
160 chrome.permissions.remove( 170 chrome.permissions.remove(
161 {permissions: ['management']}, fail(REQUIRED_ERROR)); 171 {permissions: ['management']}, fail(REQUIRED_ERROR));
162 chrome.permissions.remove( 172 chrome.permissions.remove(
163 {origins: ['http://a.com/*']}, fail(REQUIRED_ERROR)); 173 {origins: ['http://a.com/*']}, fail(REQUIRED_ERROR));
164 chrome.permissions.remove( 174 chrome.permissions.remove(
165 {permissions: ['tabs'], origins: ['http://a.com/*']}, 175 {permissions: ['tabs'], origins: ['http://a.com/*']},
166 fail(REQUIRED_ERROR)); 176 fail(REQUIRED_ERROR));
167 }, 177 },
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 try { 307 try {
298 chrome.windows.getAll({populate: true}, function() { 308 chrome.windows.getAll({populate: true}, function() {
299 chrome.test.fail("Should not have tabs API permission."); 309 chrome.test.fail("Should not have tabs API permission.");
300 }); 310 });
301 } catch (e) { 311 } catch (e) {
302 assertTrue(e.message.indexOf(NO_TABS_PERMISSION) == 0); 312 assertTrue(e.message.indexOf(NO_TABS_PERMISSION) == 0);
303 } 313 }
304 }); 314 });
305 315
306 chrome.permissions.request( 316 chrome.permissions.request(
307 {permissions: ['tabs']}, pass(function(granted) { 317 {permissions: ['tabs', 'management']}, pass(function(granted) {
308 assertTrue(granted); 318 assertTrue(granted);
309 chrome.permissions.remove( 319 chrome.permissions.remove(
310 {permissions: ['tabs']}, pass(function() { 320 {permissions: ['tabs']}, pass(function() {
311 assertTrue(true); 321 assertTrue(true);
312 })); 322 }));
313 })); 323 }));
314 } 324 }
315 325
316 ]); 326 ]);
317 }); 327 });
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/test/data/extensions/api_test/permissions/optional_deny/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698