From 76c44e9672d8541a50369bf9de8c9c1ecad31682 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 6 Jun 2016 09:51:39 -0400 Subject: [PATCH] code review re. https://github.com/gorhill/uMatrix/issues/554 No longer need to evaluate within asyncOnChannelRedirect() since all is now evaluated at `http-on-modify-request` time. --- platform/firefox/vapi-background.js | 31 +++++++++-------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index a3865609a..08c3a8bea 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -2213,42 +2213,29 @@ var httpObserver = { // contentPolicy.shouldLoad doesn't detect redirects, this needs to be used asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) { - var result = this.ACCEPT; - // If error thrown, the redirect will fail try { var URI = newChannel.URI; - if ( !URI.schemeIs('http') && !URI.schemeIs('https') ) { return; } - if ( !(oldChannel instanceof Ci.nsIWritablePropertyBag) ) { - return; - } - - var channelData = oldChannel.getProperty(this.REQDATAKEY); - - var details = { - frameId: channelData[0], - parentFrameId: channelData[1], - tabId: channelData[2], - rawtype: channelData[3] - }; - - if ( this.handleRequest(newChannel, URI, details) ) { - result = this.ABORT; + if ( + oldChannel instanceof Ci.nsIWritablePropertyBag === false || + newChannel instanceof Ci.nsIWritablePropertyBag === false + ) { return; } // Carry the data on in case of multiple redirects - if ( newChannel instanceof Ci.nsIWritablePropertyBag ) { - newChannel.setProperty(this.REQDATAKEY, channelData); - } + newChannel.setProperty( + this.REQDATAKEY, + oldChannel.getProperty(this.REQDATAKEY) + ); } catch (ex) { // console.error(ex); } finally { - callback.onRedirectVerifyCallback(result); + callback.onRedirectVerifyCallback(this.ACCEPT); } } };