1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-23 19:03:02 +01:00

Merge pull request #1042 from AlexVallat/master

Robustness changes from watching logs in Fennec
This commit is contained in:
Deathamns 2015-03-18 07:01:36 +01:00
commit c9f6a31701

View File

@ -371,6 +371,9 @@ var getTabBrowser = function(win) {
/******************************************************************************/
var getBrowserForTab = function(tab) {
if ( !tab ) {
return null;
}
return vAPI.fennec && tab.browser || tab.linkedBrowser || null;
};
@ -457,6 +460,9 @@ vAPI.tabs.stackId = 1;
/******************************************************************************/
vAPI.tabs.getTabId = function(target) {
if ( !target ) {
return vAPI.noTabId;
}
if ( vAPI.fennec ) {
if ( target.browser ) {
// target is a tab
@ -1010,6 +1016,15 @@ var httpObserver = {
Services.obs.addObserver(this, 'http-on-opening-request', true);
Services.obs.addObserver(this, 'http-on-examine-response', true);
// Guard against stale instances not having been unregistered
if ( this.componentRegistrar.isCIDRegistered(this.classID) ) {
try {
this.componentRegistrar.unregisterFactory(this.classID, Components.manager.getClassObject(this.classID, Ci.nsIFactory))
} catch (ex) {
console.error('µBlock> httpObserver > unable to unregister stale instance: ', ex);
}
}
this.componentRegistrar.registerFactory(
this.classID,
this.classDescription,
@ -1813,10 +1828,9 @@ var optionsObserver = {
cleanupTasks.push(this.unregister.bind(this));
var browser = getBrowserForTab(vAPI.tabs.get(null));
if ( browser.currentURI.spec !== 'about:addons' ) {
return;
if ( browser && browser.currentURI && browser.currentURI.spec === 'about:addons' ) {
this.observe(browser.contentDocument, 'addon-enabled', this.addonId);
}
this.observe(browser.contentDocument, 'addon-enabled', this.addonId);
},
unregister: function() {