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

Side by Side Diff: chrome/renderer/resources/extensions/apitest.js

Issue 10815028: Make ActiveTabPermissionManager also grant the tabs permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops 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 | Annotate | Revision Log
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 // extension_apitest.js 5 // extension_apitest.js
6 // mini-framework for ExtensionApiTest browser tests 6 // mini-framework for ExtensionApiTest browser tests
7 7
8 chrome.test = chrome.test || {}; 8 chrome.test = chrome.test || {};
9 9
10 chrome.test.tests = chrome.test.tests || []; 10 chrome.test.tests = chrome.test.tests || [];
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 }; 183 };
184 184
185 chrome.test.assertNoLastError = function() { 185 chrome.test.assertNoLastError = function() {
186 if (chrome.runtime.lastError != undefined) { 186 if (chrome.runtime.lastError != undefined) {
187 chrome.test.fail("lastError.message == " + 187 chrome.test.fail("lastError.message == " +
188 chrome.runtime.lastError.message); 188 chrome.runtime.lastError.message);
189 } 189 }
190 }; 190 };
191 191
192 chrome.test.assertLastError = function(expectedError) {
193 chrome.test.assertEq(typeof(expectedError), 'string');
194 chrome.test.assertTrue(chrome.runtime.lastError != undefined,
195 "No lastError, but expected " + expectedError);
196 chrome.test.assertEq(expectedError, chrome.runtime.lastError.message);
197 }
198
192 function safeFunctionApply(func, arguments) { 199 function safeFunctionApply(func, arguments) {
193 try { 200 try {
194 if (func) 201 if (func)
195 func.apply(null, arguments); 202 func.apply(null, arguments);
196 } catch (e) { 203 } catch (e) {
197 var msg = "uncaught exception " + e; 204 var msg = "uncaught exception " + e;
198 chrome.test.fail(msg); 205 chrome.test.fail(msg);
199 } 206 }
200 }; 207 };
201 208
202 // Wrapper for generating test functions, that takes care of calling 209 // Wrapper for generating test functions, that takes care of calling
203 // assertNoLastError() and (optionally) succeed() for you. 210 // assertNoLastError() and (optionally) succeed() for you.
204 chrome.test.callback = function(func, expectedError) { 211 chrome.test.callback = function(func, expectedError) {
205 if (func) { 212 if (func) {
206 chrome.test.assertEq(typeof(func), 'function'); 213 chrome.test.assertEq(typeof(func), 'function');
207 } 214 }
208 var callbackCompleted = chrome.test.callbackAdded(); 215 var callbackCompleted = chrome.test.callbackAdded();
209 216
210 return function() { 217 return function() {
211 if (expectedError == null) { 218 if (expectedError == null) {
212 chrome.test.assertNoLastError(); 219 chrome.test.assertNoLastError();
213 } else { 220 } else {
214 chrome.test.assertEq(typeof(expectedError), 'string'); 221 chrome.test.assertLastError(expectedError);
215 chrome.test.assertTrue(chrome.runtime.lastError != undefined,
216 "No lastError, but expected " + expectedError);
217 chrome.test.assertEq(expectedError, chrome.runtime.lastError.message);
218 } 222 }
219 223
220 if (func) { 224 if (func) {
221 safeFunctionApply(func, arguments); 225 safeFunctionApply(func, arguments);
222 } 226 }
223 227
224 callbackCompleted(); 228 callbackCompleted();
225 }; 229 };
226 }; 230 };
227 231
(...skipping 29 matching lines...) Expand all
257 261
258 chrome.test.callbackFail = function(expectedError, func) { 262 chrome.test.callbackFail = function(expectedError, func) {
259 return chrome.test.callback(func, expectedError); 263 return chrome.test.callback(func, expectedError);
260 }; 264 };
261 265
262 chrome.test.runTests = function(tests) { 266 chrome.test.runTests = function(tests) {
263 chrome.test.tests = tests; 267 chrome.test.tests = tests;
264 testCount = chrome.test.tests.length; 268 testCount = chrome.test.tests.length;
265 chrome.test.runNextTest(); 269 chrome.test.runNextTest();
266 }; 270 };
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.cc ('k') | chrome/test/data/extensions/api_test/active_tab/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698