[ Tool ] Set `VM_SERVICE_URL` to the VM service URL for web driver tests Fixes https://github.com/flutter/flutter/issues/172220
diff --git a/packages/flutter_tools/lib/src/drive/web_driver_service.dart b/packages/flutter_tools/lib/src/drive/web_driver_service.dart index 75e7e08..5b89e8e 100644 --- a/packages/flutter_tools/lib/src/drive/web_driver_service.dart +++ b/packages/flutter_tools/lib/src/drive/web_driver_service.dart
@@ -51,6 +51,7 @@ late ResidentRunner _residentRunner; Uri? _webUri; + final _connectionInfoCompleter = Completer<DebugConnectionInfo>.sync(); @visibleForTesting Uri? get webUri => _webUri; @@ -109,6 +110,7 @@ final appStartedCompleter = Completer<void>.sync(); final Future<int?> runFuture = _residentRunner.run( appStartedCompleter: appStartedCompleter, + connectionInfoCompleter: _connectionInfoCompleter, route: route, ); @@ -221,11 +223,13 @@ await window.setLocation(const math.Point<int>(0, 0)); await window.setSize(math.Rectangle<int>(0, 0, width, height)); } + final DebugConnectionInfo debugConnectionInfo = await _connectionInfoCompleter.future; final int result = await _processUtils.stream( <String>[_dartSdkPath, ...arguments, testFile], environment: <String, String>{ ..._platform.environment, - 'VM_SERVICE_URL': _webUri.toString(), + if (debugConnectionInfo.wsUri != null) + 'VM_SERVICE_URL': debugConnectionInfo.wsUri.toString(), ..._additionalDriverEnvironment(webDriver, browserName, androidEmulator), }, );