From 2f7e657a307f953e888a8cec18727d3542f624f0 Mon Sep 17 00:00:00 2001 From: kernp25 Date: Wed, 18 Jan 2023 11:49:45 +0000 Subject: [PATCH] Bug 1757161 - Add a check to make sure channel.loadInfo.loadingPrincipal is not null. r=bomsy Differential Revision: https://phabricator.services.mozilla.com/D165523 --- .../shared/network-observer/NetworkUtils.sys.mjs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/devtools/shared/network-observer/NetworkUtils.sys.mjs b/devtools/shared/network-observer/NetworkUtils.sys.mjs index 2ecb76071886..95d9e06f438f 100644 --- a/devtools/shared/network-observer/NetworkUtils.sys.mjs +++ b/devtools/shared/network-observer/NetworkUtils.sys.mjs @@ -372,7 +372,7 @@ function matchRequest(channel, filters) { } if (type == "webextension") { return ( - channel?.loadInfo.loadingPrincipal.addonId === + channel.loadInfo?.loadingPrincipal?.addonId === filters.sessionContext.addonId ); } @@ -410,8 +410,7 @@ function legacyMatchRequest(channel, filters) { // Ignore requests from chrome or add-on code when we are monitoring // content. if ( - channel.loadInfo && - channel.loadInfo.loadingDocument === null && + channel.loadInfo?.loadingDocument === null && (channel.loadInfo.loadingPrincipal === Services.scriptSecurityManager.getSystemPrincipal() || channel.loadInfo.isInDevToolsContext) @@ -450,18 +449,14 @@ function legacyMatchRequest(channel, filters) { // If we couldn't get the top frame BrowsingContext from the loadContext, // look for it on channel.loadInfo instead. - if ( - channel.loadInfo && - channel.loadInfo.browsingContext && - channel.loadInfo.browsingContext.browserId == filters.browserId - ) { + if (channel.loadInfo?.browsingContext?.browserId == filters.browserId) { return true; } } if ( filters.addonId && - channel?.loadInfo.loadingPrincipal.addonId === filters.addonId + channel.loadInfo?.loadingPrincipal?.addonId === filters.addonId ) { return true; }