michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: "use strict"; michael@0: michael@0: module.metadata = { michael@0: "stability": "stable" michael@0: }; michael@0: michael@0: const { deprecateFunction } = require("../util/deprecate"); michael@0: const { Cc, Ci } = require("chrome"); michael@0: const XMLHttpRequest = require("../addon/window").window.XMLHttpRequest; michael@0: michael@0: Object.defineProperties(XMLHttpRequest.prototype, { michael@0: mozBackgroundRequest: { michael@0: value: true, michael@0: }, michael@0: forceAllowThirdPartyCookie: { michael@0: configurable: true, michael@0: value: deprecateFunction(function() { michael@0: forceAllowThirdPartyCookie(this); michael@0: michael@0: }, "`xhr.forceAllowThirdPartyCookie()` is deprecated, please use" + michael@0: "`require('sdk/net/xhr').forceAllowThirdPartyCookie(request)` instead") michael@0: } michael@0: }); michael@0: exports.XMLHttpRequest = XMLHttpRequest; michael@0: michael@0: function forceAllowThirdPartyCookie(xhr) { michael@0: if (xhr.channel instanceof Ci.nsIHttpChannelInternal) michael@0: xhr.channel.forceAllowThirdPartyCookie = true; michael@0: } michael@0: exports.forceAllowThirdPartyCookie = forceAllowThirdPartyCookie; michael@0: michael@0: // No need to handle add-on unloads as addon/window is closed at unload michael@0: // and it will take down all the associated requests.