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.dartium; | 5 library test.runner.browser.dartium; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 /// Most of the communication with the browser is expected to happen via HTTP, | 23 /// Most of the communication with the browser is expected to happen via HTTP, |
24 /// so this exposes a bare-bones API. The browser starts as soon as the class is | 24 /// so this exposes a bare-bones API. The browser starts as soon as the class is |
25 /// constructed, and is killed when [close] is called. | 25 /// constructed, and is killed when [close] is called. |
26 /// | 26 /// |
27 /// Any errors starting or running the process are reported through [onExit]. | 27 /// Any errors starting or running the process are reported through [onExit]. |
28 class Dartium extends Browser { | 28 class Dartium extends Browser { |
29 final name = "Dartium"; | 29 final name = "Dartium"; |
30 | 30 |
31 final Future<Uri> observatoryUrl; | 31 final Future<Uri> observatoryUrl; |
32 | 32 |
33 factory Dartium(url, {String executable}) { | 33 factory Dartium(url, {String executable, bool debug: false}) { |
34 var completer = new Completer.sync(); | 34 var completer = new Completer.sync(); |
35 return new Dartium._(() async { | 35 return new Dartium._(() async { |
36 if (executable == null) executable = _defaultExecutable(); | 36 if (executable == null) executable = _defaultExecutable(); |
37 | 37 |
38 var dir = createTempDir(); | 38 var dir = createTempDir(); |
39 var process = await Process.start(executable, [ | 39 var process = await Process.start(executable, [ |
40 "--user-data-dir=$dir", | 40 "--user-data-dir=$dir", |
41 url.toString(), | 41 url.toString(), |
42 "--disable-extensions", | 42 "--disable-extensions", |
43 "--disable-popup-blocking", | 43 "--disable-popup-blocking", |
44 "--bwsi", | 44 "--bwsi", |
45 "--no-first-run", | 45 "--no-first-run", |
46 "--no-default-browser-check", | 46 "--no-default-browser-check", |
47 "--disable-default-apps", | 47 "--disable-default-apps", |
48 "--disable-translate" | 48 "--disable-translate" |
49 ], environment: {"DART_FLAGS": "--checked"}); | 49 ], environment: {"DART_FLAGS": "--checked"}); |
50 | 50 |
51 // The first observatory URL emitted is for the empty start page; the | 51 if (debug) { |
52 // second is actually for the host page. | 52 completer.complete(_getObservatoryUrl(process.stdout)); |
53 completer.complete(_getObservatoryUrl(process.stdout)); | 53 } else { |
| 54 completer.complete(null); |
| 55 } |
54 | 56 |
55 process.exitCode | 57 process.exitCode |
56 .then((_) => new Directory(dir).deleteSync(recursive: true)); | 58 .then((_) => new Directory(dir).deleteSync(recursive: true)); |
57 | 59 |
58 return process; | 60 return process; |
59 }, completer.future); | 61 }, completer.future); |
60 } | 62 } |
61 | 63 |
62 Dartium._(Future<Process> startBrowser(), this.observatoryUrl) | 64 Dartium._(Future<Process> startBrowser(), this.observatoryUrl) |
63 : super(startBrowser); | 65 : super(startBrowser); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // incorrect WebSocket that already closed. | 244 // incorrect WebSocket that already closed. |
243 return null; | 245 return null; |
244 } | 246 } |
245 }).catchError((error, stackTrace) { | 247 }).catchError((error, stackTrace) { |
246 if (!completer.isCompleted) completer.completeError(error, stackTrace); | 248 if (!completer.isCompleted) completer.completeError(error, stackTrace); |
247 }); | 249 }); |
248 | 250 |
249 return completer.future; | 251 return completer.future; |
250 } | 252 } |
251 } | 253 } |
OLD | NEW |