Bug 1861467 - [wpt-sync] Update web-platform-tests to eedf737ce39c512d0ca3471f988972e...
[gecko.git] / dom / webidl / XMLHttpRequest.webidl
blob66cd6cc79de18107a5b5fbf22b4394b4e4c312a5
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.
36    */
37   boolean mozAnon = false;
39   /**
40    * If true, the same origin policy will not be enforced on the request.
41    */
42   boolean mozSystem = false;
45 [Exposed=(Window,DedicatedWorker,SharedWorker)]
46 interface XMLHttpRequest : XMLHttpRequestEventTarget {
47   [Throws]
48   constructor(optional MozXMLHttpRequestParameters params = {});
49   // There are apparently callers, specifically CoffeeScript, who do
50   // things like this:
51   //   c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP")
52   // To handle that, we need a constructor that takes a string.
53   [Throws]
54   constructor(DOMString ignored);
56   // event handler
57   attribute EventHandler onreadystatechange;
59   // states
60   const unsigned short UNSENT = 0;
61   const unsigned short OPENED = 1;
62   const unsigned short HEADERS_RECEIVED = 2;
63   const unsigned short LOADING = 3;
64   const unsigned short DONE = 4;
66   readonly attribute unsigned short readyState;
68   // request
69   [Throws]
70   undefined open(ByteString method, USVString url);
71   [Throws]
72   undefined open(ByteString method, USVString url, boolean async,
73             optional USVString? user=null, optional USVString? password=null);
74   [Throws]
75   undefined setRequestHeader(ByteString header, ByteString value);
77   [SetterThrows]
78   attribute unsigned long timeout;
80   [SetterThrows]
81   attribute boolean withCredentials;
83   [Throws]
84   readonly attribute XMLHttpRequestUpload upload;
86   [Throws]
87   undefined send(optional (Document or XMLHttpRequestBodyInit)? body = null);
89   [Throws]
90   undefined abort();
92   // response
93   readonly attribute USVString responseURL;
95   [Throws]
96   readonly attribute unsigned short status;
98   [Throws]
99   readonly attribute ByteString statusText;
101   [Throws]
102   ByteString? getResponseHeader(ByteString header);
104   [Throws]
105   ByteString getAllResponseHeaders();
107   [Throws]
108   undefined overrideMimeType(DOMString mime);
110   [SetterThrows]
111   attribute XMLHttpRequestResponseType responseType;
112   [Throws]
113   readonly attribute any response;
114   [Cached, Pure, Throws]
115   readonly attribute USVString? responseText;
117   [Throws, Exposed=Window]
118   readonly attribute Document? responseXML;
120   // Mozilla-specific stuff
122   [ChromeOnly, SetterThrows]
123   attribute boolean mozBackgroundRequest;
125   [ChromeOnly, Exposed=Window]
126   readonly attribute MozChannel? channel;
128   [Throws, ChromeOnly, Exposed=Window]
129   any getInterface(any iid);
131   [ChromeOnly, Exposed=Window]
132   undefined setOriginAttributes(optional OriginAttributesDictionary originAttributes = {});
134   [ChromeOnly, Throws]
135   undefined sendInputStream(InputStream body);
137   // Only works on MainThread.
138   // Its permanence is to be evaluated in bug 1368540 for Firefox 60.
139   [ChromeOnly]
140   readonly attribute unsigned short errorCode;
142   readonly attribute boolean mozAnon;
143   readonly attribute boolean mozSystem;