From d8811a49d0adc6a04f6b025ad980ca676835b90c Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Tue, 28 Nov 2023 17:43:26 +0000 Subject: [PATCH] Bug 1866870 - Check if gBrowser is available before updating Shopping Sidebar visibility. r=shopping-reviewers,Gijs Checks if `gBrowser` is available in `updateSidebarVisibilityForWindow` to prevent errors when it is undefined (like on about:config). Differential Revision: https://phabricator.services.mozilla.com/D194810 --- browser/components/shopping/ShoppingSidebarParent.sys.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/browser/components/shopping/ShoppingSidebarParent.sys.mjs b/browser/components/shopping/ShoppingSidebarParent.sys.mjs index efb1e3e2f4cb..374ccabb30ab 100644 --- a/browser/components/shopping/ShoppingSidebarParent.sys.mjs +++ b/browser/components/shopping/ShoppingSidebarParent.sys.mjs @@ -152,6 +152,10 @@ class ShoppingSidebarManagerClass { return; } + if (!window.gBrowser) { + return; + } + let document = window.document; if (!this.isActive) { @@ -322,10 +326,12 @@ class ShoppingSidebarManagerClass { if (!this.enabled) { return; } + let { gBrowser } = event.target.ownerGlobal.top; + if (!gBrowser) { + return; + } this.updateSidebarVisibilityForWindow(event.target.ownerGlobal.top); - this._updateBCActiveness( - event.target.ownerGlobal.top.gBrowser.selectedBrowser - ); + this._updateBCActiveness(gBrowser.selectedBrowser); } } } -- 2.11.4.GIT