Skip to content

Commit fa4e3eb

Browse files
author
Anna Gringauze
committed
Added tests and updated version
1 parent 8a52285 commit fa4e3eb

File tree

10 files changed

+98
-19
lines changed

10 files changed

+98
-19
lines changed

dwds/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 13.1.1-dev
2+
- Add column information to breakpoints to allow precise breakpoint placement.
3+
14
## 13.1.0
25
- Update _fe_analyzer_shared to version ^38.0.0.
36

dwds/lib/src/debugging/debugger.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,8 @@ int _columnNumberFor(Breakpoint breakpoint) =>
736736

737737
/// Returns the breakpoint ID for the provided Dart script ID and Dart line
738738
/// number.
739-
String breakpointIdFor(String scriptId, int line, int column) {
740-
var id = 'bp/$scriptId#$line:$column';
741-
print('breakpointIdFor: $scriptId, $line, $column: $id');
742-
return id;
743-
}
739+
String breakpointIdFor(String scriptId, int line, int column) =>
740+
'bp/$scriptId#$line:$column';
744741

745742
/// Keeps track of the Dart and JS breakpoint Ids that correspond.
746743
class _Breakpoints extends Domain {
@@ -807,7 +804,12 @@ class _Breakpoints extends Domain {
807804
id: id,
808805
breakpointNumber: int.parse(createId()),
809806
resolved: true,
810-
location: SourceLocation(script: dartScript, tokenPos: location.tokenPos),
807+
location: SourceLocation(
808+
script: dartScript,
809+
tokenPos: location.tokenPos,
810+
line: location.dartLocation.line,
811+
column: location.dartLocation.column,
812+
),
811813
enabled: true,
812814
)..id = id;
813815
return breakpoint;

dwds/lib/src/debugging/location.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Location {
4040
var dartColumn = entry.sourceColumn;
4141
var jsLine = lineEntry.line;
4242
var jsColumn = entry.column;
43-
print('Location: $jsLine:$jsColumn');
43+
4444
// lineEntry data is 0 based according to:
4545
// https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k
4646
return Location._(

dwds/lib/src/injected/client.js

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

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: 13.1.0
3+
version: 13.1.1-dev
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/build_daemon_breakpoint_test.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@ void main() {
7474
await service.removeBreakpoint(isolate.id, bp.id);
7575
});
7676

77+
test('set breakpoint inside a JavaScript line succeeds', () async {
78+
var line = await context.findBreakpointLine(
79+
'printNestedObjectsMultiLine', isolate.id, mainScript);
80+
var bp = await service.addBreakpointWithScriptUri(
81+
isolate.id, mainScript.uri, line);
82+
83+
await stream.firstWhere(
84+
(Event event) => event.kind == EventKind.kPauseBreakpoint);
85+
86+
expect(bp, isNotNull);
87+
expect(
88+
bp.location,
89+
isA<SourceLocation>()
90+
.having((loc) => loc.script, 'script', equals(mainScript))
91+
.having((loc) => loc.line, 'line', equals(line)));
92+
93+
// Remove breakpoint so it doesn't impact other tests.
94+
await service.removeBreakpoint(isolate.id, bp.id);
95+
});
96+
7797
test('set breakpoint again', () async {
7898
var line = await context.findBreakpointLine(
7999
'printLocal', isolate.id, mainScript);

dwds/test/frontend_server_breakpoint_test.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void main() {
8888

8989
// Remove breakpoint so it doesn't impact other tests.
9090
await service.removeBreakpoint(isolate.id, bp.id);
91-
}, solo: true);
91+
});
9292

9393
test('set breakpoint again', () async {
9494
var line = await context.findBreakpointLine(
@@ -104,6 +104,26 @@ void main() {
104104
// Remove breakpoint so it doesn't impact other tests.
105105
await service.removeBreakpoint(isolate.id, bp.id);
106106
});
107+
108+
test('set breakpoint inside a JavaScript line succeeds', () async {
109+
var line = await context.findBreakpointLine(
110+
'printNestedObjectsMultiLine', isolate.id, mainScript);
111+
var bp = await service.addBreakpointWithScriptUri(
112+
isolate.id, mainScript.uri, line);
113+
114+
await stream.firstWhere(
115+
(Event event) => event.kind == EventKind.kPauseBreakpoint);
116+
117+
expect(bp, isNotNull);
118+
expect(
119+
bp.location,
120+
isA<SourceLocation>()
121+
.having((loc) => loc.script, 'script', equals(mainScript))
122+
.having((loc) => loc.line, 'line', equals(line)));
123+
124+
// Remove breakpoint so it doesn't impact other tests.
125+
await service.removeBreakpoint(isolate.id, bp.id);
126+
});
107127
});
108128
});
109129
}

fixtures/_testPackage/web/main.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ void main() {
4040
printFromTestPackage();
4141
printCallExtension();
4242
printLoopVariable();
43+
printNestedObjectsMultiLine();
4344
});
4445

4546
document.body.appendText(concatenate('Program', ' is running!'));
@@ -99,10 +100,25 @@ Future<void> printDeferred() async {
99100
d.deferredPrintLocal();
100101
}
101102

103+
void printNestedObjectsMultiLine() {
104+
print(
105+
EnclosingMainClass(
106+
MainClass(0) // Breakpoint: printNestedObjectsMultiLine
107+
));
108+
}
109+
102110
class MainClass {
103111
final int _field;
104112
MainClass(this._field);
105113

106114
@override
107115
String toString() => '$_field';
108116
}
117+
118+
class EnclosingMainClass {
119+
final MainClass _field;
120+
EnclosingMainClass(this._field);
121+
122+
@override
123+
String toString() => '$_field';
124+
}

fixtures/_testPackageSound/web/main.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ void main() async {
4040
printCallExtension();
4141
printLoopVariable();
4242
printGeneric<int>(0);
43+
printNestedObjectsMultiLine();
4344
});
4445

4546
document.body?.appendText(concatenate('Program', ' is running!'));
@@ -108,10 +109,25 @@ Future<void> printDeferred() async {
108109
d.deferredPrintLocal();
109110
}
110111

112+
void printNestedObjectsMultiLine() {
113+
print(
114+
EnclosingMainClass(
115+
MainClass(0) // Breakpoint: printNestedObjectsMultiLine
116+
));
117+
}
118+
111119
class MainClass {
112120
final int _field;
113121
MainClass(this._field);
114122

115123
@override
116124
String toString() => '$_field';
117125
}
126+
127+
class EnclosingMainClass {
128+
final MainClass _field;
129+
EnclosingMainClass(this._field);
130+
131+
@override
132+
String toString() => '$_field';
133+
}

0 commit comments

Comments
 (0)