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

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

@ -73,7 +73,8 @@ var contentObserver = {
contentBaseURI: 'chrome://' + hostName + '/content/js/',
cpMessageName: hostName + ':shouldLoad',
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() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@ -102,6 +103,7 @@ var contentObserver = {
register: function() {
Services.obs.addObserver(this, 'document-element-inserted', true);
if ( !this.modernFirefox ) {
this.componentRegistrar.registerFactory(
this.classID,
this.classDescription,
@ -115,11 +117,13 @@ var contentObserver = {
false,
true
);
}
},
unregister: function() {
Services.obs.removeObserver(this, 'document-element-inserted');
if ( !this.modernFirefox ) {
this.componentRegistrar.unregisterFactory(
this.classID,
this
@ -129,6 +133,7 @@ var contentObserver = {
this.contractID,
false
);
}
},
// 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 || {};
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
var tabId;
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 ) {
tabId = pendingRequest.tabId;
@ -1903,18 +1915,26 @@ vAPI.net.registerListeners = function() {
pendingReq.tabId = tabWatcher.tabIdFromTarget(e.target);
};
// https://github.com/gorhill/uMatrix/issues/200
// We need this only for Firefox 34 and less: the tab id is derived from
// the origin of the message.
if ( !vAPI.modernFirefox ) {
vAPI.messaging.globalMessageManager.addMessageListener(
shouldLoadListenerMessageName,
shouldLoadListener
);
}
httpObserver.register();
cleanupTasks.push(function() {
if ( !vAPI.modernFirefox ) {
vAPI.messaging.globalMessageManager.removeMessageListener(
shouldLoadListenerMessageName,
shouldLoadListener
);
}
httpObserver.unregister();
});
};

Loading…
Cancel
Save