| 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 3f85b43865e989d71dc9790d151603af49879730..64d1de26eae25035d68efb9602872207c562138d 100644
|
| --- a/dart/tests/try/end_to_end_test.dart
|
| +++ b/dart/tests/try/end_to_end_test.dart
|
| @@ -14,8 +14,37 @@ library trydart.end_to_end_test;
|
| import 'dart:html';
|
| import 'dart:async';
|
|
|
| +// TODO(ahe): Remove this import if issue 17936 is fixed.
|
| +import 'dart:js' as hack;
|
| +
|
| import 'package:async_helper/async_helper.dart';
|
|
|
| +void installErrorHandlerOn(IFrameElement iframe) {
|
| + // This method uses dart:js to install an error event handler on the content
|
| + // window of [iframe]. This is a workaround for http://dartbug.com/17936.
|
| + var iframeProxy = new hack.JsObject.fromBrowserObject(iframe);
|
| + var contentWindowProxy = iframeProxy['contentWindow'];
|
| + if (contentWindowProxy == null) {
|
| + print('No contentWindow in iframe');
|
| + throw 'No contentWindow in iframe';
|
| + }
|
| + contentWindowProxy.callMethod('addEventListener', ['error', (eventProxy) {
|
| + String filename = eventProxy['filename'];
|
| + int lineno = eventProxy['lineno'];
|
| + String message = eventProxy['message'];
|
| + print("Error occurred in iframe: $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: $filename:$lineno: $message';
|
| + });
|
| + }]);
|
| +}
|
| +
|
| +void onIframeLoaded(ErrorEvent event) {
|
| + installErrorHandlerOn(event.target);
|
| +}
|
| +
|
| void main() {
|
| asyncStart();
|
| window.onMessage.listen((MessageEvent e) {
|
| @@ -36,8 +65,14 @@ void main() {
|
| // time.
|
| window.localStorage.clear();
|
|
|
| - document.body.append(new IFrameElement()
|
| + IFrameElement iframe = new IFrameElement()
|
| ..src = '/root_build/try_dartlang_org/index.html'
|
| ..style.width = '90vw'
|
| - ..style.height = '90vh');
|
| + ..style.height = '90vh'
|
| + ..onLoad.listen(onIframeLoaded);
|
| + document.body.append(iframe);
|
| + // Install an error handler both on the new iframe element, and when it has
|
| + // fired the load event. That seems to matter according to some sources on
|
| + // stackoverflow.
|
| + installErrorHandlerOn(iframe);
|
| }
|
|
|