|
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 * www.w3.org/TR/2012/WD-XMLHttpRequest-20120117/ |
|
8 * |
|
9 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C |
|
10 * liability, trademark and document use rules apply. |
|
11 */ |
|
12 |
|
13 interface Blob; |
|
14 interface InputStream; |
|
15 interface MozChannel; |
|
16 interface IID; |
|
17 |
|
18 enum XMLHttpRequestResponseType { |
|
19 "", |
|
20 "arraybuffer", |
|
21 "blob", |
|
22 "document", |
|
23 "json", |
|
24 "text", |
|
25 |
|
26 // Mozilla-specific stuff |
|
27 "moz-chunked-text", |
|
28 "moz-chunked-arraybuffer", |
|
29 "moz-blob" |
|
30 }; |
|
31 |
|
32 /** |
|
33 * Parameters for instantiating an XMLHttpRequest. They are passed as an |
|
34 * optional argument to the constructor: |
|
35 * |
|
36 * new XMLHttpRequest({anon: true, system: true}); |
|
37 */ |
|
38 dictionary MozXMLHttpRequestParameters |
|
39 { |
|
40 /** |
|
41 * If true, the request will be sent without cookie and authentication |
|
42 * headers. |
|
43 */ |
|
44 boolean mozAnon = false; |
|
45 |
|
46 /** |
|
47 * If true, the same origin policy will not be enforced on the request. |
|
48 */ |
|
49 boolean mozSystem = false; |
|
50 }; |
|
51 |
|
52 [Constructor(optional MozXMLHttpRequestParameters params), |
|
53 // There are apparently callers, specifically CoffeeScript, who do |
|
54 // things like this: |
|
55 // c = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP") |
|
56 // To handle that, we need a constructor that takes a string. |
|
57 Constructor(DOMString ignored)] |
|
58 interface XMLHttpRequest : XMLHttpRequestEventTarget { |
|
59 // event handler |
|
60 attribute EventHandler onreadystatechange; |
|
61 |
|
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; |
|
68 |
|
69 readonly attribute unsigned short readyState; |
|
70 |
|
71 // request |
|
72 [Throws] |
|
73 void open(ByteString method, DOMString url); |
|
74 [Throws] |
|
75 void open(ByteString method, DOMString url, boolean async, |
|
76 optional DOMString? user, optional DOMString? password); |
|
77 [Throws] |
|
78 void setRequestHeader(ByteString header, ByteString value); |
|
79 |
|
80 [SetterThrows] |
|
81 attribute unsigned long timeout; |
|
82 |
|
83 [SetterThrows] |
|
84 attribute boolean withCredentials; |
|
85 |
|
86 [Throws=Workers] |
|
87 readonly attribute XMLHttpRequestUpload upload; |
|
88 |
|
89 [Throws] |
|
90 void send(); |
|
91 [Throws] |
|
92 void send(ArrayBuffer data); |
|
93 [Throws] |
|
94 void send(ArrayBufferView data); |
|
95 [Throws] |
|
96 void send(Blob data); |
|
97 [Throws] |
|
98 void send(Document data); |
|
99 [Throws] |
|
100 void send(DOMString? data); |
|
101 [Throws] |
|
102 void send(FormData data); |
|
103 [Throws] |
|
104 void send(InputStream data); |
|
105 |
|
106 [Throws=Workers] |
|
107 void abort(); |
|
108 |
|
109 // response |
|
110 [Throws=Workers] |
|
111 readonly attribute unsigned short status; |
|
112 |
|
113 readonly attribute ByteString statusText; |
|
114 [Throws] |
|
115 ByteString? getResponseHeader(ByteString header); |
|
116 |
|
117 [Throws=Workers] |
|
118 ByteString getAllResponseHeaders(); |
|
119 |
|
120 [Throws=Workers] |
|
121 void overrideMimeType(DOMString mime); |
|
122 |
|
123 [SetterThrows] |
|
124 attribute XMLHttpRequestResponseType responseType; |
|
125 [Throws] |
|
126 readonly attribute any response; |
|
127 [Throws] |
|
128 readonly attribute DOMString? responseText; |
|
129 |
|
130 [Throws=MainThread] |
|
131 readonly attribute Document? responseXML; |
|
132 |
|
133 // Mozilla-specific stuff |
|
134 |
|
135 [SetterThrows=Workers] |
|
136 attribute boolean mozBackgroundRequest; |
|
137 |
|
138 [ChromeOnly] |
|
139 readonly attribute MozChannel? channel; |
|
140 |
|
141 [Throws] |
|
142 void sendAsBinary(DOMString body); |
|
143 [Throws, ChromeOnly] |
|
144 any getInterface(IID iid); |
|
145 |
|
146 readonly attribute boolean mozAnon; |
|
147 readonly attribute boolean mozSystem; |
|
148 }; |