From f8de57dd1a1ea05007ad2453669925f5b8ea2617 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 10 Feb 2016 11:15:57 -0500 Subject: [PATCH] this takes care of errors in browser console while testing popup blocking --- platform/firefox/vapi-background.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 70795324a..ec30701ca 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -1428,7 +1428,11 @@ vAPI.setIcon = function(tabId, iconStatus, badge) { var win = badge === undefined ? iconStatus : winWatcher.getCurrentWindow(); - var curTabId = tabWatcher.tabIdFromTarget(getTabBrowser(win).selectedTab); + var curTabId; + var tabBrowser = getTabBrowser(win); + if ( tabBrowser ) { + curTabId = tabWatcher.tabIdFromTarget(tabBrowser.selectedTab); + } var tb = vAPI.toolbarButton; // from 'TabSelect' event @@ -1438,7 +1442,7 @@ vAPI.setIcon = function(tabId, iconStatus, badge) { tb.tabs[tabId] = { badge: badge, img: iconStatus === 'on' }; } - if ( tabId === curTabId ) { + if ( curTabId && tabId === curTabId ) { tb.updateState(win, tabId); vAPI.contextMenu.onMustUpdate(tabId); } @@ -2709,11 +2713,17 @@ vAPI.toolbarButton = { palette.appendChild(toolbarButton); } - // Find the place to put the button - var toolbars = toolbox.externalToolbars.slice(); - for ( var child of toolbox.children ) { - if ( child.localName === 'toolbar' ) { - toolbars.push(child); + // Find the place to put the button. + // Pale Moon: `toolbox.externalToolbars` can be undefined. Seen while + // testing popup test number 3: + // http://raymondhill.net/ublock/popup.html + var toolbars = []; + if ( toolbox.externalToolbars ) { + toolbars = toolbox.externalToolbars.slice(); + for ( var child of toolbox.children ) { + if ( child.localName === 'toolbar' ) { + toolbars.push(child); + } } }