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

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

Issue 12218019: Check that callbackAdded callbacks are only called once. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« 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 // 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 27 matching lines...) Expand all
38 // Try to get the script to stop running immediately. 38 // Try to get the script to stop running immediately.
39 // This isn't an error, just an attempt at saying "done". 39 // This isn't an error, just an attempt at saying "done".
40 throw "completed"; 40 throw "completed";
41 } 41 }
42 42
43 var pendingCallbacks = 0; 43 var pendingCallbacks = 0;
44 44
45 chrome.test.callbackAdded = function() { 45 chrome.test.callbackAdded = function() {
46 pendingCallbacks++; 46 pendingCallbacks++;
47 47
48 var called = false;
48 return function() { 49 return function() {
50 chrome.test.assertFalse(called, 'callback has already been run');
51 called = true;
52
49 pendingCallbacks--; 53 pendingCallbacks--;
50 if (pendingCallbacks == 0) { 54 if (pendingCallbacks == 0) {
51 chrome.test.succeed(); 55 chrome.test.succeed();
52 } 56 }
53 }; 57 };
54 }; 58 };
55 59
56 chrome.test.runNextTest = function() { 60 chrome.test.runNextTest = function() {
57 // There may have been callbacks which were interrupted by failure 61 // There may have been callbacks which were interrupted by failure
58 // exceptions. 62 // exceptions.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 265
262 chrome.test.callbackFail = function(expectedError, func) { 266 chrome.test.callbackFail = function(expectedError, func) {
263 return chrome.test.callback(func, expectedError); 267 return chrome.test.callback(func, expectedError);
264 }; 268 };
265 269
266 chrome.test.runTests = function(tests) { 270 chrome.test.runTests = function(tests) {
267 chrome.test.tests = tests; 271 chrome.test.tests = tests;
268 testCount = chrome.test.tests.length; 272 testCount = chrome.test.tests.length;
269 chrome.test.runNextTest(); 273 chrome.test.runNextTest();
270 }; 274 };
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