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

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

Issue 7553009: Add some browser tests for net-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Use g_browser.receive as function name when appropriate (Really, this time). Created 9 years, 5 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
Index: chrome/test/data/webui/test_api.js
===================================================================
--- chrome/test/data/webui/test_api.js (revision 94917)
+++ chrome/test/data/webui/test_api.js (working copy)
@@ -493,7 +493,6 @@
* @see createExpect
Sheridan Rawlins 2011/08/03 18:29:57 @see runTestFunction
mmenke 2011/08/03 19:30:12 Done.
**/
function runTest(testFunction, testArguments) {
- errors.splice(0, errors.length);
// Avoid eval() if at all possible, since it will not work on pages
// that have enabled content-security-policy.
var testBody = this[testFunction]; // global object -- not a method.
@@ -504,6 +503,24 @@
testFunction.name ? testFunction.name : testBody.toString();
console.log('Running test ' + testName);
}
+ return runTestFunction(testFunction, testBody, testArguments);
+ }
+
+ /**
+ * This is the guts of WebUIBrowserTest. It clears |errors|, runs the
+ * test surrounded by an expect to catch Errors. If |errors| is
+ * non-empty, it reports a failure and a message by joining |errors|.
+ * Consumers can use this to use assert/expect functions asynchronously,
+ * but are then responsible for reporting errors to the browser themselves.
+ * @param {string} testFunction The function name to report on failure.
+ * @param {Function} testBody The function to call.
+ * @param {Array} testArguments The arguments to call |testBody| with.
+ * @return {Array.<boolean, string>} [test-succeeded, message-if-failed]
+ * @see errors
+ * @see createExpect
+ **/
+ function runTestFunction(testFunction, testBody, testArguments) {
+ errors.splice(0, errors.length);
createExpect(testBody).apply(null, testArguments);
var result = [true];
@@ -719,6 +736,7 @@
window.registerMessageCallback = registerMessageCallback;
window.registerMockMessageCallbacks = registerMockMessageCallbacks;
window.runTest = runTest;
+ window.runTestFunction = runTestFunction;
window.SaveArgumentsMatcher = SaveArgumentsMatcher;
window.TEST = TEST;
window.TEST_F = TEST_F;

Powered by Google App Engine
This is Rietveld 408576698