| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 part of html; | 5 part of html; |
| 6 | 6 |
| 7 // This API is exploratory. | 7 _makeSendPortFuture(spawnRequest) { |
| 8 Future<SendPort> spawnDomFunction(Function topLevelFunction) { | |
| 9 final completer = new Completer<SendPort>(); | 8 final completer = new Completer<SendPort>(); |
| 10 final port = new ReceivePort(); | 9 final port = new ReceivePort(); |
| 11 port.receive((result, _) { | 10 port.receive((result, _) { |
| 12 completer.complete(result); | 11 completer.complete(result); |
| 13 port.close(); | 12 port.close(); |
| 14 }); | 13 }); |
| 15 // TODO: SendPort.hashCode is ugly way to access port id. | 14 // TODO: SendPort.hashCode is ugly way to access port id. |
| 16 _Utils.spawnDomFunction(topLevelFunction, port.toSendPort().hashCode); | 15 spawnRequest(port.toSendPort().hashCode); |
| 17 return completer.future; | 16 return completer.future; |
| 18 } | 17 } |
| 19 | 18 |
| 19 // This API is exploratory. |
| 20 Future<SendPort> spawnDomFunction(Function f) => |
| 21 _makeSendPortFuture((portId) { _Utils.spawnDomFunction(f, portId); }); |
| 22 |
| 23 Future<SendPort> spawnDomUri(String uri) => |
| 24 _makeSendPortFuture((portId) { _Utils.spawnDomUri(uri, portId); }); |
| 25 |
| 20 // testRunner implementation. | 26 // testRunner implementation. |
| 21 // FIXME: provide a separate lib for testRunner. | 27 // FIXME: provide a separate lib for testRunner. |
| 22 | 28 |
| 23 var _testRunner; | 29 var _testRunner; |
| 24 | 30 |
| 25 TestRunner get testRunner { | 31 TestRunner get testRunner { |
| 26 if (_testRunner == null) | 32 if (_testRunner == null) |
| 27 _testRunner = new TestRunner._(_NPObject.retrieve("testRunner")); | 33 _testRunner = new TestRunner._(_NPObject.retrieve("testRunner")); |
| 28 return _testRunner; | 34 return _testRunner; |
| 29 } | 35 } |
| 30 | 36 |
| 31 class TestRunner { | 37 class TestRunner { |
| 32 final _NPObject _npObject; | 38 final _NPObject _npObject; |
| 33 | 39 |
| 34 TestRunner._(this._npObject); | 40 TestRunner._(this._npObject); |
| 35 | 41 |
| 36 display() => _npObject.invoke('display'); | 42 display() => _npObject.invoke('display'); |
| 37 dumpAsText() => _npObject.invoke('dumpAsText'); | 43 dumpAsText() => _npObject.invoke('dumpAsText'); |
| 38 notifyDone() => _npObject.invoke('notifyDone'); | 44 notifyDone() => _npObject.invoke('notifyDone'); |
| 39 setCanOpenWindows() => _npObject.invoke('setCanOpenWindows'); | 45 setCanOpenWindows() => _npObject.invoke('setCanOpenWindows'); |
| 40 waitUntilDone() => _npObject.invoke('waitUntilDone'); | 46 waitUntilDone() => _npObject.invoke('waitUntilDone'); |
| 41 } | 47 } |
| OLD | NEW |