From a9021f375e61f1e6cec2ff1a6a7e29647752f84f Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Sat, 2 Nov 2019 08:35:44 -0500 Subject: [PATCH] Fix JS error when `this.sender.tab` is undefined --- background/background.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/background/background.js b/background/background.js index da59e025..18980c98 100644 --- a/background/background.js +++ b/background/background.js @@ -43,13 +43,15 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, { openEditor, updateIconBadge(count) { - // TODO: remove once our manifest's minimum_chrome_version is 50+ - // Chrome 49 doesn't report own extension pages in webNavigation apparently - // so we do a force update which doesn't use the cache. - if (CHROME && CHROME < 2661 && this.sender.tab.url.startsWith(URLS.ownOrigin)) { - updateIconBadgeForce(this.sender.tab.id, count); - } else { - updateIconBadge(this.sender.tab.id, count); + if (this.sender.tab) { + // TODO: remove once our manifest's minimum_chrome_version is 50+ + // Chrome 49 doesn't report own extension pages in webNavigation apparently + // so we do a force update which doesn't use the cache. + if (CHROME && CHROME < 2661 && this.sender.tab.url.startsWith(URLS.ownOrigin)) { + updateIconBadgeForce(this.sender.tab.id, count); + } else { + updateIconBadge(this.sender.tab.id, count); + } } return true; },