Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Unified Diff: dart/tests/try/end_to_end_test.dart

Issue 220453006: end_to_end_test detects errors instead of timing out. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/tests/try/try.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | dart/tests/try/try.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698