code review + fixes another potential error in browser console (re. popup blocking)

This commit is contained in:
gorhill 2016-02-10 11:25:52 -05:00
parent f8de57dd1a
commit 0bebc81369

View file

@ -2717,13 +2717,10 @@ vAPI.toolbarButton = {
// 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);
}
var toolbars = toolbox.externalToolbars ? toolbox.externalToolbars.slice() : [];
for ( var child of toolbox.children ) {
if ( child.localName === 'toolbar' ) {
toolbars.push(child);
}
}
@ -2737,6 +2734,11 @@ vAPI.toolbarButton = {
if ( index === -1 ) {
continue;
}
// This can occur with Pale Moon:
// "TypeError: toolbar.insertItem is not a function"
if ( typeof toolbar.insertItem !== 'function' ) {
continue;
}
// Found our button on this toolbar - but where on it?
var before = null;
for ( var i = index + 1; i < currentset.length; i++ ) {