Index: chrome/test/data/webui/net_internals/net_internals_test.js |
=================================================================== |
--- chrome/test/data/webui/net_internals/net_internals_test.js (revision 95540) |
+++ chrome/test/data/webui/net_internals/net_internals_test.js (working copy) |
@@ -10,12 +10,8 @@ |
* All callbacks from the browser are wrapped in such a way that they can |
* also use the assert/expect functions. |
* |
- * A test ends when an assert/expect test fails, an exception is thrown, or |
- * |netInternalsTest.testDone| is called. At that point, or soon afterwards, |
- * the title is updated to 'Test Failed' if an assert/expect test fails, or |
- * there was an exception. Otherwise, it's set to 'Test Passed'. The |
- * behavior when an assert/expect test fails or an assertion is thrown only |
- * after |netInternalsTest.testDone| is called is undefined. |
+ * A test ends when asyncTestDone, which is done when the end of a test |
+ * is reached runTestFunction reports a failure. |
*/ |
// Start of namespace. |
@@ -29,38 +25,9 @@ |
var TESTING_POLL_INTERVAL_MS = 50; |
/** |
- * Indicates if the test is complete. |
- * @type {boolean} |
- */ |
- var done = false; |
- |
- /** |
- * Updates the title of the page to report success or failure. Must be |
- * called at most once for each test. |
- * @param {boolean} success Description of success param. |
- */ |
- function updateTitle(success) { |
- if (success) { |
- document.title = 'Test Passed'; |
- } else { |
- document.title = 'Test Failed'; |
- } |
- done = true; |
- } |
- |
- /** |
- * Called to indicate a test is complete. |
- */ |
- function testDone() { |
- done = true; |
- } |
- |
- /** |
* Creates a test function that can use the expect and assert functions |
- * in test_api.js. On failure, will set title to 'Test Failed', and when |
- * a test is done and there was no failure, will set title to 'Test Passed'. |
- * Calling expect/assert functions after done has been called has undefined |
- * behavior. Returned test functions can safely call each other directly. |
+ * in test_api.js. Calls asyncTestDone when runTestFunction reports an |
+ * error. Tests also call asyncTestDone when complete. |
* |
* The resulting function has no return value. |
* @param {string} testName The name of the function, reported on error. |
@@ -75,23 +42,11 @@ |
// failure by runTestFunction. |
var testArguments = Array.prototype.slice.call(arguments, 0); |
- // If the test is already complete, do nothing. |
- if (done) |
- return; |
- |
var result = runTestFunction(testName, testFunction, testArguments); |
// If the first value is false, the test failed. |
- if (!result[0]) { |
- // Print any error messages. |
- console.log(result[1]); |
- // Update title to indicate failure. |
- updateTitle(false); |
- } else if (done) { |
- // If the first result is true, and |done| is also true, the test |
- // passed. Update title to indicate success. |
- updateTitle(true); |
- } |
+ if (!result[0]) |
+ asyncTestDone(); |
}; |
} |
@@ -148,7 +103,7 @@ |
/** |
* Starts running the test. A test is run until an assert/expect statement |
- * fails or testDone is called. Those functions can only be called in the |
+ * fails or testResult is called. Those functions can only be called in the |
* test function body, or in response to a message dispatched by |
* |g_browser.receive|. |
* @param {string} testName The of the test to run. |
@@ -203,34 +158,35 @@ |
return { |
test: test, |
runTest: runTest, |
- testDone:testDone, |
checkStyledTableRows: checkStyledTableRows, |
switchToView: switchToView |
}; |
})(); |
netInternalsTest.test('NetInternalsDone', function() { |
- netInternalsTest.testDone(); |
+ asyncTestDone(); |
}); |
netInternalsTest.test('NetInternalsExpectFail', function() { |
expectNotReached(); |
+ asyncTestDone(); |
}); |
netInternalsTest.test('NetInternalsAssertFail', function() { |
assertNotReached(); |
+ asyncTestDone(); |
}); |
netInternalsTest.test('NetInternalsObserverDone', function() { |
/** |
- * A HostResolverInfo observer that calls testDone() in response to the |
+ * A HostResolverInfo observer that calls asyncTestDone() in response to the |
* first seen event. |
*/ |
function HostResolverInfoObserver() { |
} |
HostResolverInfoObserver.prototype.onHostResolverInfoChanged = function() { |
- netInternalsTest.testDone(); |
+ asyncTestDone(); |
}; |
// Create the observer and add it to |g_browser|. |
@@ -250,7 +206,7 @@ |
HostResolverInfoObserver.prototype.onHostResolverInfoChanged = function() { |
expectNotReached(); |
- netInternalsTest.testDone(); |
+ asyncTestDone(); |
}; |
// Create the observer and add it to |g_browser|. |