revert fix to #390 as suggested + hopefully also fixes #413

pull/2/head
gorhill 10 years ago
parent 15dc2dc1e9
commit d5e7bc8800

@ -73,7 +73,8 @@ var contentObserver = {
contentBaseURI: 'chrome://' + hostName + '/content/js/', contentBaseURI: 'chrome://' + hostName + '/content/js/',
cpMessageName: hostName + ':shouldLoad', cpMessageName: hostName + ':shouldLoad',
uniqueSandboxId: 1, uniqueSandboxId: 1,
firefoxPre35: Services.vc.compare(Services.appinfo.platformVersion, '35.0') < 0, modernFirefox: Services.appinfo.ID === '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}' &&
Services.vc.compare(Services.appinfo.platformVersion, '45.0') >= 0,
get componentRegistrar() { get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@ -102,33 +103,37 @@ var contentObserver = {
register: function() { register: function() {
Services.obs.addObserver(this, 'document-element-inserted', true); Services.obs.addObserver(this, 'document-element-inserted', true);
this.componentRegistrar.registerFactory( if ( !this.modernFirefox ) {
this.classID, this.componentRegistrar.registerFactory(
this.classDescription, this.classID,
this.contractID, this.classDescription,
this this.contractID,
); this
this.categoryManager.addCategoryEntry( );
'content-policy', this.categoryManager.addCategoryEntry(
this.contractID, 'content-policy',
this.contractID, this.contractID,
false, this.contractID,
true false,
); true
);
}
}, },
unregister: function() { unregister: function() {
Services.obs.removeObserver(this, 'document-element-inserted'); Services.obs.removeObserver(this, 'document-element-inserted');
this.componentRegistrar.unregisterFactory( if ( !this.modernFirefox ) {
this.classID, this.componentRegistrar.unregisterFactory(
this this.classID,
); this
this.categoryManager.deleteCategoryEntry( );
'content-policy', this.categoryManager.deleteCategoryEntry(
this.contractID, 'content-policy',
false this.contractID,
); false
);
}
}, },
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy

@ -46,7 +46,8 @@ const {Services} = Cu.import('resource://gre/modules/Services.jsm', null);
var vAPI = self.vAPI = self.vAPI || {}; var vAPI = self.vAPI = self.vAPI || {};
vAPI.firefox = true; vAPI.firefox = true;
vAPI.firefoxPre35 = Services.vc.compare(Services.appinfo.platformVersion, '35.0') < 0; vAPI.modernFirefox = Services.appinfo.ID === '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}' &&
Services.vc.compare(Services.appinfo.platformVersion, '45.0') >= 0;
/******************************************************************************/ /******************************************************************************/
@ -1819,7 +1820,18 @@ var httpObserver = {
// http-on-opening-request // http-on-opening-request
var tabId; var tabId;
var pendingRequest = this.lookupPendingRequest(URI.asciiSpec); var pendingRequest = this.lookupPendingRequest(URI.asciiSpec);
var rawType = channel.loadInfo && channel.loadInfo.contentPolicyType || 1; var rawType = 1;
var loadInfo = channel.loadInfo;
// https://github.com/gorhill/uMatrix/issues/390#issuecomment-155717004
if ( loadInfo ) {
rawType = loadInfo.externalContentPolicyType !== undefined ?
loadInfo.externalContentPolicyType :
loadInfo.contentPolicyType;
if ( !rawType ) {
rawType = 1;
}
}
if ( pendingRequest !== null ) { if ( pendingRequest !== null ) {
tabId = pendingRequest.tabId; tabId = pendingRequest.tabId;
@ -1903,18 +1915,26 @@ vAPI.net.registerListeners = function() {
pendingReq.tabId = tabWatcher.tabIdFromTarget(e.target); pendingReq.tabId = tabWatcher.tabIdFromTarget(e.target);
}; };
vAPI.messaging.globalMessageManager.addMessageListener( // https://github.com/gorhill/uMatrix/issues/200
shouldLoadListenerMessageName, // We need this only for Firefox 34 and less: the tab id is derived from
shouldLoadListener // the origin of the message.
); if ( !vAPI.modernFirefox ) {
vAPI.messaging.globalMessageManager.addMessageListener(
shouldLoadListenerMessageName,
shouldLoadListener
);
}
httpObserver.register(); httpObserver.register();
cleanupTasks.push(function() { cleanupTasks.push(function() {
vAPI.messaging.globalMessageManager.removeMessageListener( if ( !vAPI.modernFirefox ) {
shouldLoadListenerMessageName, vAPI.messaging.globalMessageManager.removeMessageListener(
shouldLoadListener shouldLoadListenerMessageName,
); shouldLoadListener
);
}
httpObserver.unregister(); httpObserver.unregister();
}); });
}; };

Loading…
Cancel
Save