| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @JS() | 5 @JS() |
| 6 library js_typed_interop_test; | 6 library js_typed_interop_test; |
| 7 | 7 |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 | 9 |
| 10 import 'package:js/js.dart'; | 10 import 'package:js/js.dart'; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 function _PrivateClass(a, b) { | 74 function _PrivateClass(a, b) { |
| 75 this._a = a; | 75 this._a = a; |
| 76 this._b = b; | 76 this._b = b; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 _PrivateClass.prototype = { | 79 _PrivateClass.prototype = { |
| 80 _getA: function() { return this._a;} | 80 _getA: function() { return this._a;} |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 var selection = ["a", "b", "c", foo, bar]; | 83 var selection = ["a", "b", "c", foo, bar]; |
| 84 | 84 |
| 85 function returnNumArgs() { return arguments.length; }; | 85 function returnNumArgs() { return arguments.length; }; |
| 86 function returnLastArg() { return arguments[arguments.length-1]; }; | 86 function returnLastArg() { return arguments[arguments.length-1]; }; |
| 87 | 87 |
| 88 function confuse(obj) { return obj; } | 88 function confuse(obj) { return obj; } |
| 89 | 89 |
| 90 window['class'] = function() { return 42; }; | 90 window['class'] = function() { return 42; }; |
| 91 window['delete'] = 100; | 91 window['delete'] = 100; |
| 92 window['JS$hasJsInName'] = 'unicorn'; | 92 window['JS$hasJsInName'] = 'unicorn'; |
| 93 window['JS$hasJsInNameMethod'] = function(x) { return x*5; }; | 93 window['JS$hasJsInNameMethod'] = function(x) { return x*5; }; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 @JS('ClassWithConstructor') | 139 @JS('ClassWithConstructor') |
| 140 class _ClassWithConstructor { | 140 class _ClassWithConstructor { |
| 141 external _ClassWithConstructor(aParam, bParam); | 141 external _ClassWithConstructor(aParam, bParam); |
| 142 external getA(); | 142 external getA(); |
| 143 external get a; | 143 external get a; |
| 144 external get b; | 144 external get b; |
| 145 } | 145 } |
| 146 | 146 |
| 147 @JS('ClassWithConstructor') |
| 148 class ClassWithFactory { |
| 149 external factory ClassWithFactory(aParam, bParam); |
| 150 external getA(); |
| 151 external get a; |
| 152 external get b; |
| 153 } |
| 154 |
| 147 @JS() | 155 @JS() |
| 148 class JS$_PrivateClass { | 156 class JS$_PrivateClass { |
| 149 external JS$_PrivateClass(aParam, bParam); | 157 external JS$_PrivateClass(aParam, bParam); |
| 150 external JS$_getA(); | 158 external JS$_getA(); |
| 151 external get JS$_a; | 159 external get JS$_a; |
| 152 external get JS$_b; | 160 external get JS$_b; |
| 153 // Equivalent to JS$_a but only visible within | 161 // Equivalent to JS$_a but only visible within |
| 154 // the class. | 162 // the class. |
| 155 external get _a; | 163 external get _a; |
| 156 } | 164 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 }); | 325 }); |
| 318 }); | 326 }); |
| 319 | 327 |
| 320 group('constructor', () { | 328 group('constructor', () { |
| 321 test('simple', () { | 329 test('simple', () { |
| 322 var o = new ClassWithConstructor("foo", "bar"); | 330 var o = new ClassWithConstructor("foo", "bar"); |
| 323 expect(o.a, equals("foo")); | 331 expect(o.a, equals("foo")); |
| 324 expect(o.b, equals("bar")); | 332 expect(o.b, equals("bar")); |
| 325 expect(o.getA(), equals("foo")); | 333 expect(o.getA(), equals("foo")); |
| 326 }); | 334 }); |
| 335 test('external factory', () { |
| 336 var o = new ClassWithFactory("foo", "bar"); |
| 337 expect(o.a, equals("foo")); |
| 338 expect(o.b, equals("bar")); |
| 339 expect(o.getA(), equals("foo")); |
| 340 }); |
| 327 }); | 341 }); |
| 328 | 342 |
| 329 group('private class', () { | 343 group('private class', () { |
| 330 test('simple', () { | 344 test('simple', () { |
| 331 var o = new _ClassWithConstructor("foo", "bar"); | 345 var o = new _ClassWithConstructor("foo", "bar"); |
| 332 expect(o.a, equals("foo")); | 346 expect(o.a, equals("foo")); |
| 333 expect(o.b, equals("bar")); | 347 expect(o.b, equals("bar")); |
| 334 expect(o.getA(), equals("foo")); | 348 expect(o.getA(), equals("foo")); |
| 335 }); | 349 }); |
| 336 }); | 350 }); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 group('html', () { | 574 group('html', () { |
| 561 test('return html type', () { | 575 test('return html type', () { |
| 562 expect(getCanvasContext() is CanvasRenderingContext2D, isTrue); | 576 expect(getCanvasContext() is CanvasRenderingContext2D, isTrue); |
| 563 }); | 577 }); |
| 564 test('js path contains html types', () { | 578 test('js path contains html types', () { |
| 565 expect(propertyOnWindow, equals(42)); | 579 expect(propertyOnWindow, equals(42)); |
| 566 expect(propertyOnDocument, equals(45)); | 580 expect(propertyOnDocument, equals(45)); |
| 567 }); | 581 }); |
| 568 }); | 582 }); |
| 569 } | 583 } |
| OLD | NEW |