diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 396d4d514..6f48bf8ed 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -2,6 +2,7 @@ - Update to be forward compatible with changes to `package:shelf_web_socket`. - Added support for some debugging APIs with the DDC library bundle format. - [#2537](https://github.com/dart-lang/webdev/issues/2537) +- Added support for some debugging APIs with the DDC library bundle format. - [#2537](https://github.com/dart-lang/webdev/issues/2537),[#2544](https://github.com/dart-lang/webdev/issues/2544) - Expose a partial implementation of `FrontendServerDdcLibraryBundleStrategyProvider`. - Update `package:vm_service_interface` to '^2.0.1'. diff --git a/dwds/lib/src/debugging/dart_runtime_debugger.dart b/dwds/lib/src/debugging/dart_runtime_debugger.dart index 0a8cd4d2f..90b47d581 100644 --- a/dwds/lib/src/debugging/dart_runtime_debugger.dart +++ b/dwds/lib/src/debugging/dart_runtime_debugger.dart @@ -160,4 +160,13 @@ class DartRuntimeDebugger { 'getSetElements(this)', ); } + + /// Generates a JS expression for retrieving the fields of a record. + String getRecordFieldsJsExpression() { + return _buildExpression( + '', + 'getRecordFields(this)', + 'getRecordFields(this)', + ); + } } diff --git a/dwds/lib/src/debugging/instance.dart b/dwds/lib/src/debugging/instance.dart index 35c8698f9..2815b255a 100644 --- a/dwds/lib/src/debugging/instance.dart +++ b/dwds/lib/src/debugging/instance.dart @@ -524,7 +524,8 @@ class InstanceHelper extends Domain { // We do this in in awkward way because we want the keys and values, but we // can't return things by value or some Dart objects will come back as // values that we need to be RemoteObject, e.g. a List of int. - final expression = _jsRuntimeFunctionCall('getRecordFields(this)'); + final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger + .getRecordFieldsJsExpression(); final result = await inspector.jsCallFunctionOn(record, expression, []); final fieldNameElements = diff --git a/dwds/test/instances/common/record_inspection_common.dart b/dwds/test/instances/common/record_inspection_common.dart index a5e6e837d..a1bbdd161 100644 --- a/dwds/test/instances/common/record_inspection_common.dart +++ b/dwds/test/instances/common/record_inspection_common.dart @@ -66,6 +66,7 @@ void runTests({ verboseCompiler: debug, experiments: ['records', 'patterns'], canaryFeatures: canaryFeatures, + moduleFormat: provider.ddcModuleFormat, ), ); service = context.debugConnection.vmService; diff --git a/dwds/test/instances/record_inspection_canary_test.dart b/dwds/test/instances/record_inspection_amd_canary_test.dart similarity index 84% rename from dwds/test/instances/record_inspection_canary_test.dart rename to dwds/test/instances/record_inspection_amd_canary_test.dart index c1b79e7cb..7c2c5c0a8 100644 --- a/dwds/test/instances/record_inspection_canary_test.dart +++ b/dwds/test/instances/record_inspection_amd_canary_test.dart @@ -1,4 +1,4 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -7,6 +7,7 @@ @Timeout(Duration(minutes: 2)) library; +import 'package:dwds/src/services/expression_compiler.dart'; import 'package:test/test.dart'; import 'package:test_common/test_sdk_configuration.dart'; @@ -22,6 +23,7 @@ void main() { final provider = TestSdkConfigurationProvider( verbose: debug, canaryFeatures: canaryFeatures, + ddcModuleFormat: ModuleFormat.amd, ); tearDownAll(provider.dispose); diff --git a/dwds/test/instances/record_inspection_test.dart b/dwds/test/instances/record_inspection_amd_test.dart similarity index 84% rename from dwds/test/instances/record_inspection_test.dart rename to dwds/test/instances/record_inspection_amd_test.dart index a8af90b88..afee36510 100644 --- a/dwds/test/instances/record_inspection_test.dart +++ b/dwds/test/instances/record_inspection_amd_test.dart @@ -1,4 +1,4 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -7,6 +7,7 @@ @Timeout(Duration(minutes: 2)) library; +import 'package:dwds/src/services/expression_compiler.dart'; import 'package:test/test.dart'; import 'package:test_common/test_sdk_configuration.dart'; @@ -22,6 +23,7 @@ void main() { final provider = TestSdkConfigurationProvider( verbose: debug, canaryFeatures: canaryFeatures, + ddcModuleFormat: ModuleFormat.amd, ); tearDownAll(provider.dispose); diff --git a/dwds/test/instances/record_inspection_ddc_library_bundle_test.dart b/dwds/test/instances/record_inspection_ddc_library_bundle_test.dart new file mode 100644 index 000000000..deb18060a --- /dev/null +++ b/dwds/test/instances/record_inspection_ddc_library_bundle_test.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +@Tags(['daily']) +@TestOn('vm') +@Timeout(Duration(minutes: 2)) +library; + +import 'package:dwds/src/services/expression_compiler.dart'; +import 'package:test/test.dart'; +import 'package:test_common/test_sdk_configuration.dart'; + +import '../fixtures/context.dart'; +import 'common/record_inspection_common.dart'; + +void main() { + // Enable verbose logging for debugging. + final debug = false; + final canaryFeatures = true; + final compilationMode = CompilationMode.frontendServer; + + group('canary: $canaryFeatures |', () { + final provider = TestSdkConfigurationProvider( + verbose: debug, + canaryFeatures: canaryFeatures, + ddcModuleFormat: ModuleFormat.ddc, + ); + tearDownAll(provider.dispose); + runTests( + provider: provider, + compilationMode: compilationMode, + canaryFeatures: canaryFeatures, + debug: debug, + ); + }); +}