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

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: 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') | dart/tests/try/try.status » ('J')
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..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
}
« no previous file with comments | « no previous file | dart/tests/try/try.status » ('j') | dart/tests/try/try.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698