| 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.browser_manager; | 5 library test.runner.browser.browser_manager; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:http_parser/http_parser.dart'; | 10 import 'package:http_parser/http_parser.dart'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 var suiteChannel = _channel.virtualChannel(); | 43 var suiteChannel = _channel.virtualChannel(); |
| 44 _channel.sink.add({ | 44 _channel.sink.add({ |
| 45 "command": "loadSuite", | 45 "command": "loadSuite", |
| 46 "url": url.toString(), | 46 "url": url.toString(), |
| 47 "channel": suiteChannel.id | 47 "channel": suiteChannel.id |
| 48 }); | 48 }); |
| 49 | 49 |
| 50 // Create a nested MultiChannel because the iframe will be using a channel | 50 // Create a nested MultiChannel because the iframe will be using a channel |
| 51 // wrapped within the host's channel. | 51 // wrapped within the host's channel. |
| 52 suiteChannel = new MultiChannel(suiteChannel.stream, suiteChannel.sink); | 52 suiteChannel = new MultiChannel(suiteChannel.stream, suiteChannel.sink); |
| 53 return suiteChannel.stream.first.then((response) { | 53 |
| 54 // The stream may close before emitting a value if the browser is killed |
| 55 // prematurely (e.g. via Control-C). |
| 56 return maybeFirst(suiteChannel.stream).then((response) { |
| 57 if (response == null) return null; |
| 58 |
| 54 if (response["type"] == "loadException") { | 59 if (response["type"] == "loadException") { |
| 55 return new Future.error(new LoadException(path, response["message"])); | 60 return new Future.error(new LoadException(path, response["message"])); |
| 56 } else if (response["type"] == "error") { | 61 } else if (response["type"] == "error") { |
| 57 var asyncError = RemoteException.deserialize(response["error"]); | 62 var asyncError = RemoteException.deserialize(response["error"]); |
| 58 return new Future.error( | 63 return new Future.error( |
| 59 new LoadException(path, asyncError.error), | 64 new LoadException(path, asyncError.error), |
| 60 asyncError.stackTrace); | 65 asyncError.stackTrace); |
| 61 } | 66 } |
| 62 | 67 |
| 63 return new Suite(response["tests"].map((test) { | 68 return new Suite(response["tests"].map((test) { |
| 64 var metadata = new Metadata.deserialize(test['metadata']); | 69 var metadata = new Metadata.deserialize(test['metadata']); |
| 65 var testChannel = suiteChannel.virtualChannel(test['channel']); | 70 var testChannel = suiteChannel.virtualChannel(test['channel']); |
| 66 return new IframeTest(test['name'], metadata, testChannel); | 71 return new IframeTest(test['name'], metadata, testChannel); |
| 67 }), path: path); | 72 }), path: path); |
| 68 }); | 73 }); |
| 69 } | 74 } |
| 70 } | 75 } |
| OLD | NEW |