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

Unified Diff: tests/html/js_test.dart

Issue 222203009: Execute callbacks from JS in the correct zone Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add _wrapToJs Created 6 years, 8 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 | « sdk/lib/js/dartium/js_dartium.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/js_test.dart
diff --git a/tests/html/js_test.dart b/tests/html/js_test.dart
index 081ab0270576c4bd3a86d22885eae90a21c73fba..7bdee2d50c520bb1f676125f6b07b8817bbf4b56 100644
--- a/tests/html/js_test.dart
+++ b/tests/html/js_test.dart
@@ -228,6 +228,8 @@ class Callable {
call() => 'called';
}
+typedef ThreeArgFunction(a, b, c);
+
main() {
_injectJs();
useHtmlConfiguration();
@@ -659,6 +661,20 @@ main() {
context.deleteProperty('callback');
});
+ test('invoke Dart callback from JS in a Zone', () {
+ expect(() => context.callMethod('invokeCallback'), throws);
+
+ var childZone = Zone.current.fork();
+ childZone.run(() {
+ context['callback'] = () {
+ expect(Zone.current, childZone);
+ };
+ });
+ context.callMethod('invokeCallback');
+
+ context.deleteProperty('callback');
+ });
+
test('callback as parameter', () {
expect(context.callMethod('getTypeOf', [context['razzle']]),
equals("function"));
@@ -694,6 +710,13 @@ main() {
context.deleteProperty('callable');
});
+ test('Dart closures should survive a round-trip to JS', () {
+ context['callback'] = (a, b, c) => a + b + c;
+ var f = context['callback'];
+ expect(f, new isInstanceOf<ThreeArgFunction>());
+ context.deleteProperty('callback');
+ });
+
});
group('JsObject.jsify()', () {
« no previous file with comments | « sdk/lib/js/dartium/js_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698