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
37 boolean mozAnon = false;
40 * If true, the same origin policy will not be enforced on the request.
42 boolean mozSystem = false;
45 [Exposed=(Window,DedicatedWorker,SharedWorker)]
46 interface XMLHttpRequest : XMLHttpRequestEventTarget {
48 constructor(optional MozXMLHttpRequestParameters params = {});
49 // There are apparently callers, specifically CoffeeScript, who do
51 // c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP")
52 // To handle that, we need a constructor that takes a string.
54 constructor(DOMString ignored);
57 attribute EventHandler onreadystatechange;
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;
70 undefined open(ByteString method, USVString url);
72 undefined open(ByteString method, USVString url, boolean async,
73 optional USVString? user=null, optional USVString? password=null);
75 undefined setRequestHeader(ByteString header, ByteString value);
78 attribute unsigned long timeout;
81 attribute boolean withCredentials;
84 readonly attribute XMLHttpRequestUpload upload;
87 undefined send(optional (Document or XMLHttpRequestBodyInit)? body = null);
93 readonly attribute USVString responseURL;
96 readonly attribute unsigned short status;
99 readonly attribute ByteString statusText;
102 ByteString? getResponseHeader(ByteString header);
105 ByteString getAllResponseHeaders();
108 undefined overrideMimeType(DOMString mime);
111 attribute XMLHttpRequestResponseType responseType;
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 = {});
135 undefined sendInputStream(InputStream body);
137 // Only works on MainThread.
138 // Its permanence is to be evaluated in bug 1368540 for Firefox 60.
140 readonly attribute unsigned short errorCode;
142 readonly attribute boolean mozAnon;
143 readonly attribute boolean mozSystem;