Browse Source

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

pull/2/head
gorhill 9 years ago
parent
commit
d5e7bc8800
  1. 7
      platform/firefox/frameModule.js
  2. 24
      platform/firefox/vapi-background.js

7
platform/firefox/frameModule.js

@ -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,6 +103,7 @@ var contentObserver = {
register: function() { register: function() {
Services.obs.addObserver(this, 'document-element-inserted', true); Services.obs.addObserver(this, 'document-element-inserted', true);
if ( !this.modernFirefox ) {
this.componentRegistrar.registerFactory( this.componentRegistrar.registerFactory(
this.classID, this.classID,
this.classDescription, this.classDescription,
@ -115,11 +117,13 @@ var contentObserver = {
false, false,
true true
); );
}
}, },
unregister: function() { unregister: function() {
Services.obs.removeObserver(this, 'document-element-inserted'); Services.obs.removeObserver(this, 'document-element-inserted');
if ( !this.modernFirefox ) {
this.componentRegistrar.unregisterFactory( this.componentRegistrar.unregisterFactory(
this.classID, this.classID,
this this
@ -129,6 +133,7 @@ var contentObserver = {
this.contractID, this.contractID,
false 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

24
platform/firefox/vapi-background.js

@ -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);
}; };
// 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( vAPI.messaging.globalMessageManager.addMessageListener(
shouldLoadListenerMessageName, shouldLoadListenerMessageName,
shouldLoadListener shouldLoadListener
); );
}
httpObserver.register(); httpObserver.register();
cleanupTasks.push(function() { cleanupTasks.push(function() {
if ( !vAPI.modernFirefox ) {
vAPI.messaging.globalMessageManager.removeMessageListener( vAPI.messaging.globalMessageManager.removeMessageListener(
shouldLoadListenerMessageName, shouldLoadListenerMessageName,
shouldLoadListener shouldLoadListener
); );
}
httpObserver.unregister(); httpObserver.unregister();
}); });
}; };

Loading…
Cancel
Save