OLD | NEW |
1 library dromaeo_test; | 1 library dromaeo_test; |
2 | 2 |
3 import 'dart:html'; | 3 import 'dart:html'; |
4 import 'dart:async'; | 4 import 'dart:async'; |
5 import 'dart:json' as json; | 5 import "dart:convert"; |
6 import 'dart:math' as Math; | 6 import 'dart:math' as Math; |
7 import 'Suites.dart'; | 7 import 'Suites.dart'; |
8 | 8 |
9 main() { | 9 main() { |
10 new Dromaeo().run(); | 10 new Dromaeo().run(); |
11 } | 11 } |
12 | 12 |
13 class SuiteController { | 13 class SuiteController { |
14 final SuiteDescription _suiteDescription; | 14 final SuiteDescription _suiteDescription; |
15 final IFrameElement _suiteIframe; | 15 final IFrameElement _suiteIframe; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 final List<SuiteController> _suiteControllers; | 91 final List<SuiteController> _suiteControllers; |
92 Function _handler; | 92 Function _handler; |
93 | 93 |
94 Dromaeo() | 94 Dromaeo() |
95 : _suiteControllers = new List<SuiteController>() | 95 : _suiteControllers = new List<SuiteController>() |
96 { | 96 { |
97 _handler = _createHandler(); | 97 _handler = _createHandler(); |
98 window.onMessage.listen( | 98 window.onMessage.listen( |
99 (MessageEvent event) { | 99 (MessageEvent event) { |
100 try { | 100 try { |
101 final response = json.parse(event.data); | 101 final response = JSON.decode(event.data); |
102 _handler = _handler(response['command'], response['data']); | 102 _handler = _handler(response['command'], response['data']); |
103 } catch (e, stacktrace) { | 103 } catch (e, stacktrace) { |
104 if (!(e is FormatException && | 104 if (!(e is FormatException && |
105 (event.data.toString().startsWith('unittest') || | 105 (event.data.toString().startsWith('unittest') || |
106 event.data.toString().startsWith('dart')))) { | 106 event.data.toString().startsWith('dart')))) { |
107 // Hack because unittest also uses post messages to communicate. | 107 // Hack because unittest also uses post messages to communicate. |
108 // So the fact that the event.data is not proper json is not | 108 // So the fact that the event.data is not proper json is not |
109 // always an error. | 109 // always an error. |
110 print('Exception: ${e}: ${stacktrace}'); | 110 print('Exception: ${e}: ${stacktrace}'); |
111 print(event.data); | 111 print(event.data); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 Element _byId(String id) { | 223 Element _byId(String id) { |
224 return document.query('#$id'); | 224 return document.query('#$id'); |
225 } | 225 } |
226 | 226 |
227 int get _suitesTotal { | 227 int get _suitesTotal { |
228 return _suiteControllers.length; | 228 return _suiteControllers.length; |
229 } | 229 } |
230 } | 230 } |
OLD | NEW |