OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
4 for details. All rights reserved. Use of this source code is governed by a | 4 for details. All rights reserved. Use of this source code is governed by a |
5 BSD-style license that can be found in the LICENSE file. | 5 BSD-style license that can be found in the LICENSE file. |
6 --> | 6 --> |
7 <html lang="en"> | 7 <html lang="en"> |
8 <head> | 8 <head> |
9 <meta charset="utf-8"> | 9 <meta charset="utf-8"> |
10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
11 <title>data_style_binding_test</title> | |
12 <script type='application/javascript' src="testing.js"></script> | 11 <script type='application/javascript' src="testing.js"></script> |
13 </head> | 12 </head> |
14 <body> | 13 <body> |
15 <p id="test" style="{{styles}}">This text should be 24px monospace</p> | 14 <p id="test" style="{{styles}}">This text should be 24px monospace</p> |
16 <script type="application/dart"> | 15 <script type="application/dart"> |
17 import 'dart:html'; | 16 import 'dart:html'; |
18 import 'package:web_ui/web_ui.dart'; | 17 import 'package:web_ui/web_ui.dart'; |
19 import 'package:unittest/unittest.dart'; | 18 import 'package:unittest/unittest.dart'; |
20 | 19 |
21 // Note: use const maps to ensure that the system doesn't mutate the map. | 20 // Note: use const maps to ensure that the system doesn't mutate the map. |
22 // (this would cause a runtime error). | 21 // (this would cause a runtime error). |
23 var styles = const { 'font-size': '16px' }; | 22 @observable var styles = const { 'font-size': '16px' }; |
24 main() { | 23 main() { |
25 window.setTimeout(() { | 24 window.setTimeout(() { |
26 expect(query('#test').style.cssText, 'font-size: 16px;'); | 25 expect(query('#test').style.cssText, 'font-size: 16px;'); |
27 var oldStyles = styles; | 26 var oldStyles = styles; |
28 | 27 |
29 styles = "Intentionally invalid style!"; | 28 styles = "Intentionally invalid style!"; |
30 expect(dispatch, throwsA(predicate((x) => x is DataBindingError))); | 29 |
| 30 var error = null; |
| 31 onObserveUnhandledError = (e, trace, callback) { |
| 32 error = e; |
| 33 }; |
| 34 try { |
| 35 deliverChangesSync(); |
| 36 expect(error, new isInstanceOf<DataBindingError>()); |
| 37 } finally { |
| 38 onObserveUnhandledError = defaultObserveUnhandledError; |
| 39 } |
| 40 |
31 window.setTimeout(() { | 41 window.setTimeout(() { |
32 // Our invalid style was ignored. | 42 // Our invalid style was ignored. |
33 expect(query('#test').style.cssText, ''); | 43 expect(query('#test').style.cssText, ''); |
34 | 44 |
35 styles = const { 'font-size': '24px', 'font-family': 'monospace' }; | 45 styles = const { 'font-size': '24px', 'font-family': 'monospace' }; |
36 dispatch(); | 46 deliverChangesSync(); |
37 window.setTimeout(() { | 47 window.setTimeout(() { |
38 // This is also verified through the render tree. | 48 // This is also verified through the render tree. |
39 expect(query('#test').style.cssText, | 49 expect(query('#test').style.cssText, |
40 'font-size: 24px; font-family: monospace;'); | 50 'font-size: 24px; font-family: monospace;'); |
41 window.postMessage('done', '*'); | 51 window.postMessage('done', '*'); |
42 }, 0); | 52 }, 0); |
43 }, 0); | 53 }, 0); |
44 }, 0); | 54 }, 0); |
45 } | 55 } |
46 </script> | 56 </script> |
47 </body> | 57 </body> |
48 </html> | 58 </html> |
OLD | NEW |