1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
use super::*;
/// The XMLHttpRequest class.
/// [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct XMLHttpRequest {
inner: XMLHttpRequestEventTarget,
}
impl FromVal for XMLHttpRequest {
fn from_val(v: &Any) -> Self {
XMLHttpRequest {
inner: XMLHttpRequestEventTarget::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for XMLHttpRequest {
type Target = XMLHttpRequestEventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for XMLHttpRequest {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for XMLHttpRequest {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for XMLHttpRequest {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<XMLHttpRequest> for Any {
fn from(s: XMLHttpRequest) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&XMLHttpRequest> for Any {
fn from(s: &XMLHttpRequest) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(XMLHttpRequest);
impl XMLHttpRequest {
/// Getter of the `onreadystatechange` attribute.
/// [`XMLHttpRequest.onreadystatechange`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/onreadystatechange)
pub fn onreadystatechange(&self) -> Any {
self.inner.get("onreadystatechange").as_::<Any>()
}
/// Setter of the `onreadystatechange` attribute.
/// [`XMLHttpRequest.onreadystatechange`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/onreadystatechange)
pub fn set_onreadystatechange(&mut self, value: &Any) {
self.inner.set("onreadystatechange", value);
}
}
impl XMLHttpRequest {
/// Getter of the `readyState` attribute.
/// [`XMLHttpRequest.readyState`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState)
pub fn ready_state(&self) -> u16 {
self.inner.get("readyState").as_::<u16>()
}
}
impl XMLHttpRequest {
/// Getter of the `timeout` attribute.
/// [`XMLHttpRequest.timeout`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout)
pub fn timeout(&self) -> u32 {
self.inner.get("timeout").as_::<u32>()
}
/// Setter of the `timeout` attribute.
/// [`XMLHttpRequest.timeout`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout)
pub fn set_timeout(&mut self, value: u32) {
self.inner.set("timeout", value);
}
}
impl XMLHttpRequest {
/// Getter of the `withCredentials` attribute.
/// [`XMLHttpRequest.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials)
pub fn with_credentials(&self) -> bool {
self.inner.get("withCredentials").as_::<bool>()
}
/// Setter of the `withCredentials` attribute.
/// [`XMLHttpRequest.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials)
pub fn set_with_credentials(&mut self, value: bool) {
self.inner.set("withCredentials", value);
}
}
impl XMLHttpRequest {
/// Getter of the `upload` attribute.
/// [`XMLHttpRequest.upload`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/upload)
pub fn upload(&self) -> XMLHttpRequestUpload {
self.inner.get("upload").as_::<XMLHttpRequestUpload>()
}
}
impl XMLHttpRequest {
/// Getter of the `responseURL` attribute.
/// [`XMLHttpRequest.responseURL`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL)
pub fn response_url(&self) -> JsString {
self.inner.get("responseURL").as_::<JsString>()
}
}
impl XMLHttpRequest {
/// Getter of the `status` attribute.
/// [`XMLHttpRequest.status`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/status)
pub fn status(&self) -> u16 {
self.inner.get("status").as_::<u16>()
}
}
impl XMLHttpRequest {
/// Getter of the `statusText` attribute.
/// [`XMLHttpRequest.statusText`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/statusText)
pub fn status_text(&self) -> JsString {
self.inner.get("statusText").as_::<JsString>()
}
}
impl XMLHttpRequest {
/// Getter of the `responseType` attribute.
/// [`XMLHttpRequest.responseType`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType)
pub fn response_type(&self) -> XMLHttpRequestResponseType {
self.inner
.get("responseType")
.as_::<XMLHttpRequestResponseType>()
}
/// Setter of the `responseType` attribute.
/// [`XMLHttpRequest.responseType`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType)
pub fn set_response_type(&mut self, value: &XMLHttpRequestResponseType) {
self.inner.set("responseType", value);
}
}
impl XMLHttpRequest {
/// Getter of the `response` attribute.
/// [`XMLHttpRequest.response`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/response)
pub fn response(&self) -> Any {
self.inner.get("response").as_::<Any>()
}
}
impl XMLHttpRequest {
/// Getter of the `responseText` attribute.
/// [`XMLHttpRequest.responseText`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText)
pub fn response_text(&self) -> JsString {
self.inner.get("responseText").as_::<JsString>()
}
}
impl XMLHttpRequest {
/// Getter of the `responseXML` attribute.
/// [`XMLHttpRequest.responseXML`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML)
pub fn response_xml(&self) -> Document {
self.inner.get("responseXML").as_::<Document>()
}
}
impl XMLHttpRequest {
/// The `new XMLHttpRequest(..)` constructor, creating a new XMLHttpRequest instance
pub fn new() -> XMLHttpRequest {
Self {
inner: Any::global("XMLHttpRequest")
.new(&[])
.as_::<XMLHttpRequestEventTarget>(),
}
}
}
impl XMLHttpRequest {
/// The open method.
/// [`XMLHttpRequest.open`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open)
pub fn open(&self, method: &JsString, url: &JsString) -> Undefined {
self.inner
.call("open", &[method.into(), url.into()])
.as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The open method.
/// [`XMLHttpRequest.open`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open)
pub fn open_with_method_and_url_and_async(
&self,
method: &JsString,
url: &JsString,
async_: bool,
) -> Undefined {
self.inner
.call("open", &[method.into(), url.into(), async_.into()])
.as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The open method.
/// [`XMLHttpRequest.open`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open)
pub fn open_with_username(
&self,
method: &JsString,
url: &JsString,
async_: bool,
username: &JsString,
) -> Undefined {
self.inner
.call(
"open",
&[method.into(), url.into(), async_.into(), username.into()],
)
.as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The open method.
/// [`XMLHttpRequest.open`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open)
pub fn open_with_username_and_password(
&self,
method: &JsString,
url: &JsString,
async_: bool,
username: &JsString,
password: &JsString,
) -> Undefined {
self.inner
.call(
"open",
&[
method.into(),
url.into(),
async_.into(),
username.into(),
password.into(),
],
)
.as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The setRequestHeader method.
/// [`XMLHttpRequest.setRequestHeader`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader)
pub fn set_request_header(&self, name: &JsString, value: &JsString) -> Undefined {
self.inner
.call("setRequestHeader", &[name.into(), value.into()])
.as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The send method.
/// [`XMLHttpRequest.send`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send)
pub fn send(&self) -> Undefined {
self.inner.call("send", &[]).as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The send method.
/// [`XMLHttpRequest.send`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send)
pub fn send_with_body(&self, body: &Any) -> Undefined {
self.inner.call("send", &[body.into()]).as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The abort method.
/// [`XMLHttpRequest.abort`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/abort)
pub fn abort(&self) -> Undefined {
self.inner.call("abort", &[]).as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The getResponseHeader method.
/// [`XMLHttpRequest.getResponseHeader`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getResponseHeader)
pub fn get_response_header(&self, name: &JsString) -> JsString {
self.inner
.call("getResponseHeader", &[name.into()])
.as_::<JsString>()
}
}
impl XMLHttpRequest {
/// The getAllResponseHeaders method.
/// [`XMLHttpRequest.getAllResponseHeaders`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders)
pub fn get_all_response_headers(&self) -> JsString {
self.inner
.call("getAllResponseHeaders", &[])
.as_::<JsString>()
}
}
impl XMLHttpRequest {
/// The overrideMimeType method.
/// [`XMLHttpRequest.overrideMimeType`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/overrideMimeType)
pub fn override_mime_type(&self, mime: &JsString) -> Undefined {
self.inner
.call("overrideMimeType", &[mime.into()])
.as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The setAttributionReporting method.
/// [`XMLHttpRequest.setAttributionReporting`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setAttributionReporting)
pub fn set_attribution_reporting(
&self,
options: &AttributionReportingRequestOptions,
) -> Undefined {
self.inner
.call("setAttributionReporting", &[options.into()])
.as_::<Undefined>()
}
}
impl XMLHttpRequest {
/// The setPrivateToken method.
/// [`XMLHttpRequest.setPrivateToken`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setPrivateToken)
pub fn set_private_token(&self, private_token: &PrivateToken) -> Undefined {
self.inner
.call("setPrivateToken", &[private_token.into()])
.as_::<Undefined>()
}
}