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

Unified Diff: chrome/test/data/webui/test_api.js

Issue 320753002: Support javascript gtests in an extension background page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: EXPECT_TRUE and TODO. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/web_ui_browser_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/test_api.js
diff --git a/chrome/test/data/webui/test_api.js b/chrome/test/data/webui/test_api.js
index 2696d2b2ede4376bfb221f5dea68b136a61a4ec0..460495c985d548e9e1cdbcfaf3f499c26060c066 100644
--- a/chrome/test/data/webui/test_api.js
+++ b/chrome/test/data/webui/test_api.js
@@ -830,7 +830,14 @@ var testing = {};
}
if (!result)
result = testResult();
- chrome.send('testResult', result);
+ if (chrome.send) {
+ // For WebUI tests.
+ chrome.send('testResult', result);
+ } else if (window.domAutomationController.send) {
+ // For extension tests.
+ valueResult = { 'result': result[0], message: result[1] };
+ window.domAutomationController.send(JSON.stringify(valueResult));
+ }
errors.splice(0, errors.length);
} else {
console.warn('testIsDone already');
@@ -1101,6 +1108,12 @@ var testing = {};
// that have enabled content-security-policy.
var testBody = this[testFunction]; // global object -- not a method.
var testName = testFunction;
+
+ // Depending on how we were called, |this| might not resolve to the global
+ // context.
+ if (testName == 'RUN_TEST_F' && testBody === undefined)
+ testBody = RUN_TEST_F;
+
if (typeof testBody === "undefined") {
testBody = eval(testFunction);
testName = testBody.toString();
« no previous file with comments | « chrome/test/base/web_ui_browser_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698