Browse Source

shouldLoad needed only for FF34 and less (no need for sync messaging with e10s)

pull/2/head
gorhill 9 years ago
parent
commit
51d18b4c47
  1. 8
      platform/firefox/frameModule.js
  2. 8
      platform/firefox/vapi-background.js

8
platform/firefox/frameModule.js

@ -72,6 +72,7 @@ const contentObserver = {
contentBaseURI: 'chrome://' + hostName + '/content/js/', contentBaseURI: 'chrome://' + hostName + '/content/js/',
cpMessageName: hostName + ':shouldLoad', cpMessageName: hostName + ':shouldLoad',
uniqueSandboxId: 1, uniqueSandboxId: 1,
firefoxPost34: Services.vc.compare(Services.appinfo.platformVersion, '35.0') >= 0,
get componentRegistrar() { get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@ -126,13 +127,10 @@ const contentObserver = {
); );
}, },
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy
// https://bugzil.la/612921 // https://bugzil.la/612921
shouldLoad: function(type, location, origin, context) { shouldLoad: function(type, location, origin, context) {
if ( Services === undefined ) {
return this.ACCEPT;
}
if ( !context ) {
if ( this.firefoxPost34 || Services === undefined || !context ) {
return this.ACCEPT; return this.ACCEPT;
} }

8
platform/firefox/vapi-background.js

@ -46,6 +46,7 @@ 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;
/******************************************************************************/ /******************************************************************************/
@ -1883,18 +1884,25 @@ 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.firefoxPre35 ) {
vAPI.messaging.globalMessageManager.addMessageListener( vAPI.messaging.globalMessageManager.addMessageListener(
shouldLoadListenerMessageName, shouldLoadListenerMessageName,
shouldLoadListener shouldLoadListener
); );
}
httpObserver.register(); httpObserver.register();
cleanupTasks.push(function() { cleanupTasks.push(function() {
if ( vAPI.firefoxPre35 ) {
vAPI.messaging.globalMessageManager.removeMessageListener( vAPI.messaging.globalMessageManager.removeMessageListener(
shouldLoadListenerMessageName, shouldLoadListenerMessageName,
shouldLoadListener shouldLoadListener
); );
}
httpObserver.unregister(); httpObserver.unregister();
}); });
}; };

Loading…
Cancel
Save