Firefox: new method for request handling

Now both nsIContentPolicy and on-http-* observers are used for net request
monitoring.

Reasons:
 - In many cases, nsIContentPolicy.shouldLoad is invoked twice for the same
   resource, because of the speculative parsing.
 - nsIContentPolicy.shouldLoad don't have information about the channel,
   so it can't redirect the request, nor change its headers, however
   on-http-opening-request can.

Also, local mirroring and inline-script blocking has been implemented.
pull/2/head
Deathamns 10 years ago committed by gorhill
parent e70bf61206
commit 3e39e1bd9f

@ -95,10 +95,10 @@ vAPI.messaging = {
this.channels['vAPI'] = {}; this.channels['vAPI'] = {};
this.channels['vAPI'].listener = function(msg) { this.channels['vAPI'].listener = function(msg) {
if (msg.cmd === 'injectScript') { if ( msg.cmd === 'injectScript' ) {
var details = msg.details; var details = msg.details;
if (!details.allFrames && window !== window.top) { if ( !details.allFrames && window !== window.top ) {
return; return;
} }
@ -108,12 +108,14 @@ vAPI.messaging = {
}, },
close: function() { close: function() {
if (this.connector) { if ( !this.connector ) {
removeMessageListener(this.connectorId, this.connector); return;
this.connector = null;
this.channels = {};
this.listeners = {};
} }
removeMessageListener(this.connectorId, this.connector);
this.connector = null;
this.channels = {};
this.listeners = {};
}, },
channel: function(channelName, callback) { channel: function(channelName, callback) {

Loading…
Cancel
Save