From 0bebc8136967ebf91d47d52afe6247190828afe4 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 10 Feb 2016 11:25:52 -0500 Subject: [PATCH] code review + fixes another potential error in browser console (re. popup blocking) --- platform/firefox/vapi-background.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index ec30701ca..39d8e867f 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -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++ ) {