diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index e277380dc..ade85d735 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.3-dev + +- Handle `org-dartlang-app` scheme library uris and convert them to match the + dart uris that we will see in the sourcemaps. + ## 0.3.2 - Add support for `scope` in `evaluate` calls. diff --git a/dwds/lib/src/chrome_proxy_service.dart b/dwds/lib/src/chrome_proxy_service.dart index 150722208..bca607669 100644 --- a/dwds/lib/src/chrome_proxy_service.dart +++ b/dwds/lib/src/chrome_proxy_service.dart @@ -6,6 +6,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:path/path.dart' as p; import 'package:pedantic/pedantic.dart'; import 'package:pub_semver/pub_semver.dart' as semver; import 'package:vm_service_lib/vm_service_lib.dart'; @@ -119,11 +120,21 @@ class ChromeProxyService implements VmServiceInterface { ..kind = EventKind.kResume ..isolate = isolateRef; - for (var library in await _getLibraryNames()) { + for (var uri in await _getLibraryUris()) { + // The `org-dartlang-app` scheme is used to reference files that are not + // under the `lib` directory (and thus can't be referenced using a + // `package` scheme). + // + // We want to make these match the uris in the source map, which are + // relative to a top level directory in the package (such as `web` or + // `test`), so we strip the scheme and skip the first path segment. + var sourceMapUri = uri.scheme == 'org-dartlang-app' + ? p.url.joinAll(['/'].followedBy(uri.pathSegments.skip(1))) + : '$uri'; isolate.libraries.add(LibraryRef() - ..id = library - ..name = library - ..uri = library); + ..id = sourceMapUri + ..name = sourceMapUri + ..uri = sourceMapUri); } // TODO: Something more robust here, right now we rely on the 2nd to last @@ -803,13 +814,16 @@ function($argsString) { } /// Runs an eval on the page to compute all the library names in the app. - Future> _getLibraryNames() async { + Future> _getLibraryUris() async { var expression = "require('dart_sdk').dart.getLibraries();"; var librariesResult = await tabConnection.runtime.sendCommand( 'Runtime.evaluate', params: {'expression': expression, 'returnByValue': true}); _handleErrorIfPresent(librariesResult, evalContents: expression); - return List.from(librariesResult.result['result']['value'] as List); + return (librariesResult.result['result']['value'] as List) + .cast() + .map(Uri.parse) + .toList(); } /// Listens for chrome console events and handles the ones we care about. diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml index 372eb36e7..6feb439a6 100644 --- a/dwds/pubspec.yaml +++ b/dwds/pubspec.yaml @@ -1,5 +1,5 @@ name: dwds -version: 0.3.2 +version: 0.3.3-dev author: Dart Team homepage: https://github.com/dart-lang/webdev/tree/master/dwds description: >- diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index e63e71162..0915e4b16 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -242,7 +242,8 @@ void main() { expect(result, const TypeMatcher()); var isolate = result as Isolate; expect(isolate.name, contains(context.appUrl)); - // TODO: library names change with kernel dart-lang/sdk#36736 + // TODO(jakemac): Update to the full expected uri `/hello_world/main.dart` + // once the next dev sdk comes out. expect(isolate.rootLib.uri, endsWith('main.dart')); expect( diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index 441007300..532dafe09 100644 --- a/webdev/pubspec.yaml +++ b/webdev/pubspec.yaml @@ -49,5 +49,9 @@ dev_dependencies: uuid: ^2.0.0 webdriver: ^2.0.0 +dependency_overrides: + dwds: + path: ../dwds + executables: webdev: