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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // that have enabled content-security-policy. | 760 // that have enabled content-security-policy. |
761 var testBody = this[testFunction]; // global object -- not a method. | 761 var testBody = this[testFunction]; // global object -- not a method. |
762 var testName = testFunction; | 762 var testName = testFunction; |
763 if (typeof testBody === "undefined") { | 763 if (typeof testBody === "undefined") { |
764 testBody = eval(testFunction); | 764 testBody = eval(testFunction); |
765 testName = testBody.toString(); | 765 testName = testBody.toString(); |
766 } | 766 } |
767 if (testBody != RUN_TEST_F) { | 767 if (testBody != RUN_TEST_F) { |
768 console.log('Running test ' + testName); | 768 console.log('Running test ' + testName); |
769 } | 769 } |
770 var result = runTestFunction(testFunction, testBody, testArguments, true); | 770 |
| 771 // Async allow expect errors, but not assert errors. |
| 772 var result = runTestFunction(testFunction, testBody, testArguments, |
| 773 isAsync); |
771 if (!isAsync || !result[0]) | 774 if (!isAsync || !result[0]) |
772 testDone(result); | 775 testDone(result); |
773 return true; | 776 return true; |
774 } | 777 } |
775 | 778 |
776 /** | 779 /** |
777 * This is the guts of WebUIBrowserTest. It runs the test surrounded by an | 780 * This is the guts of WebUIBrowserTest. It runs the test surrounded by an |
778 * expect to catch Errors. If |errors| is non-empty, it reports a failure and | 781 * expect to catch Errors. If |errors| is non-empty, it reports a failure and |
779 * a message by joining |errors|. Consumers can use this to use assert/expect | 782 * a message by joining |errors|. Consumers can use this to use assert/expect |
780 * functions asynchronously, but are then responsible for reporting errors to | 783 * functions asynchronously, but are then responsible for reporting errors to |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 window.SaveMockArguments = SaveMockArguments; | 1302 window.SaveMockArguments = SaveMockArguments; |
1300 window.DUMMY_URL = DUMMY_URL; | 1303 window.DUMMY_URL = DUMMY_URL; |
1301 window.TEST = TEST; | 1304 window.TEST = TEST; |
1302 window.TEST_F = TEST_F; | 1305 window.TEST_F = TEST_F; |
1303 window.GEN = GEN; | 1306 window.GEN = GEN; |
1304 window.WhenTestDone = WhenTestDone; | 1307 window.WhenTestDone = WhenTestDone; |
1305 | 1308 |
1306 // Import the Mock4JS helpers. | 1309 // Import the Mock4JS helpers. |
1307 Mock4JS.addMockSupport(window); | 1310 Mock4JS.addMockSupport(window); |
1308 })(('window' in this) ? window : this); | 1311 })(('window' in this) ? window : this); |
OLD | NEW |