|
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"; |
|
5 |
|
6 module.metadata = { |
|
7 "stability": "stable" |
|
8 }; |
|
9 |
|
10 const { deprecateFunction } = require("../util/deprecate"); |
|
11 const { Cc, Ci } = require("chrome"); |
|
12 const XMLHttpRequest = require("../addon/window").window.XMLHttpRequest; |
|
13 |
|
14 Object.defineProperties(XMLHttpRequest.prototype, { |
|
15 mozBackgroundRequest: { |
|
16 value: true, |
|
17 }, |
|
18 forceAllowThirdPartyCookie: { |
|
19 configurable: true, |
|
20 value: deprecateFunction(function() { |
|
21 forceAllowThirdPartyCookie(this); |
|
22 |
|
23 }, "`xhr.forceAllowThirdPartyCookie()` is deprecated, please use" + |
|
24 "`require('sdk/net/xhr').forceAllowThirdPartyCookie(request)` instead") |
|
25 } |
|
26 }); |
|
27 exports.XMLHttpRequest = XMLHttpRequest; |
|
28 |
|
29 function forceAllowThirdPartyCookie(xhr) { |
|
30 if (xhr.channel instanceof Ci.nsIHttpChannelInternal) |
|
31 xhr.channel.forceAllowThirdPartyCookie = true; |
|
32 } |
|
33 exports.forceAllowThirdPartyCookie = forceAllowThirdPartyCookie; |
|
34 |
|
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. |