| Index: lib/compat.js |
| diff --git a/lib/compat.js b/lib/compat.js |
| index f7ed72a23c4eae74ce70b9c89c31b681b6a04b36..b37ff5548de1867e49001e87f6eabacea892ec7b 100644 |
| --- a/lib/compat.js |
| +++ b/lib/compat.js |
| @@ -384,7 +384,8 @@ XMLHttpRequest.prototype = |
| throw new Error("Sending data to server is not supported"); |
| this.readyState = 3; |
| - window._webRequest.GET(this._url, this._requestHeaders, function(result) |
| + |
| + var onGetDone = function(result) |
| { |
| this.channel.status = result.status; |
| this.status = result.responseStatus; |
| @@ -403,6 +404,22 @@ XMLHttpRequest.prototype = |
| var list = this["_" + eventName + "Handlers"]; |
| for (var i = 0; i < list.length; i++) |
| list[i].call(this, event); |
| + }.bind(this); |
| + // HACK (#5066): the code checking whether the connection is allowed is temporary, |
| + // the actual check should be in the core when we make a decision whether |
| + // to update a subscription with current connection or not, thus whether to |
| + // even construct XMLHttpRequest object or not. |
| + _isSubscriptionDownloadAllowed(function(isAllowed) |
| + { |
| + if (!isAllowed) |
| + { |
| + onGetDone({ |
| + status: 0x804b000d, //NS_ERROR_CONNECTION_REFUSED; |
| + responseStatus: 0 |
| + }); |
| + return; |
| + } |
| + window._webRequest.GET(this._url, this._requestHeaders, onGetDone); |
| }.bind(this)); |
| }, |
| @@ -444,6 +461,16 @@ XMLHttpRequest.prototype = |
| } |
| }; |
| +function _isSubscriptionDownloadAllowed(callback) { |
| + // It's a bit hacky, JsEngine interface which is used by FilterEngine does |
| + // not allow to inject an arbitrary callback, so we use triggerEvent |
| + // mechanism. |
| + // Yet one hack (#5039). |
| + var allowed_connection_type = require("prefs").Prefs.allowed_connection_type; |
| + if (allowed_connection_type == "") |
| + allowed_connection_type = null; |
| + _triggerEvent("_isSubscriptionDownloadAllowed", allowed_connection_type, callback); |
| +} |
| // Polyfill Array.prototype.find |
| // from https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find |