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

Side by Side 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 Dartium support 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library jsTest; 5 library jsTest;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:typed_data' show ByteBuffer, Int32List; 9 import 'dart:typed_data' show ByteBuffer, Int32List;
10 import 'dart:indexed_db' show IdbFactory, KeyRange; 10 import 'dart:indexed_db' show IdbFactory, KeyRange;
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 group('Dart functions', () { 652 group('Dart functions', () {
653 test('invoke Dart callback from JS', () { 653 test('invoke Dart callback from JS', () {
654 expect(() => context.callMethod('invokeCallback'), throws); 654 expect(() => context.callMethod('invokeCallback'), throws);
655 655
656 context['callback'] = () => 42; 656 context['callback'] = () => 42;
657 expect(context.callMethod('invokeCallback'), equals(42)); 657 expect(context.callMethod('invokeCallback'), equals(42));
658 658
659 context.deleteProperty('callback'); 659 context.deleteProperty('callback');
660 }); 660 });
661 661
662 test('invoke Dart callback from JS in a Zone', () {
663 expect(() => context.callMethod('invokeCallback'), throws);
664
665 var childZone = Zone.current.fork();
666 childZone.run(() {
667 context['callback'] = () {
668 expect(Zone.current, childZone);
669 };
670 });
671 context.callMethod('invokeCallback');
672
673 context.deleteProperty('callback');
674 });
675
662 test('callback as parameter', () { 676 test('callback as parameter', () {
663 expect(context.callMethod('getTypeOf', [context['razzle']]), 677 expect(context.callMethod('getTypeOf', [context['razzle']]),
664 equals("function")); 678 equals("function"));
665 }); 679 });
666 680
667 test('invoke Dart callback from JS with this', () { 681 test('invoke Dart callback from JS with this', () {
668 // A JavaScript constructor function implemented in Dart which 682 // A JavaScript constructor function implemented in Dart which
669 // uses 'this' 683 // uses 'this'
670 final constructor = new JsFunction.withThis(($this, arg1) { 684 final constructor = new JsFunction.withThis(($this, arg1) {
671 var t = $this; 685 var t = $this;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 // expect(context.callMethod('isPropertyInstanceOf', ['o', listType]), 1019 // expect(context.callMethod('isPropertyInstanceOf', ['o', listType]),
1006 // isTrue); 1020 // isTrue);
1007 context.deleteProperty('o'); 1021 context.deleteProperty('o');
1008 } 1022 }
1009 }); 1023 });
1010 1024
1011 }); 1025 });
1012 }); 1026 });
1013 1027
1014 } 1028 }
OLDNEW
« sdk/lib/js/dartium/js_dartium.dart ('K') | « 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