Skip to content

Commit 4131f1f

Browse files
author
Anna Gringauze
authored
Hotfix: support Chrome 100 update (#1566)
* Hotfix: support Chrome 100 update * Update version and build
1 parent 1ddc710 commit 4131f1f

File tree

10 files changed

+361
-455
lines changed

10 files changed

+361
-455
lines changed

dwds/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 11.5.2
2+
3+
- Hotfix: Fix missing `CallFrame.url` after update to Chrome 100.
4+
15
## 11.5.1
26

37
- Update SDK contraint to `>=2.15.0 <3.0.0`.

dwds/debug_extension/web/background.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,6 @@ void _filterAndForward(Debuggee source, String method, Object params) {
384384

385385
if (debugSession == null) return;
386386

387-
if (method == 'Debugger.scriptParsed') return;
388-
389387
var event = _extensionEventFor(method, params);
390388

391389
debugSession.socketClient.sink.add(jsonEncode(serializers.serialize(event)));

dwds/lib/src/debugging/debugger.dart

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,22 @@ class Debugger extends Domain {
307307
}
308308
}
309309

310+
/// Returns Chrome script uri for Chrome script ID.
311+
String _urlForScriptId(String scriptId) =>
312+
_remoteDebugger.scripts[scriptId]?.url;
313+
310314
/// Returns source [Location] for the paused event.
311315
///
312316
/// If we do not have [Location] data for the embedded JS location, null is
313317
/// returned.
314318
Future<Location> _sourceLocation(DebuggerPausedEvent e) {
315319
var frame = e.params['callFrames'][0];
316320
var location = frame['location'];
317-
return _locations.locationForJs(
318-
frame['url'] as String, (location['lineNumber'] as int) + 1);
321+
var scriptId = location['scriptId'] as String;
322+
var lineNumber = location['lineNumber'] as int;
323+
324+
var url = _urlForScriptId(scriptId);
325+
return _locations.locationForJs(url, lineNumber + 1);
319326
}
320327

321328
/// The variables visible in a frame in Dart protocol [BoundVariable] form.
@@ -427,10 +434,17 @@ class Debugger extends Domain {
427434
// Chrome is 0 based. Account for this.
428435
var line = location.lineNumber + 1;
429436
var column = location.columnNumber + 1;
437+
438+
var url = _urlForScriptId(location.scriptId);
439+
if (url == null) {
440+
logger.severe('Failed to create dart frame for ${frame.functionName}: '
441+
'cannot find location for script ${location.scriptId}');
442+
}
443+
430444
// TODO(sdk/issues/37240) - ideally we look for an exact location instead
431445
// of the closest location on a given line.
432446
Location bestLocation;
433-
for (var location in await _locations.locationsForUrl(frame.url)) {
447+
for (var location in await _locations.locationsForUrl(url)) {
434448
if (location.jsLocation.line == line) {
435449
bestLocation ??= location;
436450
if ((location.jsLocation.column - column).abs() <
@@ -530,8 +544,14 @@ class Debugger extends Domain {
530544
// If we don't have source location continue stepping.
531545
if (_isStepping && (await _sourceLocation(e)) == null) {
532546
var frame = e.params['callFrames'][0];
533-
var url = '${frame["url"]}';
534547
var scriptId = '${frame["location"]["scriptId"]}';
548+
549+
var url = _urlForScriptId(scriptId);
550+
if (url == null) {
551+
logger.severe('Stepping failed: '
552+
'cannot find location for script $scriptId');
553+
}
554+
535555
// TODO(grouma) - In the future we should send all previously computed
536556
// skipLists.
537557
await _remoteDebugger.stepInto(params: {

dwds/lib/src/debugging/modules.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ class Modules {
2020
final _sourceToLibrary = <String, Uri>{};
2121
var _moduleMemoizer = AsyncMemoizer<void>();
2222

23-
// The Chrome script ID to corresponding module.
24-
final _scriptIdToModule = <String, String>{};
25-
2623
final Map<String, String> _libraryToModule = {};
2724

2825
String _entrypoint;
@@ -43,9 +40,6 @@ class Modules {
4340
_entrypoint = entrypoint;
4441
}
4542

46-
/// Returns the module for the Chrome script ID.
47-
String moduleForScriptId(String scriptId) => _scriptIdToModule[scriptId];
48-
4943
/// Returns the containing module for the provided Dart server path.
5044
Future<String> moduleForSource(String serverPath) async {
5145
await _moduleMemoizer.runOnce(_initializeMapping);

dwds/lib/src/injected/client.js

Lines changed: 307 additions & 430 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/lib/src/services/expression_evaluator.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class ExpressionEvaluator {
149149

150150
var functionName = jsFrame.functionName;
151151
var jsLine = jsFrame.location.lineNumber + 1;
152+
var jsScriptId = jsFrame.location.scriptId;
152153
var jsScope = await _collectLocalJsScope(jsFrame);
153154

154155
// Find corresponding dart location and scope.
@@ -158,12 +159,13 @@ class ExpressionEvaluator {
158159
// so this will result in expressions not evaluated in some
159160
// cases. Invent location matching strategy for those cases.
160161
// [issue 890](https://github.com/dart-lang/webdev/issues/890)
161-
var locationMap = await _locations.locationForJs(jsFrame.url, jsLine);
162+
var url = _urlForScriptId(jsScriptId);
163+
var locationMap = await _locations.locationForJs(url, jsLine);
162164
if (locationMap == null) {
163165
return _createError(
164166
ErrorKind.internal,
165167
'Cannot find Dart location for JS location: '
166-
'url: ${jsFrame.url}'
168+
'url: $url, '
167169
'function: $functionName, '
168170
'line: $jsLine');
169171
}
@@ -300,4 +302,8 @@ class ExpressionEvaluator {
300302

301303
return jsScope;
302304
}
305+
306+
/// Returns Chrome script uri for Chrome script ID.
307+
String _urlForScriptId(String scriptId) =>
308+
_inspector.remoteDebugger.scripts[scriptId]?.url;
303309
}

dwds/lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dwds
22
# Every time this changes you need to run `dart run build_runner build`.
3-
version: 11.5.1
3+
version: 11.5.2
44
homepage: https://github.com/dart-lang/webdev/tree/master/dwds
55
description: >-
66
A service that proxies between the Chrome debug protocol and the Dart VM

dwds/test/debugger_test.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'package:dwds/src/loaders/strategy.dart';
1717
import 'package:test/test.dart';
1818
import 'package:vm_service/vm_service.dart';
1919
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
20-
show CallFrame, DebuggerPausedEvent, StackTrace, WipCallFrame;
20+
show CallFrame, DebuggerPausedEvent, StackTrace, WipCallFrame, WipScript;
2121

2222
import 'fixtures/context.dart';
2323
import 'fixtures/debugger_data.dart';
@@ -72,22 +72,31 @@ final sampleSyncFrame = WipCallFrame({
7272
'columnNumber': 72,
7373
},
7474
'location': {'scriptId': '69', 'lineNumber': 37, 'columnNumber': 0},
75-
'url': 'http://127.0.0.1:8081/foo.ddc.js',
75+
'url': '',
7676
'scopeChain': [],
7777
'this': {'type': 'undefined'},
7878
});
7979

8080
final sampleAsyncFrame = CallFrame({
8181
'functionName': 'myFunc',
82-
'url': 'http://127.0.0.1:8081/bar.ddc.js',
82+
'url': '',
8383
'scriptId': '71',
8484
'lineNumber': 40,
8585
'columnNumber': 1,
8686
});
8787

88+
final Map<String, WipScript> scripts = {
89+
'69': WipScript(<String, dynamic>{
90+
'url': 'http://127.0.0.1:8081/foo.ddc.js',
91+
}),
92+
'71': WipScript(<String, dynamic>{
93+
'url': 'http://127.0.0.1:8081/bar.ddc.js',
94+
}),
95+
};
96+
8897
void main() async {
8998
setUpAll(() async {
90-
webkitDebugger = FakeWebkitDebugger();
99+
webkitDebugger = FakeWebkitDebugger(scripts: scripts);
91100
pausedController = StreamController<DebuggerPausedEvent>();
92101
webkitDebugger.onPaused = pausedController.stream;
93102
globalLoadStrategy = TestStrategy();

dwds/test/fixtures/fakes.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ class FakeModules implements Modules {
115115
throw UnimplementedError();
116116
}
117117

118-
@override
119-
String moduleForScriptId(String serverId) => '';
120-
121118
@override
122119
Future<String> moduleForSource(String serverPath) {
123120
throw UnimplementedError();
@@ -135,13 +132,14 @@ class FakeModules implements Modules {
135132
}
136133

137134
class FakeWebkitDebugger implements WebkitDebugger {
135+
final Map<String, WipScript> _scripts;
138136
@override
139137
Future disable() => null;
140138

141139
@override
142140
Future enable() => null;
143141

144-
FakeWebkitDebugger() {
142+
FakeWebkitDebugger({Map<String, WipScript> scripts}) : _scripts = scripts {
145143
globalLoadStrategy = RequireStrategy(
146144
ReloadConfiguration.none,
147145
(_) async => {},
@@ -185,7 +183,7 @@ class FakeWebkitDebugger implements WebkitDebugger {
185183
Future<WipResponse> resume() => null;
186184

187185
@override
188-
Map<String, WipScript> get scripts => null;
186+
Map<String, WipScript> get scripts => _scripts;
189187

190188
List<WipResponse> results = variables1;
191189
int resultsReturned = 0;

0 commit comments

Comments
 (0)