Chromium Code Reviews| Index: dart/tests/try/end_to_end_test.dart |
| diff --git a/dart/tests/try/end_to_end_test.dart b/dart/tests/try/end_to_end_test.dart |
| index 3452aa8c39b4e73fbd4f3dea79143ae7cd2721d5..24c11145d6fe31178bf1cf525c67f21c497aca5c 100644 |
| --- a/dart/tests/try/end_to_end_test.dart |
| +++ b/dart/tests/try/end_to_end_test.dart |
| @@ -19,15 +19,31 @@ import 'dart:js' as hack; |
| import 'package:async_helper/async_helper.dart'; |
| -void onError(String message, String filename, int lineno) { |
| - if (filename != null) { |
| - message = '$filename:$lineno: $message'; |
| +void onError(String message, String filename, int lineno, [int colno, error]) { |
| + if (filename != null && filename != "" && lineno != 0) { |
| + if (colno != null && colno != 0) { |
| + message = '$filename:$lineno:$colno $message'; |
| + } else { |
| + message = '$filename:$lineno: $message'; |
| + } |
| } |
| - print("Error occurred in Try Dart iframe: $message"); |
| + if (error != null) { |
| + // See: |
| + // https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror |
| + var stack = error['stack']; |
| + if (stack != null) { |
| + message += '\n$stack'; |
| + } |
| + } |
| + message = "Error occurred in Try Dart iframe: $message"; |
| + |
| + // Synchronous, easier to read when running the browser manually. |
| + window.console.log(message); |
| + |
| new Future(() { |
| - // Chrome seems to not call window.onerror when you throw in response to an |
| - // error event. So we throw the error in a future. |
| - throw 'Error from iframe: $message'; |
| + // Browsers ignore errors throw in event listeners (or from |
| + // window.onerror). |
| + throw message; |
| }); |
| } |
| @@ -40,11 +56,12 @@ void installErrorHandlerOn(IFrameElement iframe) { |
| print('No contentWindow in iframe'); |
| throw 'No contentWindow in iframe'; |
| } |
| - contentWindowProxy.callMethod('addEventListener', ['error', (eventProxy) { |
| - onError( |
| - eventProxy['message'], eventProxy['filename'], eventProxy['lineno']); |
| - }]); |
| contentWindowProxy['onerror'] = onError; |
| + |
| + // Note: we have two options, use "iframe.contentWindow.onerror = ..." or |
|
ricow1
2014/05/08 05:33:10
move this comment above the code line doing it?
|
| + // "iframe.contentWindow.addEventListener('error', ...)". The former seems |
| + // to provide more details on both Chrome and Firefox (which provides no |
| + // information at all in error events). |
| } |
| void onIframeLoaded(Event event) { |
| @@ -61,9 +78,7 @@ void main() { |
| // Clean up after ourselves. |
| window.localStorage.clear(); |
| - asyncSuccess(null); |
| - } else { |
| - window.console.dir(e.data); |
| + asyncEnd(); |
| } |
| }); |
| @@ -72,6 +87,7 @@ void main() { |
| window.localStorage.clear(); |
| IFrameElement iframe = new IFrameElement() |
| + ..src = '/root_build/try_dartlang_org/index.html' |
| ..style.width = '90vw' |
| ..style.height = '90vh' |
| ..onLoad.listen(onIframeLoaded); |
| @@ -80,6 +96,4 @@ void main() { |
| // fired the load event. That seems to matter according to some sources on |
| // stackoverflow. |
| installErrorHandlerOn(iframe); |
| - |
| - iframe.src = '/root_build/try_dartlang_org/index.html'; |
| } |