From 08085f7383bc4443e14fa0dd5b3cfe38e6d9c701 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 11 Dec 2015 19:18:14 -0500 Subject: [PATCH] code review --- platform/firefox/vapi-background.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 8283747c6..ca4a32fb4 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -3432,27 +3432,22 @@ var optionsObserver = (function() { // Older versions of Firefox can throw here when looking up `currentURI`. var canInit = function() { - var ok; try { var tabBrowser = tabWatcher.currentBrowser(); - ok = tabBrowser && - tabBrowser.currentURI && - tabBrowser.contentDocument && - tabBrowser.contentDocument.readyState === 'complete'; + return tabBrowser && + tabBrowser.currentURI && + tabBrowser.currentURI.spec === 'about:addons' && + tabBrowser.contentDocument && + tabBrowser.contentDocument.readyState === 'complete'; } catch (ex) { } - return ok; }; - // Manually add the buttons if the `about:addons` page is already - // opened. + // Manually add the buttons if the `about:addons` page is already opened. var init = function() { if ( canInit() ) { - var tabBrowser = tabWatcher.currentBrowser(); - if ( tabBrowser.currentURI.spec === 'about:addons' ) { - setupOptionsButtons(tabBrowser.contentDocument); - } + setupOptionsButtons(tabWatcher.currentBrowser().contentDocument); } }; @@ -3463,7 +3458,7 @@ var optionsObserver = (function() { var register = function() { Services.obs.addObserver(observer, 'addon-options-displayed', false); cleanupTasks.push(unregister); - deferUntil(canInit, init); + deferUntil(canInit, init, { next: 463 }); }; return {