code review

This commit is contained in:
gorhill 2015-12-11 19:18:14 -05:00
parent 84d85d080c
commit 08085f7383
1 changed files with 8 additions and 13 deletions

View File

@ -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 {