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/.
6 * The origin of this IDL file is
7 * https://xhr.spec.whatwg.org/#interface-xmlhttprequest
9 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
10 * liability, trademark and document use rules apply.
13 interface InputStream;
16 enum XMLHttpRequestResponseType {
26 * Parameters for instantiating an XMLHttpRequest. They are passed as an
27 * optional argument to the constructor:
29 * new XMLHttpRequest({anon: true, system: true});
31 dictionary MozXMLHttpRequestParameters
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.
43 * If true, the same origin policy will not be enforced on the request.
45 boolean mozSystem = false;
48 [Exposed=(Window,DedicatedWorker,SharedWorker)]
49 interface XMLHttpRequest : XMLHttpRequestEventTarget {
51 constructor(optional MozXMLHttpRequestParameters params = {});
52 // There are apparently callers, specifically CoffeeScript, who do
54 // c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP")
55 // To handle that, we need a constructor that takes a string.
57 constructor(DOMString ignored);
60 attribute EventHandler onreadystatechange;
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;
73 undefined open(ByteString method, USVString url);
75 undefined open(ByteString method, USVString url, boolean async,
76 optional USVString? user=null, optional USVString? password=null);
78 undefined setRequestHeader(ByteString header, ByteString value);
81 attribute unsigned long timeout;
84 attribute boolean withCredentials;
87 readonly attribute XMLHttpRequestUpload upload;
90 undefined send(optional (Document or XMLHttpRequestBodyInit)? body = null);
96 readonly attribute USVString responseURL;
99 readonly attribute unsigned short status;
102 readonly attribute ByteString statusText;
105 ByteString? getResponseHeader(ByteString header);
108 ByteString getAllResponseHeaders();
111 undefined overrideMimeType(DOMString mime);
114 attribute XMLHttpRequestResponseType responseType;
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 = {});
138 undefined sendInputStream(InputStream body);
140 // Only works on MainThread.
141 // Its permanence is to be evaluated in bug 1368540 for Firefox 60.
143 readonly attribute unsigned short errorCode;
145 readonly attribute boolean mozAnon;
146 readonly attribute boolean mozSystem;