fix(devtools): set extension icon and popup only on DevTools background message

The script handles messages globally, for all extensions running on the page. I this case, we don't want to do anything if the message does not come from Angular DevTools itself.
This commit is contained in:
mgechev
2020-08-11 00:34:49 +03:00
committed by Minko Gechev
parent 094a0a5b10
commit 0e10241b5c
2 changed files with 10 additions and 0 deletions
@@ -100,6 +100,9 @@ const getPopUpName = (ng: AngularDetection) => {
};
chrome.runtime.onMessage.addListener((req, sender) => {
if (!req.isAngularDevTools) {
return;
}
if (sender && sender.tab) {
chrome.browserAction.setPopup({
tabId: sender.tab.id,
@@ -1,4 +1,10 @@
export interface AngularDetection {
// This is necessary because the runtime
// message listener handles messages globally
// including from other extensions. We don't
// want to set icon and/or popup based on
// a message coming from an unrelated extension.
isAngularDevTools: true;
isIvy: boolean;
isAngular: boolean;
isDebugMode: boolean;
@@ -34,6 +40,7 @@ function detectAngular(win: Window): void {
isAngular,
isDebugMode,
isSupportedAngularVersion,
isAngularDevTools: true,
} as AngularDetection,
'*'
);