OLD | NEW |
1 /*global self*/ | 1 /*global self*/ |
2 /*jshint latedef: nofunc*/ | 2 /*jshint latedef: nofunc*/ |
3 /* | 3 /* |
4 Distributed under both the W3C Test Suite License [1] and the W3C | 4 Distributed under both the W3C Test Suite License [1] and the W3C |
5 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the | 5 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
6 policies and contribution forms [3]. | 6 policies and contribution forms [3]. |
7 | 7 |
8 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license | 8 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
9 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license | 9 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
10 [3] http://www.w3.org/2004/10/27-testcases | 10 [3] http://www.w3.org/2004/10/27-testcases |
(...skipping 2655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2666 return supports; | 2666 return supports; |
2667 } | 2667 } |
2668 | 2668 |
2669 /** | 2669 /** |
2670 * Setup globals | 2670 * Setup globals |
2671 */ | 2671 */ |
2672 | 2672 |
2673 var tests = new Tests(); | 2673 var tests = new Tests(); |
2674 | 2674 |
2675 var error_handler = function(e) { | 2675 var error_handler = function(e) { |
| 2676 if (tests.tests.length === 0 && !tests.allow_uncaught_exception) { |
| 2677 tests.set_file_is_test(); |
| 2678 } |
| 2679 |
| 2680 var stack; |
| 2681 if (e.error && e.error.stack) { |
| 2682 stack = e.error.stack; |
| 2683 } else { |
| 2684 stack = e.filename + ":" + e.lineno + ":" + e.colno; |
| 2685 } |
| 2686 |
2676 if (tests.file_is_test) { | 2687 if (tests.file_is_test) { |
2677 var test = tests.tests[0]; | 2688 var test = tests.tests[0]; |
2678 if (test.phase >= test.phases.HAS_RESULT) { | 2689 if (test.phase >= test.phases.HAS_RESULT) { |
2679 return; | 2690 return; |
2680 } | 2691 } |
2681 test.set_status(test.FAIL, e.message, e.stack); | 2692 test.set_status(test.FAIL, e.message, stack); |
2682 test.phase = test.phases.HAS_RESULT; | 2693 test.phase = test.phases.HAS_RESULT; |
2683 test.done(); | 2694 test.done(); |
2684 done(); | |
2685 } else if (!tests.allow_uncaught_exception) { | 2695 } else if (!tests.allow_uncaught_exception) { |
2686 tests.status.status = tests.status.ERROR; | 2696 tests.status.status = tests.status.ERROR; |
2687 tests.status.message = e.message; | 2697 tests.status.message = e.message; |
2688 tests.status.stack = e.stack; | 2698 tests.status.stack = stack; |
2689 } | 2699 } |
| 2700 done(); |
2690 }; | 2701 }; |
2691 | 2702 |
2692 addEventListener("error", error_handler, false); | 2703 addEventListener("error", error_handler, false); |
2693 addEventListener("unhandledrejection", function(e){ error_handler(e.reason);
}, false); | 2704 addEventListener("unhandledrejection", function(e){ error_handler(e.reason);
}, false); |
2694 | 2705 |
2695 test_environment.on_tests_ready(); | 2706 test_environment.on_tests_ready(); |
2696 | 2707 |
2697 })(); | 2708 })(); |
2698 // vim: set expandtab shiftwidth=4 tabstop=4: | 2709 // vim: set expandtab shiftwidth=4 tabstop=4: |
OLD | NEW |