OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 polymer.test.web.js_interop_test; | 5 library polymer.test.web.js_interop_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:js'; | 9 import 'dart:js'; |
10 import 'package:polymer/polymer.dart'; | 10 import 'package:polymer/polymer.dart'; |
(...skipping 27 matching lines...) Expand all Loading... |
38 class DartTwoWay extends PolymerElement { | 38 class DartTwoWay extends PolymerElement { |
39 @observable var twoWay = 40; | 39 @observable var twoWay = 40; |
40 DartTwoWay.created() : super.created(); | 40 DartTwoWay.created() : super.created(); |
41 } | 41 } |
42 | 42 |
43 main() => initPolymer().run(() { | 43 main() => initPolymer().run(() { |
44 useHtmlConfiguration(); | 44 useHtmlConfiguration(); |
45 | 45 |
46 setUp(() => Polymer.onReady); | 46 setUp(() => Polymer.onReady); |
47 | 47 |
48 test('elements can be passed through Node.bind to JS', () { | |
49 var text = querySelector('dart-element2') | |
50 .shadowRoot.querySelector('js-element2') | |
51 .shadowRoot.text; | |
52 expect(text, 'QUX:123'); | |
53 }); | |
54 | |
55 test('dart-element upgraded', () { | 48 test('dart-element upgraded', () { |
56 expect(querySelector('dart-element') is DartElement, true, | 49 expect(querySelector('dart-element') is DartElement, true, |
57 reason: 'dart-element upgraded'); | 50 reason: 'dart-element upgraded'); |
58 }); | 51 }); |
59 | 52 |
60 test('js-element in body', () => testInterop( | 53 test('js-element in body', () => testInterop( |
61 querySelector('js-element'))); | 54 querySelector('js-element'))); |
62 | 55 |
63 test('js-element in dart-element', () => testInterop( | 56 test('js-element in dart-element', () => testInterop( |
64 querySelector('dart-element').shadowRoot.querySelector('js-element'))); | 57 querySelector('dart-element').shadowRoot.querySelector('js-element'))); |
65 | 58 |
| 59 test('elements can be passed through Node.bind to JS', () { |
| 60 var text = querySelector('dart-element2') |
| 61 .shadowRoot.querySelector('js-element2') |
| 62 .shadowRoot.text; |
| 63 expect(text, 'QUX:123'); |
| 64 }); |
| 65 |
66 test('objects with functions can be passed through Node.bind to JS', () { | 66 test('objects with functions can be passed through Node.bind to JS', () { |
67 var sr = querySelector('dart-element3') | 67 var sr = querySelector('dart-element3') |
68 .shadowRoot.querySelector('js-element3') | 68 .shadowRoot.querySelector('js-element3') |
69 .shadowRoot; | 69 .shadowRoot; |
70 | 70 |
71 return new Future(() { | 71 return new Future(() { |
72 expect(sr.text, 'js-element3[qux]:765'); | 72 expect(sr.text, 'js-element3[qux]:765'); |
73 }); | 73 }); |
74 }); | 74 }); |
75 | 75 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 /// Calls Platform.flush() to flush Polymer.js pending operations, e.g. | 140 /// Calls Platform.flush() to flush Polymer.js pending operations, e.g. |
141 /// dirty checking for data-bindings. | 141 /// dirty checking for data-bindings. |
142 Future flush() { | 142 Future flush() { |
143 var Platform = context['Platform']; | 143 var Platform = context['Platform']; |
144 Platform.callMethod('flush'); | 144 Platform.callMethod('flush'); |
145 | 145 |
146 var completer = new Completer(); | 146 var completer = new Completer(); |
147 Platform.callMethod('endOfMicrotask', [() => completer.complete()]); | 147 Platform.callMethod('endOfMicrotask', [() => completer.complete()]); |
148 return completer.future; | 148 return completer.future; |
149 } | 149 } |
OLD | NEW |