Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / webidl / XMLHttpRequest.webidl
blobb1cc840faae7857c4db3937f3b395e5c59f971b3
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * The origin of this IDL file is
7  * https://xhr.spec.whatwg.org/#interface-xmlhttprequest
8  *
9  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
10  * liability, trademark and document use rules apply.
11  */
13 interface InputStream;
14 interface MozChannel;
16 enum XMLHttpRequestResponseType {
17   "",
18   "arraybuffer",
19   "blob",
20   "document",
21   "json",
22   "text",
25 /**
26  * Parameters for instantiating an XMLHttpRequest. They are passed as an
27  * optional argument to the constructor:
28  *
29  *  new XMLHttpRequest({anon: true, system: true});
30  */
31 dictionary MozXMLHttpRequestParameters
33   /**
34    * If true, the request will be sent without cookie and authentication
35    * headers. Defaults to true for system/privileged/chrome requests,
36    * and to false otherwise.
37    * Note that even if set to true, for system/privileged/chrome requests,
38    * manually-set 'Cookie' headers are not removed.
39    */
40   boolean mozAnon;
42   /**
43    * If true, the same origin policy will not be enforced on the request.
44    */
45   boolean mozSystem = false;
48 [Exposed=(Window,DedicatedWorker,SharedWorker)]
49 interface XMLHttpRequest : XMLHttpRequestEventTarget {
50   [Throws]
51   constructor(optional MozXMLHttpRequestParameters params = {});
52   // There are apparently callers, specifically CoffeeScript, who do
53   // things like this:
54   //   c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP")
55   // To handle that, we need a constructor that takes a string.
56   [Throws]
57   constructor(DOMString ignored);
59   // event handler
60   attribute EventHandler onreadystatechange;
62   // states
63   const unsigned short UNSENT = 0;
64   const unsigned short OPENED = 1;
65   const unsigned short HEADERS_RECEIVED = 2;
66   const unsigned short LOADING = 3;
67   const unsigned short DONE = 4;
69   readonly attribute unsigned short readyState;
71   // request
72   [Throws]
73   undefined open(ByteString method, USVString url);
74   [Throws]
75   undefined open(ByteString method, USVString url, boolean async,
76             optional USVString? user=null, optional USVString? password=null);
77   [Throws]
78   undefined setRequestHeader(ByteString header, ByteString value);
80   [SetterThrows]
81   attribute unsigned long timeout;
83   [SetterThrows]
84   attribute boolean withCredentials;
86   [Throws]
87   readonly attribute XMLHttpRequestUpload upload;
89   [Throws]
90   undefined send(optional (Document or XMLHttpRequestBodyInit)? body = null);
92   [Throws]
93   undefined abort();
95   // response
96   readonly attribute USVString responseURL;
98   [Throws]
99   readonly attribute unsigned short status;
101   [Throws]
102   readonly attribute ByteString statusText;
104   [Throws]
105   ByteString? getResponseHeader(ByteString header);
107   [Throws]
108   ByteString getAllResponseHeaders();
110   [Throws]
111   undefined overrideMimeType(DOMString mime);
113   [SetterThrows]
114   attribute XMLHttpRequestResponseType responseType;
115   [Throws]
116   readonly attribute any response;
117   [Cached, Pure, Throws]
118   readonly attribute USVString? responseText;
120   [Throws, Exposed=Window]
121   readonly attribute Document? responseXML;
123   // Mozilla-specific stuff
125   [ChromeOnly, SetterThrows]
126   attribute boolean mozBackgroundRequest;
128   [ChromeOnly, Exposed=Window]
129   readonly attribute MozChannel? channel;
131   [Throws, ChromeOnly, Exposed=Window]
132   any getInterface(any iid);
134   [ChromeOnly, Exposed=Window]
135   undefined setOriginAttributes(optional OriginAttributesDictionary originAttributes = {});
137   [ChromeOnly, Throws]
138   undefined sendInputStream(InputStream body);
140   // Only works on MainThread.
141   // Its permanence is to be evaluated in bug 1368540 for Firefox 60.
142   [ChromeOnly]
143   readonly attribute unsigned short errorCode;
145   readonly attribute boolean mozAnon;
146   readonly attribute boolean mozSystem;