OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** | 5 /** |
6 * @fileoverview Library providing basic test framework functionality. | 6 * @fileoverview Library providing basic test framework functionality. |
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * Namespace for |Test|. | 10 * Namespace for |Test|. |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 * error messages. This supports sync tests and async tests by calling | 736 * error messages. This supports sync tests and async tests by calling |
737 * testDone() when |isAsync| is not true, relying on async tests to call | 737 * testDone() when |isAsync| is not true, relying on async tests to call |
738 * testDone() when they complete. | 738 * testDone() when they complete. |
739 * @param {boolean} isAsync When false, call testDone() with the test result. | 739 * @param {boolean} isAsync When false, call testDone() with the test result. |
740 * @param {string} testFunction The function name to call. | 740 * @param {string} testFunction The function name to call. |
741 * @param {Array} testArguments The arguments to call |testFunction| with. | 741 * @param {Array} testArguments The arguments to call |testFunction| with. |
742 * @return {boolean} true always to signal successful execution (but not | 742 * @return {boolean} true always to signal successful execution (but not |
743 * necessarily successful results) of this test. | 743 * necessarily successful results) of this test. |
744 * @see errors | 744 * @see errors |
745 * @see runTestFunction | 745 * @see runTestFunction |
| 746 * TODO(scr): Fix TEST_F to call testDone when assertions fail in async mode. |
746 */ | 747 */ |
747 function runTest(isAsync, testFunction, testArguments) { | 748 function runTest(isAsync, testFunction, testArguments) { |
748 // Avoid eval() if at all possible, since it will not work on pages | 749 // Avoid eval() if at all possible, since it will not work on pages |
749 // that have enabled content-security-policy. | 750 // that have enabled content-security-policy. |
750 var testBody = this[testFunction]; // global object -- not a method. | 751 var testBody = this[testFunction]; // global object -- not a method. |
751 var testName = testFunction; | 752 var testName = testFunction; |
752 if (typeof testBody === "undefined") { | 753 if (typeof testBody === "undefined") { |
753 testBody = eval(testFunction); | 754 testBody = eval(testFunction); |
754 testName = testBody.toString(); | 755 testName = testBody.toString(); |
755 } | 756 } |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 window.SaveMockArguments = SaveMockArguments; | 1286 window.SaveMockArguments = SaveMockArguments; |
1286 window.DUMMY_URL = DUMMY_URL; | 1287 window.DUMMY_URL = DUMMY_URL; |
1287 window.TEST = TEST; | 1288 window.TEST = TEST; |
1288 window.TEST_F = TEST_F; | 1289 window.TEST_F = TEST_F; |
1289 window.GEN = GEN; | 1290 window.GEN = GEN; |
1290 window.WhenTestDone = WhenTestDone; | 1291 window.WhenTestDone = WhenTestDone; |
1291 | 1292 |
1292 // Import the Mock4JS helpers. | 1293 // Import the Mock4JS helpers. |
1293 Mock4JS.addMockSupport(window); | 1294 Mock4JS.addMockSupport(window); |
1294 })(('window' in this) ? window : this); | 1295 })(('window' in this) ? window : this); |
OLD | NEW |