addon-sdk/source/lib/sdk/net/xhr.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/lib/sdk/net/xhr.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +"use strict";
     1.8 +
     1.9 +module.metadata = {
    1.10 +  "stability": "stable"
    1.11 +};
    1.12 +
    1.13 +const { deprecateFunction } = require("../util/deprecate");
    1.14 +const { Cc, Ci } = require("chrome");
    1.15 +const XMLHttpRequest = require("../addon/window").window.XMLHttpRequest;
    1.16 +
    1.17 +Object.defineProperties(XMLHttpRequest.prototype, {
    1.18 +  mozBackgroundRequest: {
    1.19 +    value: true,
    1.20 +  },
    1.21 +  forceAllowThirdPartyCookie: {
    1.22 +    configurable: true,
    1.23 +    value: deprecateFunction(function() {
    1.24 +      forceAllowThirdPartyCookie(this);
    1.25 +
    1.26 +    }, "`xhr.forceAllowThirdPartyCookie()` is deprecated, please use" +
    1.27 +       "`require('sdk/net/xhr').forceAllowThirdPartyCookie(request)` instead")
    1.28 +  }
    1.29 +});
    1.30 +exports.XMLHttpRequest = XMLHttpRequest;
    1.31 +
    1.32 +function forceAllowThirdPartyCookie(xhr) {
    1.33 +  if (xhr.channel instanceof Ci.nsIHttpChannelInternal)
    1.34 +    xhr.channel.forceAllowThirdPartyCookie = true;
    1.35 +}
    1.36 +exports.forceAllowThirdPartyCookie = forceAllowThirdPartyCookie;
    1.37 +
    1.38 +// No need to handle add-on unloads as addon/window is closed at unload
    1.39 +// and it will take down all the associated requests.

mercurial