Browse Source

Robustness changes from watching logs in Fennec

pull/2/head
AlexVallat 10 years ago
committed by gorhill
parent
commit
28923771dc
  1. 20
      platform/firefox/vapi-background.js

20
platform/firefox/vapi-background.js

@ -371,6 +371,9 @@ var getTabBrowser = function(win) {
/******************************************************************************/ /******************************************************************************/
var getBrowserForTab = function(tab) { var getBrowserForTab = function(tab) {
if ( !tab ) {
return null;
}
return vAPI.fennec && tab.browser || tab.linkedBrowser || null; return vAPI.fennec && tab.browser || tab.linkedBrowser || null;
}; };
@ -457,6 +460,9 @@ vAPI.tabs.stackId = 1;
/******************************************************************************/ /******************************************************************************/
vAPI.tabs.getTabId = function(target) { vAPI.tabs.getTabId = function(target) {
if ( !target ) {
return vAPI.noTabId;
}
if ( vAPI.fennec ) { if ( vAPI.fennec ) {
if ( target.browser ) { if ( target.browser ) {
// target is a tab // 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-opening-request', true);
Services.obs.addObserver(this, 'http-on-examine-response', 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.componentRegistrar.registerFactory(
this.classID, this.classID,
this.classDescription, this.classDescription,
@ -1813,10 +1828,9 @@ var optionsObserver = {
cleanupTasks.push(this.unregister.bind(this)); cleanupTasks.push(this.unregister.bind(this));
var browser = getBrowserForTab(vAPI.tabs.get(null)); 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() { unregister: function() {

Loading…
Cancel
Save