Browse Source

this should fix #390

pull/2/head
gorhill 10 years ago
parent
commit
6c0c62cc13
  1. 45
      platform/firefox/frameModule.js
  2. 35
      platform/firefox/vapi-background.js

45
platform/firefox/frameModule.js

@ -102,34 +102,33 @@ var contentObserver = {
register: function() { register: function() {
Services.obs.addObserver(this, 'document-element-inserted', true); Services.obs.addObserver(this, 'document-element-inserted', true);
if ( this.firefoxPre35 ) { this.componentRegistrar.registerFactory(
this.componentRegistrar.registerFactory( this.classID,
this.classID, this.classDescription,
this.classDescription, this.contractID,
this.contractID, this
this );
); this.categoryManager.addCategoryEntry(
this.categoryManager.addCategoryEntry( 'content-policy',
'content-policy', this.contractID,
this.contractID, this.contractID,
this.contractID, false,
false, true
true );
);
}
}, },
unregister: function() { unregister: function() {
Services.obs.removeObserver(this, 'document-element-inserted'); Services.obs.removeObserver(this, 'document-element-inserted');
if ( this.firefoxPre35 ) { this.componentRegistrar.unregisterFactory(
this.componentRegistrar.unregisterFactory(this.classID, this); this.classID,
this.categoryManager.deleteCategoryEntry( this
'content-policy', );
this.contractID, this.categoryManager.deleteCategoryEntry(
false 'content-policy',
); 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

35
platform/firefox/vapi-background.js

@ -1820,15 +1820,21 @@ var httpObserver = {
} }
// http-on-opening-request // http-on-opening-request
var tabId, rawType; var tabId;
var pendingRequest = this.lookupPendingRequest(URI.asciiSpec); var pendingRequest = this.lookupPendingRequest(URI.asciiSpec);
var rawType = channel.loadInfo && channel.loadInfo.contentPolicyType || 1;
if ( pendingRequest !== null ) { if ( pendingRequest !== null ) {
tabId = pendingRequest.tabId; tabId = pendingRequest.tabId;
rawType = pendingRequest.rawType; // https://github.com/gorhill/uBlock/issues/654
// Use the request type from the HTTP observer point of view.
if ( rawType !== 1 ) {
pendingRequest.rawType = rawType;
} else {
rawType = pendingRequest.rawType;
}
} else { } else {
tabId = this.tabIdFromChannel(channel); tabId = this.tabIdFromChannel(channel);
rawType = channel.loadInfo && channel.loadInfo.contentPolicyType || 1;
} }
if ( this.handleRequest(channel, URI, tabId, rawType) ) { if ( this.handleRequest(channel, URI, tabId, rawType) ) {
@ -1900,25 +1906,18 @@ vAPI.net.registerListeners = function() {
pendingReq.tabId = tabWatcher.tabIdFromTarget(e.target); pendingReq.tabId = tabWatcher.tabIdFromTarget(e.target);
}; };
// https://github.com/gorhill/uMatrix/issues/200 vAPI.messaging.globalMessageManager.addMessageListener(
// We need this only for Firefox 34 and less: the tab id is derived from shouldLoadListenerMessageName,
// the origin of the message. shouldLoadListener
if ( vAPI.firefoxPre35 ) { );
vAPI.messaging.globalMessageManager.addMessageListener(
shouldLoadListenerMessageName,
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();
}); });
}; };

|||||||
100:0
Loading…
Cancel
Save