Skip to content

Commit cdb7fb4

Browse files
authored
Show a warning in the Dart Debug Extension when a user tries to debug a sharded Dart app (#1462)
1 parent 1db4938 commit cdb7fb4

File tree

11 files changed

+6387
-6252
lines changed

11 files changed

+6387
-6252
lines changed

dwds/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 11.5.2-dev
2+
3+
- Show an alert in the Dart Debug Extension for a multi-app scenario.
4+
15
## 11.5.1
26

37
- Update SDK contraint to `>=2.15.0 <3.0.0`.
@@ -18,7 +22,7 @@
1822
- Fix chrome detection in iPhone emulation mode in chrome or edge browsers.
1923
- Reliably find unused port for extension backend http service.
2024
- Ignore offset / count parameters in getObject if the object has no length.
21-
- Include static member information for classes
25+
- Include static member information for classes.
2226

2327
## 11.4.0
2428

dwds/debug_extension/CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
## 1.24
2+
3+
- Detect Dart applications in multi-app environments and show an alert.
4+
15
## 1.23
26

37
- Depend on the latest `package:sse` to improve stability of the connection with many
48
concurrent requests.
59

6-
710
## 1.22
811

912
- Detect Dart applications and update the icon accordingly.

dwds/debug_extension/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: extension
22
publish_to: none
3-
version: 1.23.0
3+
version: 1.24.0
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/dart-lang/webdev
66
description: >-

dwds/debug_extension/web/background.dart

+26-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const _allowedEvents = {'Overlay.inspectNodeRequested'};
3838
// Map of Chrome tab ID to encoded vm service protocol URI.
3939
final _tabIdToEncodedUri = <int, String>{};
4040

41+
// Map of Chrome tab ID to warnings for that tab.
42+
final _tabIdToWarning = <int, String>{};
43+
4144
final _debuggableTabs = <int>{};
4245

4346
final _tabsToAttach = <Tab>{};
@@ -67,6 +70,12 @@ void main() {
6770
var callback = allowInterop((List<Tab> tabs) async {
6871
currentTab = tabs[0];
6972
if (!_debuggableTabs.contains(currentTab.id)) return;
73+
74+
if (_tabIdToWarning.containsKey(currentTab.id)) {
75+
alert(_tabIdToWarning[currentTab.id]);
76+
return;
77+
}
78+
7079
attach(Debuggee(tabId: currentTab.id), '1.3', allowInterop(() async {
7180
if (lastError != null) {
7281
String alertMessage;
@@ -100,6 +109,10 @@ void main() {
100109

101110
onMessageAddListener(allowInterop(
102111
(Request request, Sender sender, Function sendResponse) async {
112+
// Register any warnings for the tab:
113+
if (request.warning != '') {
114+
_tabIdToWarning[sender.tab.id] = request.warning;
115+
}
103116
_debuggableTabs.add(sender.tab.id);
104117
_updateIcon();
105118
// TODO(grouma) - We can conditionally auto start debugging here.
@@ -362,9 +375,20 @@ void _updateIcon() {
362375
var query = QueryInfo(active: true, currentWindow: true);
363376
queryTabs(query, allowInterop((List tabs) {
364377
var tabList = List<Tab>.from(tabs);
365-
if (tabList.isEmpty || _debuggableTabs.contains(tabList.first.id)) {
378+
// If tabList is empty, the user has likely navigated to a different window.
379+
// Therefore, do not update the icon:
380+
if (tabList.isEmpty || tabList.first == null || tabList.first.id == null) {
381+
return;
382+
}
383+
384+
if (_tabIdToWarning.containsKey(tabList.first.id)) {
385+
// Set the warning icon (red):
386+
setIcon(IconInfo(path: 'dart_warning.png'));
387+
} else if (_debuggableTabs.contains(tabList.first.id)) {
388+
// Set the debuggable icon (blue):
366389
setIcon(IconInfo(path: 'dart.png'));
367390
} else {
391+
// Set the default icon (grey):
368392
setIcon(IconInfo(path: 'dart_grey.png'));
369393
}
370394
}));
@@ -514,6 +538,7 @@ class Request {
514538
external int get tabId;
515539
external String get name;
516540
external dynamic get options;
541+
external String get warning;
517542
external factory Request({int tabId, String name, dynamic options});
518543
}
519544

0 commit comments

Comments
 (0)