-
Notifications
You must be signed in to change notification settings - Fork 87
[MV3 Debug Extension] Show a warning if multiple Dart apps are in a single page #1976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
10977cc
Add warning when user tries to debug from multi-app environment
elliette 76aafd1
Merge branch 'master' into multi-ddr
elliette 8ffe883
Multi DDR warning from Chrome Devtools panel
elliette 65d9e1b
Maybe set warning icon when tab changes
elliette 38086b9
Add a test
elliette a0781d3
Update messaging and guarantee warning icon is shown after debuggable…
elliette f729a05
Update async functions
elliette File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,17 +46,23 @@ const _lostConnectionMsg = 'Lost connection.'; | |
const _connectionTimeoutMsg = 'Connection timed out.'; | ||
const _failedToConnectMsg = 'Failed to connect, please try again.'; | ||
const _pleaseAuthenticateMsg = 'Please re-authenticate and try again.'; | ||
const _multipleAppsMsg = 'Cannot debug multiple apps in a page.'; | ||
|
||
int get _tabId => chrome.devtools.inspectedWindow.tabId; | ||
|
||
void main() { | ||
void main() async { | ||
unawaited( | ||
_registerListeners().catchError((error) { | ||
debugWarn('Error registering listeners in panel: $error'); | ||
}), | ||
); | ||
_setColorThemeToMatchChromeDevTools(); | ||
_maybeUpdateFileABugLink(); | ||
final multipleApps = await fetchStorageObject<String>( | ||
type: StorageObject.multipleAppsDetected, | ||
tabId: _tabId, | ||
); | ||
_maybeShowMultipleAppsWarning(multipleApps); | ||
} | ||
|
||
Future<void> _registerListeners() async { | ||
|
@@ -120,6 +126,12 @@ void _handleStorageChanges(Object storageObj, String storageArea) { | |
tabId: _tabId, | ||
changeHandler: _handleDevToolsUriChanges, | ||
); | ||
interceptStorageChange<String>( | ||
storageObj: storageObj, | ||
expectedType: StorageObject.multipleAppsDetected, | ||
tabId: _tabId, | ||
changeHandler: _maybeShowMultipleAppsWarning, | ||
); | ||
} | ||
|
||
void _handleDebugInfoChanges(DebugInfo? debugInfo) async { | ||
|
@@ -143,6 +155,16 @@ void _handleDevToolsUriChanges(String? devToolsUri) async { | |
} | ||
} | ||
|
||
void _maybeShowMultipleAppsWarning(String? multipleApps) async { | ||
if (multipleApps != null) { | ||
_showWarningBanner(_multipleAppsMsg); | ||
} else { | ||
if (_warningBannerIsVisible(message: _multipleAppsMsg)) { | ||
_hideWarningBanner(); | ||
} | ||
} | ||
} | ||
|
||
void _maybeUpdateFileABugLink() async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
final debugInfo = await fetchStorageObject<DebugInfo>( | ||
type: StorageObject.debugInfo, | ||
|
@@ -217,9 +239,13 @@ void _handleConnectFailure(ConnectFailureReason reason) { | |
_updateElementVisibility(_loadingSpinnerId, visible: false); | ||
} | ||
|
||
bool _warningBannerIsVisible() { | ||
bool _warningBannerIsVisible({String? message}) { | ||
final warningBanner = document.getElementById(_warningBannerId); | ||
return warningBanner != null && warningBanner.classes.contains(_showClass); | ||
final isVisible = | ||
warningBanner != null && warningBanner.classes.contains(_showClass); | ||
if (message == null || isVisible == false) return isVisible; | ||
final warningMsg = document.getElementById(_warningMsgId); | ||
return warningMsg?.innerHtml == message; | ||
} | ||
|
||
void _showWarningBanner(String message) { | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+77.7 KB
dwds/test/puppeteer/test_images/debuggerMultipleAppsDetected_dartApp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+77.7 KB
dwds/test/puppeteer/test_images/debuggerMultipleAppsDetected_flutterApp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future<void>
(there are more like that below)