From 3e39e1bd9f14073f401fd28495d184bd4ae79e8d Mon Sep 17 00:00:00 2001 From: Deathamns Date: Wed, 24 Dec 2014 23:11:36 +0100 Subject: [PATCH] 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. --- platform/firefox/vapi-client.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/platform/firefox/vapi-client.js b/platform/firefox/vapi-client.js index a700005..d187a5f 100644 --- a/platform/firefox/vapi-client.js +++ b/platform/firefox/vapi-client.js @@ -95,10 +95,10 @@ vAPI.messaging = { this.channels['vAPI'] = {}; this.channels['vAPI'].listener = function(msg) { - if (msg.cmd === 'injectScript') { + if ( msg.cmd === 'injectScript' ) { var details = msg.details; - if (!details.allFrames && window !== window.top) { + if ( !details.allFrames && window !== window.top ) { return; } @@ -108,12 +108,14 @@ vAPI.messaging = { }, close: function() { - if (this.connector) { - removeMessageListener(this.connectorId, this.connector); - this.connector = null; - this.channels = {}; - this.listeners = {}; + if ( !this.connector ) { + return; } + + removeMessageListener(this.connectorId, this.connector); + this.connector = null; + this.channels = {}; + this.listeners = {}; }, channel: function(channelName, callback) {