@@ -15,7 +15,6 @@ import '../base/logger.dart';
15
15
import '../base/os.dart' ;
16
16
import '../base/platform.dart' ;
17
17
import '../convert.dart' ;
18
- import '../globals.dart' as globals;
19
18
20
19
/// An environment variable used to override the location of Google Chrome.
21
20
const String kChromeEnvironment = 'CHROME_EXECUTABLE' ;
@@ -105,14 +104,14 @@ class ChromiumLauncher {
105
104
@required Platform platform,
106
105
@required ProcessManager processManager,
107
106
@required OperatingSystemUtils operatingSystemUtils,
108
- @required Logger logger,
109
107
@required BrowserFinder browserFinder,
108
+ @required Logger logger,
110
109
}) : _fileSystem = fileSystem,
111
110
_platform = platform,
112
111
_processManager = processManager,
113
112
_operatingSystemUtils = operatingSystemUtils,
114
- _logger = logger,
115
113
_browserFinder = browserFinder,
114
+ _logger = logger,
116
115
_fileSystemUtils = FileSystemUtils (
117
116
fileSystem: fileSystem,
118
117
platform: platform,
@@ -122,9 +121,9 @@ class ChromiumLauncher {
122
121
final Platform _platform;
123
122
final ProcessManager _processManager;
124
123
final OperatingSystemUtils _operatingSystemUtils;
125
- Logger _logger;
126
124
final BrowserFinder _browserFinder;
127
125
final FileSystemUtils _fileSystemUtils;
126
+ final Logger _logger;
128
127
129
128
bool get hasChromeInstance => _currentCompleter.isCompleted;
130
129
@@ -163,7 +162,6 @@ class ChromiumLauncher {
163
162
bool skipCheck = false ,
164
163
Directory cacheDir,
165
164
}) async {
166
- _logger ?? = globals.logger;
167
165
if (_currentCompleter.isCompleted) {
168
166
throwToolExit ('Only one instance of chrome can be started.' );
169
167
}
@@ -207,21 +205,15 @@ class ChromiumLauncher {
207
205
208
206
final Process process = await _processManager.start (args);
209
207
210
- // When the process exits, copy the user settings back to the provided data-dir.
211
- if (cacheDir != null ) {
212
- unawaited (process.exitCode.whenComplete (() {
213
- _cacheUserSessionInformation (userDataDir, cacheDir);
214
- }));
215
- }
216
-
217
208
process.stdout
218
209
.transform (utf8.decoder)
219
210
.transform (const LineSplitter ())
220
211
.listen ((String line) {
221
212
_logger.printTrace ('[CHROME]: $line ' );
222
213
});
223
214
224
- // Wait until the DevTools are listening before trying to connect.
215
+ // Wait until the DevTools are listening before trying to connect. This is
216
+ // only required for flutter_test --platform=chrome and not flutter run.
225
217
await process.stderr
226
218
.transform (utf8.decoder)
227
219
.transform (const LineSplitter ())
@@ -232,13 +224,18 @@ class ChromiumLauncher {
232
224
.firstWhere ((String line) => line.startsWith ('DevTools listening' ), orElse: () {
233
225
return 'Failed to spawn stderr' ;
234
226
});
235
- final Uri remoteDebuggerUri = await _getRemoteDebuggerUrl (Uri .parse ('http://localhost:$port ' ));
227
+
228
+ // When the process exits, copy the user settings back to the provided data-dir.
229
+ if (cacheDir != null ) {
230
+ unawaited (process.exitCode.whenComplete (() {
231
+ _cacheUserSessionInformation (userDataDir, cacheDir);
232
+ }));
233
+ }
236
234
return _connect (Chromium ._(
237
235
port,
238
236
ChromeConnection ('localhost' , port),
239
237
url: url,
240
238
process: process,
241
- remoteDebuggerUri: remoteDebuggerUri,
242
239
chromiumLauncher: this ,
243
240
), skipCheck);
244
241
}
@@ -311,28 +308,6 @@ class ChromiumLauncher {
311
308
}
312
309
313
310
Future <Chromium > get connectedInstance => _currentCompleter.future;
314
-
315
- /// Returns the full URL of the Chrome remote debugger for the main page.
316
- ///
317
- /// This takes the [base] remote debugger URL (which points to a browser-wide
318
- /// page) and uses its JSON API to find the resolved URL for debugging the host
319
- /// page.
320
- Future <Uri > _getRemoteDebuggerUrl (Uri base ) async {
321
- try {
322
- final HttpClient client = HttpClient ();
323
- final HttpClientRequest request = await client.getUrl (base .resolve ('/json/list' ));
324
- final HttpClientResponse response = await request.close ();
325
- final List <dynamic > jsonObject = await json.fuse (utf8).decoder.bind (response).single as List <dynamic >;
326
- if (jsonObject == null || jsonObject.isEmpty) {
327
- return base ;
328
- }
329
- return base .resolve (jsonObject.first['devtoolsFrontendUrl' ] as String );
330
- } on Exception {
331
- // If we fail to talk to the remote debugger protocol, give up and return
332
- // the raw URL rather than crashing.
333
- return base ;
334
- }
335
- }
336
311
}
337
312
338
313
/// A class for managing an instance of a Chromium browser.
@@ -342,7 +317,6 @@ class Chromium {
342
317
this .chromeConnection, {
343
318
this .url,
344
319
Process process,
345
- this .remoteDebuggerUri,
346
320
@required ChromiumLauncher chromiumLauncher,
347
321
}) : _process = process,
348
322
_chromiumLauncher = chromiumLauncher;
@@ -351,7 +325,6 @@ class Chromium {
351
325
final int debugPort;
352
326
final Process _process;
353
327
final ChromeConnection chromeConnection;
354
- final Uri remoteDebuggerUri;
355
328
final ChromiumLauncher _chromiumLauncher;
356
329
357
330
Future <int > get onExit => _process.exitCode;
0 commit comments