| OLD | NEW |
| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 expect(context['y'], isNull); | 315 expect(context['y'], isNull); |
| 316 }); | 316 }); |
| 317 | 317 |
| 318 test('write global field', () { | 318 test('write global field', () { |
| 319 context['y'] = 42; | 319 context['y'] = 42; |
| 320 expect(context['y'], equals(42)); | 320 expect(context['y'], equals(42)); |
| 321 }); | 321 }); |
| 322 | 322 |
| 323 }); | 323 }); |
| 324 | 324 |
| 325 group('new JsObject()', () { | 325 group('new_JsObject', () { |
| 326 | 326 |
| 327 test('new Foo()', () { | 327 test('new Foo()', () { |
| 328 var foo = new JsObject(context['Foo'], [42]); | 328 var foo = new JsObject(context['Foo'], [42]); |
| 329 expect(foo['a'], equals(42)); | 329 expect(foo['a'], equals(42)); |
| 330 expect(foo.callMethod('bar'), equals(42)); | 330 expect(foo.callMethod('bar'), equals(42)); |
| 331 expect(() => foo.callMethod('baz'), throwsA(isNoSuchMethodError)); | 331 expect(() => foo.callMethod('baz'), throwsA(isNoSuchMethodError)); |
| 332 }); | 332 }); |
| 333 | 333 |
| 334 test('new container.Foo()', () { | 334 test('new container.Foo()', () { |
| 335 final Foo2 = context['container']['Foo']; | 335 final Foo2 = context['container']['Foo']; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 642 |
| 643 test('primitives and null throw ArgumentError', () { | 643 test('primitives and null throw ArgumentError', () { |
| 644 for (var v in ['a', 1, 2.0, true, null]) { | 644 for (var v in ['a', 1, 2.0, true, null]) { |
| 645 expect(() => new JsObject.fromBrowserObject(v), | 645 expect(() => new JsObject.fromBrowserObject(v), |
| 646 throwsA(new isInstanceOf<ArgumentError>())); | 646 throwsA(new isInstanceOf<ArgumentError>())); |
| 647 } | 647 } |
| 648 }); | 648 }); |
| 649 | 649 |
| 650 }); | 650 }); |
| 651 | 651 |
| 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('callback as parameter', () { | 662 test('callback as parameter', () { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 expect(jsObject['b']['d'].callMethod('bar'), equals(42)); | 745 expect(jsObject['b']['d'].callMethod('bar'), equals(42)); |
| 746 expect(jsObject['e'], isNull); | 746 expect(jsObject['e'], isNull); |
| 747 }); | 747 }); |
| 748 | 748 |
| 749 test('throws if object is not a Map or Iterable', () { | 749 test('throws if object is not a Map or Iterable', () { |
| 750 expect(() => new JsObject.jsify('a'), | 750 expect(() => new JsObject.jsify('a'), |
| 751 throwsA(new isInstanceOf<ArgumentError>())); | 751 throwsA(new isInstanceOf<ArgumentError>())); |
| 752 }); | 752 }); |
| 753 }); | 753 }); |
| 754 | 754 |
| 755 group('JsObject methods', () { | 755 group('JsObject_methods', () { |
| 756 | 756 |
| 757 test('hashCode and ==', () { | 757 test('hashCode and ==', () { |
| 758 final o1 = context['Object']; | 758 final o1 = context['Object']; |
| 759 final o2 = context['Object']; | 759 final o2 = context['Object']; |
| 760 expect(o1 == o2, isTrue); | 760 expect(o1 == o2, isTrue); |
| 761 expect(o1.hashCode == o2.hashCode, isTrue); | 761 expect(o1.hashCode == o2.hashCode, isTrue); |
| 762 final d = context['document']; | 762 final d = context['document']; |
| 763 expect(o1 == d, isFalse); | 763 expect(o1 == d, isFalse); |
| 764 }); | 764 }); |
| 765 | 765 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 // expect(context.callMethod('isPropertyInstanceOf', ['o', listType]), | 1008 // expect(context.callMethod('isPropertyInstanceOf', ['o', listType]), |
| 1009 // isTrue); | 1009 // isTrue); |
| 1010 context.deleteProperty('o'); | 1010 context.deleteProperty('o'); |
| 1011 } | 1011 } |
| 1012 }); | 1012 }); |
| 1013 | 1013 |
| 1014 }); | 1014 }); |
| 1015 }); | 1015 }); |
| 1016 | 1016 |
| 1017 } | 1017 } |
| OLD | NEW |