| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 "url": url.toString(), | 49 "url": url.toString(), |
| 50 "channel": suiteChannel.id | 50 "channel": suiteChannel.id |
| 51 }); | 51 }); |
| 52 | 52 |
| 53 // Create a nested MultiChannel because the iframe will be using a channel | 53 // Create a nested MultiChannel because the iframe will be using a channel |
| 54 // wrapped within the host's channel. | 54 // wrapped within the host's channel. |
| 55 suiteChannel = new MultiChannel(suiteChannel.stream, suiteChannel.sink); | 55 suiteChannel = new MultiChannel(suiteChannel.stream, suiteChannel.sink); |
| 56 | 56 |
| 57 // The stream may close before emitting a value if the browser is killed | 57 // The stream may close before emitting a value if the browser is killed |
| 58 // prematurely (e.g. via Control-C). | 58 // prematurely (e.g. via Control-C). |
| 59 return maybeFirst(suiteChannel.stream).then((response) { | 59 return maybeFirst(suiteChannel.stream) |
| 60 .timeout(new Duration(seconds: 7), onTimeout: () { |
| 61 throw new LoadException( |
| 62 path, "Timed out waiting for the test suite to connect."); |
| 63 }).then((response) { |
| 60 if (response == null) return null; | 64 if (response == null) return null; |
| 61 | 65 |
| 62 if (response["type"] == "loadException") { | 66 if (response["type"] == "loadException") { |
| 63 return new Future.error(new LoadException(path, response["message"])); | 67 return new Future.error(new LoadException(path, response["message"])); |
| 64 } else if (response["type"] == "error") { | 68 } else if (response["type"] == "error") { |
| 65 var asyncError = RemoteException.deserialize(response["error"]); | 69 var asyncError = RemoteException.deserialize(response["error"]); |
| 66 return new Future.error( | 70 return new Future.error( |
| 67 new LoadException(path, asyncError.error), | 71 new LoadException(path, asyncError.error), |
| 68 asyncError.stackTrace); | 72 asyncError.stackTrace); |
| 69 } | 73 } |
| 70 | 74 |
| 71 return new Suite(response["tests"].map((test) { | 75 return new Suite(response["tests"].map((test) { |
| 72 var testMetadata = new Metadata.deserialize(test['metadata']); | 76 var testMetadata = new Metadata.deserialize(test['metadata']); |
| 73 var testChannel = suiteChannel.virtualChannel(test['channel']); | 77 var testChannel = suiteChannel.virtualChannel(test['channel']); |
| 74 return new IframeTest(test['name'], testMetadata, testChannel); | 78 return new IframeTest(test['name'], testMetadata, testChannel); |
| 75 }), metadata: metadata, path: path); | 79 }), metadata: metadata, path: path); |
| 76 }); | 80 }); |
| 77 } | 81 } |
| 78 } | 82 } |
| OLD | NEW |