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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     4 "use strict";
     6 module.metadata = {
     7   "stability": "stable"
     8 };
    10 const { deprecateFunction } = require("../util/deprecate");
    11 const { Cc, Ci } = require("chrome");
    12 const XMLHttpRequest = require("../addon/window").window.XMLHttpRequest;
    14 Object.defineProperties(XMLHttpRequest.prototype, {
    15   mozBackgroundRequest: {
    16     value: true,
    17   },
    18   forceAllowThirdPartyCookie: {
    19     configurable: true,
    20     value: deprecateFunction(function() {
    21       forceAllowThirdPartyCookie(this);
    23     }, "`xhr.forceAllowThirdPartyCookie()` is deprecated, please use" +
    24        "`require('sdk/net/xhr').forceAllowThirdPartyCookie(request)` instead")
    25   }
    26 });
    27 exports.XMLHttpRequest = XMLHttpRequest;
    29 function forceAllowThirdPartyCookie(xhr) {
    30   if (xhr.channel instanceof Ci.nsIHttpChannelInternal)
    31     xhr.channel.forceAllowThirdPartyCookie = true;
    32 }
    33 exports.forceAllowThirdPartyCookie = forceAllowThirdPartyCookie;
    35 // No need to handle add-on unloads as addon/window is closed at unload
    36 // and it will take down all the associated requests.

mercurial