| 5046 | |
| 5047 | if (global_scope.addEventListener) { |
| 5048 | var error_handler = function(error, message, stack) { |
| 5049 | var optional_unsupported = error instanceof OptionalFeatureUnsupportedError; |
| 5050 | if (tests.file_is_test) { |
| 5051 | var test = tests.tests[0]; |
| 5052 | if (test.phase >= test.phases.HAS_RESULT) { |
| 5053 | return; |
| 5054 | } |
| 5055 | var status = optional_unsupported ? test.PRECONDITION_FAILED : test.FAIL; |
| 5056 | test.set_status(status, message, stack); |
| 5057 | test.phase = test.phases.HAS_RESULT; |
| 5058 | } else if (!tests.allow_uncaught_exception) { |
| 5059 | var status = optional_unsupported ? tests.status.PRECONDITION_FAILED : tests.status.ERROR; |
| 5060 | tests.status.status = status; |
| 5061 | tests.status.message = message; |
| 5062 | tests.status.stack = stack; |
| 5063 | } |
| 5064 | |
| 5065 | // Do not transition to the "complete" phase if the test has been |
| 5066 | // configured to allow uncaught exceptions. This gives the test an |
| 5067 | // opportunity to define subtests based on the exception reporting |
| 5068 | // behavior. |
| 5069 | if (!tests.allow_uncaught_exception) { |
| 5070 | done(); |
| 5071 | } |
| 5072 | }; |
| 5073 | |
| 5074 | addEventListener("error", function(e) { |
| 5075 | var message = e.message; |