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. 24
      platform/firefox/vapi-background.js

8
platform/firefox/frameModule.js

@ -72,6 +72,7 @@ const contentObserver = {
contentBaseURI: 'chrome://' + hostName + '/content/js/',
cpMessageName: hostName + ':shouldLoad',
uniqueSandboxId: 1,
firefoxPost34: Services.vc.compare(Services.appinfo.platformVersion, '35.0') >= 0,
get componentRegistrar() {
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
shouldLoad: function(type, location, origin, context) {
if ( Services === undefined ) {
return this.ACCEPT;
}
if ( !context ) {
if ( this.firefoxPost34 || Services === undefined || !context ) {
return this.ACCEPT;
}

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

Loading…
Cancel
Save