this takes care of errors in browser console while testing popup blocking

This commit is contained in:
gorhill 2016-02-10 11:15:57 -05:00
parent 7f79e92072
commit f8de57dd1a
1 changed files with 17 additions and 7 deletions

View File

@ -1428,7 +1428,11 @@ vAPI.setIcon = function(tabId, iconStatus, badge) {
var win = badge === undefined var win = badge === undefined
? iconStatus ? iconStatus
: winWatcher.getCurrentWindow(); : 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; var tb = vAPI.toolbarButton;
// from 'TabSelect' event // from 'TabSelect' event
@ -1438,7 +1442,7 @@ vAPI.setIcon = function(tabId, iconStatus, badge) {
tb.tabs[tabId] = { badge: badge, img: iconStatus === 'on' }; tb.tabs[tabId] = { badge: badge, img: iconStatus === 'on' };
} }
if ( tabId === curTabId ) { if ( curTabId && tabId === curTabId ) {
tb.updateState(win, tabId); tb.updateState(win, tabId);
vAPI.contextMenu.onMustUpdate(tabId); vAPI.contextMenu.onMustUpdate(tabId);
} }
@ -2709,13 +2713,19 @@ vAPI.toolbarButton = {
palette.appendChild(toolbarButton); palette.appendChild(toolbarButton);
} }
// Find the place to put the button // Find the place to put the button.
var toolbars = toolbox.externalToolbars.slice(); // 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 ) { for ( var child of toolbox.children ) {
if ( child.localName === 'toolbar' ) { if ( child.localName === 'toolbar' ) {
toolbars.push(child); toolbars.push(child);
} }
} }
}
for ( var toolbar of toolbars ) { for ( var toolbar of toolbars ) {
var currentsetString = toolbar.getAttribute('currentset'); var currentsetString = toolbar.getAttribute('currentset');