Skip to content

Commit ee356b3

Browse files
author
Anna Gringauze
authored
Change to recognize pageReady dwds event from devtools (#1411)
* Change to recognize pageReady dwds event from devtools * Disable test that depends on unpublished version of devtools * Addressed CR comments
1 parent 37ecb56 commit ee356b3

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

dwds/CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'type': '<event type>',
1010
'payload': {
1111
'screen: '<screen name>',
12-
'action: '<action name>',
12+
'action: '<action name>'
1313
}
1414
}
1515
```
@@ -18,8 +18,8 @@
1818
{
1919
'type: 'DevtoolsEvent',
2020
'payload': {
21-
'screen': 'debugger'
22-
'action': 'screenReady'
21+
'screen': 'debugger',
22+
'action': 'pageReady'
2323
}
2424
}
2525
```

dwds/lib/src/dwds_vm_client.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,14 @@ void _processSendEvent(Map<String, dynamic> event,
203203
{
204204
var screen = payload == null ? null : payload['screen'];
205205
var action = payload == null ? null : payload['action'];
206-
if (screen == 'debugger' &&
207-
action == 'screenReady' &&
208-
dwdsStats.isFirstDebuggerReady()) {
209-
emitEvent(DwdsEvent.debuggerReady(DateTime.now()
210-
.difference(dwdsStats.debuggerStart)
211-
.inMilliseconds));
206+
if (screen == 'debugger' && action == 'pageReady') {
207+
if (dwdsStats.isFirstDebuggerReady()) {
208+
emitEvent(DwdsEvent.debuggerReady(DateTime.now()
209+
.difference(dwdsStats.debuggerStart)
210+
.inMilliseconds));
211+
} else {
212+
_logger.warning('Ignoring already received event: $event');
213+
}
212214
} else {
213215
_logger.warning('Ignoring unknown event: $event');
214216
}

dwds/test/events_test.dart

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ void main() {
7474

7575
test('emits DEBUGGER_READY event', () async {
7676
await expectEventDuring(
77-
matchesEvent(DwdsEventKind.debuggerReady, {}),
77+
matchesEvent(DwdsEventKind.debuggerReady, {
78+
'elapsedMilliseconds': isNotNull,
79+
}),
7880
() => keyboard.sendChord([Keyboard.alt, 'd']),
7981
);
80-
}, skip: 'https://github.com/dart-lang/webdev/issues/1406');
82+
},
83+
skip: 'Enable after publishing of '
84+
'https://github.com/flutter/devtools/pull/3346');
8185

8286
test('events can be listened to multiple times', () async {
8387
events.listen((_) {});
@@ -94,18 +98,6 @@ void main() {
9498
expect(response.type, 'Success');
9599
});
96100

97-
test('can receive DevtoolsEvent and emit DEBUGGER_READY event', () async {
98-
final response = await expectEventDuring(
99-
matchesEvent(DwdsEventKind.debuggerReady, {
100-
'elapsedMilliseconds': isNotNull,
101-
}),
102-
() => vmService.callServiceExtension('ext.dwds.sendEvent', args: {
103-
'type': 'DevtoolsEvent',
104-
'payload': {'screen': 'debugger', 'action': 'screenReady'},
105-
}));
106-
expect(response.type, 'Success');
107-
});
108-
109101
group('evaluate', () {
110102
Isolate isolate;
111103
LibraryRef bootstrap;
@@ -275,7 +267,7 @@ void main() {
275267

276268
test('emits GET_SCRIPTS events', () async {
277269
await expectEventDuring(
278-
matchesEvent(DwdsEventKind.getSourceReport, {
270+
matchesEvent(DwdsEventKind.getScripts, {
279271
'elapsedMilliseconds': isNotNull,
280272
}),
281273
() => service.getScripts(isolateId));

0 commit comments

Comments
 (0)