1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-01 18:10:17 +12:00

Robustness changes from watching logs in Fennec

This commit is contained in:
AlexVallat 2015-03-17 18:08:29 +00:00 committed by gorhill
parent 1629accdb8
commit 28923771dc

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() {