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 library test.runner.browser.iframe_listener; | 5 library test.runner.browser.iframe_listener; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:html' hide Metadata; | 9 import 'dart:html' hide Metadata; |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 if (main is! Function) { | 50 if (main is! Function) { |
51 _sendLoadException(channel, "Top-level main getter is not a function."); | 51 _sendLoadException(channel, "Top-level main getter is not a function."); |
52 return; | 52 return; |
53 } else if (main is! AsyncFunction) { | 53 } else if (main is! AsyncFunction) { |
54 _sendLoadException(channel, "Top-level main() function takes arguments."); | 54 _sendLoadException(channel, "Top-level main() function takes arguments."); |
55 return; | 55 return; |
56 } | 56 } |
57 | 57 |
58 var declarer = new Declarer(); | 58 var declarer = new Declarer(); |
59 try { | 59 runZoned(() => new Future.sync(main), zoneValues: { |
60 runZoned(main, zoneValues: {#test.declarer: declarer}); | 60 #test.declarer: declarer |
61 } catch (error, stackTrace) { | 61 }).then((_) { |
| 62 var url = Uri.parse(window.location.href); |
| 63 var message = JSON.decode(Uri.decodeFull(url.fragment)); |
| 64 var metadata = new Metadata.deserialize(message['metadata']); |
| 65 var browser = TestPlatform.find(message['browser']); |
| 66 |
| 67 var suite = new Suite(declarer.tests, metadata: metadata) |
| 68 .forPlatform(browser); |
| 69 new IframeListener._(suite)._listen(channel); |
| 70 }, onError: (error, stackTrace) { |
62 channel.sink.add({ | 71 channel.sink.add({ |
63 "type": "error", | 72 "type": "error", |
64 "error": RemoteException.serialize(error, stackTrace) | 73 "error": RemoteException.serialize(error, stackTrace) |
65 }); | 74 }); |
66 return; | 75 }); |
67 } | |
68 | |
69 var url = Uri.parse(window.location.href); | |
70 var message = JSON.decode(Uri.decodeFull(url.fragment)); | |
71 var metadata = new Metadata.deserialize(message['metadata']); | |
72 var browser = TestPlatform.find(message['browser']); | |
73 | |
74 var suite = new Suite(declarer.tests, metadata: metadata) | |
75 .forPlatform(browser); | |
76 new IframeListener._(suite)._listen(channel); | |
77 } | 76 } |
78 | 77 |
79 /// Constructs a [MultiChannel] wrapping the `postMessage` communication with | 78 /// Constructs a [MultiChannel] wrapping the `postMessage` communication with |
80 /// the host page. | 79 /// the host page. |
81 /// | 80 /// |
82 /// This [MultiChannel] corresponds to a [MultiChannel] in the server's | 81 /// This [MultiChannel] corresponds to a [MultiChannel] in the server's |
83 /// [IframeTest] class. | 82 /// [IframeTest] class. |
84 static MultiChannel _postMessageChannel() { | 83 static MultiChannel _postMessageChannel() { |
85 var inputController = new StreamController(sync: true); | 84 var inputController = new StreamController(sync: true); |
86 var outputController = new StreamController(sync: true); | 85 var outputController = new StreamController(sync: true); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 }); | 166 }); |
168 | 167 |
169 liveTest.onPrint.listen((line) { | 168 liveTest.onPrint.listen((line) { |
170 print(line); | 169 print(line); |
171 channel.sink.add({"type": "print", "line": line}); | 170 channel.sink.add({"type": "print", "line": line}); |
172 }); | 171 }); |
173 | 172 |
174 liveTest.run().then((_) => channel.sink.add({"type": "complete"})); | 173 liveTest.run().then((_) => channel.sink.add({"type": "complete"})); |
175 } | 174 } |
176 } | 175 } |
OLD | NEW |