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

Unified Diff: chrome/renderer/resources/extension_apitest.js

Issue 199091: Update ExtensionApiTest.Tabs and re-enable (Closed)
Patch Set: remove comment Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/test/data/extensions/api_test/tabs/test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extension_apitest.js
diff --git a/chrome/renderer/resources/extension_apitest.js b/chrome/renderer/resources/extension_apitest.js
index 7b2d5837871861f38eb99939f84522f37d7eae46..90cc0554361326731b3fc4775c4e0e7a15f64ac7 100644
--- a/chrome/renderer/resources/extension_apitest.js
+++ b/chrome/renderer/resources/extension_apitest.js
@@ -50,20 +50,14 @@ var chrome = chrome || {};
}
var pendingCallbacks = 0;
- var totalCallbacks = 0;
-
+
function callbackAdded() {
pendingCallbacks++;
- chrome.test.assertEq(totalCallbacks, 0);
};
-
+
function callbackCompleted() {
- if (!totalCallbacks)
- totalCallbacks = pendingCallbacks;
pendingCallbacks--;
if (pendingCallbacks == 0) {
- //chrome.test.log(" " + totalCallbacks + " callbacks ran");
- totalCallbacks = 0;
chrome.test.succeed();
}
};
@@ -126,7 +120,7 @@ var chrome = chrome || {};
chrome.extension.lastError.message);
}
};
-
+
function safeFunctionApply(func, arguments) {
try {
if (func) {
@@ -154,7 +148,6 @@ var chrome = chrome || {};
if (func) {
chrome.test.assertEq(typeof(func), 'function');
}
-
callbackAdded();
return function() {
@@ -172,17 +165,34 @@ var chrome = chrome || {};
callbackCompleted();
};
};
-
+
chrome.test.listenOnce = function(event, func) {
callbackAdded();
var listener = function() {
event.removeListener(listener);
- safeFunctionApply(func, arguments);
+ safeFunctionApply(func, arguments);
callbackCompleted();
};
event.addListener(listener);
};
+ chrome.test.listenForever = function(event, func) {
+ callbackAdded();
+
+ var listener = function() {
+ safeFunctionApply(func, arguments);
+ };
+
+ var done = {};
+ done.doneListening = function() {
+ event.removeListener(listener);
+ callbackCompleted();
+ };
+
+ event.addListener(listener);
+ return done;
+ };
+
chrome.test.callbackPass = function(func) {
return chrome.test.callback(func);
};
@@ -191,14 +201,8 @@ var chrome = chrome || {};
return chrome.test.callback(null, expectedError);
};
- // TODO(erikkay) This is deprecated and should be removed.
- chrome.test.testCallback = function(succeedWhenDone, func) {
- return chrome.test.callback(func);
- };
-
chrome.test.runTests = function(tests) {
chrome.test.tests = tests;
chrome.test.runNextTest();
};
-
})();
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/test/data/extensions/api_test/tabs/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698