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 3f85b43865e989d71dc9790d151603af49879730..703cebc51a93f4b4e9b744d99615ca3b94db35f1 100644 |
| --- a/dart/tests/try/end_to_end_test.dart |
| +++ b/dart/tests/try/end_to_end_test.dart |
| @@ -14,8 +14,34 @@ 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) return; |
|
kustermann
2014/04/01 20:27:30
If contentWindowProxy is null, we should fail, oth
ahe
2014/04/01 21:21:17
I can't tell when contentWindowProxy is null. As f
ahe
2014/04/03 11:05:35
Changed it to throw an exception.
|
| + 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 +62,11 @@ 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); |
| + installErrorHandlerOn(iframe); |
|
kustermann
2014/04/01 20:27:30
Why are you doing this here and in the onIframeLoa
ahe
2014/04/01 21:21:17
As far as I can gather, it matters. I think there
|
| } |