Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM XMLHttpRequest.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "ChromeUtilsBinding.h"
5 : #include "EventHandlerBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "XMLHttpRequestBinding.h"
8 : #include "XMLHttpRequestEventTargetBinding.h"
9 : #include "XrayWrapper.h"
10 : #include "jsapi.h"
11 : #include "jsfriendapi.h"
12 : #include "mozilla/OwningNonNull.h"
13 : #include "mozilla/dom/BindingUtils.h"
14 : #include "mozilla/dom/Blob.h"
15 : #include "mozilla/dom/DOMJSClass.h"
16 : #include "mozilla/dom/FormData.h"
17 : #include "mozilla/dom/NonRefcountedDOMObject.h"
18 : #include "mozilla/dom/Nullable.h"
19 : #include "mozilla/dom/PrimitiveConversions.h"
20 : #include "mozilla/dom/ScriptSettings.h"
21 : #include "mozilla/dom/SimpleGlobalObject.h"
22 : #include "mozilla/dom/TypedArray.h"
23 : #include "mozilla/dom/URLSearchParams.h"
24 : #include "mozilla/dom/XMLHttpRequest.h"
25 : #include "mozilla/dom/XMLHttpRequestUpload.h"
26 : #include "mozilla/dom/XrayExpandoClass.h"
27 : #include "nsContentUtils.h"
28 : #include "nsIChannel.h"
29 : #include "nsIDocument.h"
30 : #include "nsIInputStream.h"
31 : #include "nsISupports.h"
32 : #include "nsThreadUtils.h"
33 : #include "xpcjsid.h"
34 :
35 : namespace mozilla {
36 : namespace dom {
37 :
38 : namespace XMLHttpRequestResponseTypeValues {
39 : extern const EnumEntry strings[10] = {
40 : {"", 0},
41 : {"arraybuffer", 11},
42 : {"blob", 4},
43 : {"document", 8},
44 : {"json", 4},
45 : {"text", 4},
46 : {"moz-chunked-text", 16},
47 : {"moz-chunked-arraybuffer", 23},
48 : {"moz-blob", 8},
49 : { nullptr, 0 }
50 : };
51 : } // namespace XMLHttpRequestResponseTypeValues
52 :
53 : bool
54 0 : ToJSValue(JSContext* aCx, XMLHttpRequestResponseType aArgument, JS::MutableHandle<JS::Value> aValue)
55 : {
56 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(XMLHttpRequestResponseTypeValues::strings));
57 : JSString* resultStr =
58 0 : JS_NewStringCopyN(aCx, XMLHttpRequestResponseTypeValues::strings[uint32_t(aArgument)].value,
59 0 : XMLHttpRequestResponseTypeValues::strings[uint32_t(aArgument)].length);
60 0 : if (!resultStr) {
61 0 : return false;
62 : }
63 0 : aValue.setString(resultStr);
64 0 : return true;
65 : }
66 :
67 :
68 :
69 0 : MozXMLHttpRequestParameters::MozXMLHttpRequestParameters()
70 : {
71 : // Safe to pass a null context if we pass a null value
72 0 : Init(nullptr, JS::NullHandleValue);
73 0 : }
74 :
75 :
76 :
77 : bool
78 1 : MozXMLHttpRequestParameters::InitIds(JSContext* cx, MozXMLHttpRequestParametersAtoms* atomsCache)
79 : {
80 1 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
81 :
82 : // Initialize these in reverse order so that any failure leaves the first one
83 : // uninitialized.
84 2 : if (!atomsCache->mozSystem_id.init(cx, "mozSystem") ||
85 1 : !atomsCache->mozAnon_id.init(cx, "mozAnon")) {
86 0 : return false;
87 : }
88 1 : return true;
89 : }
90 :
91 : bool
92 3 : MozXMLHttpRequestParameters::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
93 : {
94 : // Passing a null JSContext is OK only if we're initing from null,
95 : // Since in that case we will not have to do any property gets
96 : // Also evaluate isNullOrUndefined in order to avoid false-positive
97 : // checkers by static analysis tools
98 3 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
99 3 : MozXMLHttpRequestParametersAtoms* atomsCache = nullptr;
100 3 : if (cx) {
101 3 : atomsCache = GetAtomCache<MozXMLHttpRequestParametersAtoms>(cx);
102 3 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
103 0 : return false;
104 : }
105 : }
106 :
107 3 : if (!IsConvertibleToDictionary(val)) {
108 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
109 : }
110 :
111 3 : bool isNull = val.isNullOrUndefined();
112 : // We only need these if !isNull, in which case we have |cx|.
113 6 : Maybe<JS::Rooted<JSObject *> > object;
114 6 : Maybe<JS::Rooted<JS::Value> > temp;
115 3 : if (!isNull) {
116 0 : MOZ_ASSERT(cx);
117 0 : object.emplace(cx, &val.toObject());
118 0 : temp.emplace(cx);
119 : }
120 3 : if (!isNull) {
121 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->mozAnon_id, temp.ptr())) {
122 0 : return false;
123 : }
124 : }
125 3 : if (!isNull && !temp->isUndefined()) {
126 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMozAnon)) {
127 0 : return false;
128 : }
129 : } else {
130 3 : mMozAnon = false;
131 : }
132 3 : mIsAnyMemberPresent = true;
133 :
134 3 : if (!isNull) {
135 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->mozSystem_id, temp.ptr())) {
136 0 : return false;
137 : }
138 : }
139 3 : if (!isNull && !temp->isUndefined()) {
140 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMozSystem)) {
141 0 : return false;
142 : }
143 : } else {
144 3 : mMozSystem = false;
145 : }
146 3 : mIsAnyMemberPresent = true;
147 3 : return true;
148 : }
149 :
150 : bool
151 0 : MozXMLHttpRequestParameters::Init(const nsAString& aJSON)
152 : {
153 0 : AutoJSAPI jsapi;
154 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
155 0 : if (!cleanGlobal) {
156 0 : return false;
157 : }
158 0 : if (!jsapi.Init(cleanGlobal)) {
159 0 : return false;
160 : }
161 0 : JSContext* cx = jsapi.cx();
162 0 : JS::Rooted<JS::Value> json(cx);
163 0 : bool ok = ParseJSON(cx, aJSON, &json);
164 0 : NS_ENSURE_TRUE(ok, false);
165 0 : return Init(cx, json);
166 : }
167 :
168 : bool
169 0 : MozXMLHttpRequestParameters::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
170 : {
171 0 : MozXMLHttpRequestParametersAtoms* atomsCache = GetAtomCache<MozXMLHttpRequestParametersAtoms>(cx);
172 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
173 0 : return false;
174 : }
175 :
176 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
177 0 : if (!obj) {
178 0 : return false;
179 : }
180 0 : rval.set(JS::ObjectValue(*obj));
181 :
182 : do {
183 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
184 0 : JS::Rooted<JS::Value> temp(cx);
185 0 : bool const & currentValue = mMozAnon;
186 0 : temp.setBoolean(currentValue);
187 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->mozAnon_id, temp, JSPROP_ENUMERATE)) {
188 0 : return false;
189 : }
190 0 : break;
191 : } while(0);
192 :
193 : do {
194 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
195 0 : JS::Rooted<JS::Value> temp(cx);
196 0 : bool const & currentValue = mMozSystem;
197 0 : temp.setBoolean(currentValue);
198 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->mozSystem_id, temp, JSPROP_ENUMERATE)) {
199 0 : return false;
200 : }
201 0 : break;
202 : } while(0);
203 :
204 0 : return true;
205 : }
206 :
207 : bool
208 0 : MozXMLHttpRequestParameters::ToJSON(nsAString& aJSON) const
209 : {
210 0 : AutoJSAPI jsapi;
211 0 : jsapi.Init();
212 0 : JSContext *cx = jsapi.cx();
213 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
214 : // because we'll only be creating objects, in ways that have no
215 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
216 : // which likewise guarantees no side-effects for the sorts of
217 : // things we will pass it.
218 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
219 0 : JS::Rooted<JS::Value> val(cx);
220 0 : if (!ToObjectInternal(cx, &val)) {
221 0 : return false;
222 : }
223 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
224 0 : return StringifyToJSON(cx, obj, aJSON);
225 : }
226 :
227 : void
228 0 : MozXMLHttpRequestParameters::TraceDictionary(JSTracer* trc)
229 : {
230 0 : }
231 :
232 : MozXMLHttpRequestParameters&
233 0 : MozXMLHttpRequestParameters::operator=(const MozXMLHttpRequestParameters& aOther)
234 : {
235 0 : mMozAnon = aOther.mMozAnon;
236 0 : mMozSystem = aOther.mMozSystem;
237 0 : return *this;
238 : }
239 :
240 : namespace binding_detail {
241 : } // namespace binding_detail
242 :
243 :
244 : namespace XMLHttpRequestBinding {
245 :
246 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<XMLHttpRequestEventTargetBinding::NativeType>::value,
247 : "Can't inherit from an interface with a different ownership model.");
248 :
249 : static bool
250 0 : get_onreadystatechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
251 : {
252 0 : RefPtr<EventHandlerNonNull> result(self->GetOnreadystatechange());
253 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
254 0 : if (result) {
255 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
256 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
257 0 : return false;
258 : }
259 0 : return true;
260 : } else {
261 0 : args.rval().setNull();
262 0 : return true;
263 : }
264 : }
265 :
266 : static bool
267 0 : set_onreadystatechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitSetterCallArgs args)
268 : {
269 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
270 0 : if (args[0].isObject()) {
271 : { // scope for tempRoot
272 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
273 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
274 : }
275 : } else {
276 0 : arg0 = nullptr;
277 : }
278 0 : self->SetOnreadystatechange(Constify(arg0));
279 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
280 :
281 0 : return true;
282 : }
283 :
284 : static const JSJitInfo onreadystatechange_getterinfo = {
285 : { (JSJitGetterOp)get_onreadystatechange },
286 : { prototypes::id::XMLHttpRequest },
287 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
288 : JSJitInfo::Getter,
289 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
290 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
291 : false, /* isInfallible. False in setters. */
292 : false, /* isMovable. Not relevant for setters. */
293 : false, /* isEliminatable. Not relevant for setters. */
294 : false, /* isAlwaysInSlot. Only relevant for getters. */
295 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
296 : false, /* isTypedMethod. Only relevant for methods. */
297 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
298 : };
299 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
300 : static_assert(0 < 2, "There is no slot for us");
301 : static const JSJitInfo onreadystatechange_setterinfo = {
302 : { (JSJitGetterOp)set_onreadystatechange },
303 : { prototypes::id::XMLHttpRequest },
304 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
305 : JSJitInfo::Setter,
306 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
307 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
308 : false, /* isInfallible. False in setters. */
309 : false, /* isMovable. Not relevant for setters. */
310 : false, /* isEliminatable. Not relevant for setters. */
311 : false, /* isAlwaysInSlot. Only relevant for getters. */
312 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
313 : false, /* isTypedMethod. Only relevant for methods. */
314 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
315 : };
316 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
317 : static_assert(0 < 2, "There is no slot for us");
318 :
319 : static bool
320 0 : get_readyState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
321 : {
322 0 : uint16_t result(self->ReadyState());
323 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
324 0 : args.rval().setInt32(int32_t(result));
325 0 : return true;
326 : }
327 :
328 : static const JSJitInfo readyState_getterinfo = {
329 : { (JSJitGetterOp)get_readyState },
330 : { prototypes::id::XMLHttpRequest },
331 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
332 : JSJitInfo::Getter,
333 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
334 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
335 : true, /* isInfallible. False in setters. */
336 : false, /* isMovable. Not relevant for setters. */
337 : false, /* isEliminatable. Not relevant for setters. */
338 : false, /* isAlwaysInSlot. Only relevant for getters. */
339 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
340 : false, /* isTypedMethod. Only relevant for methods. */
341 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
342 : };
343 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
344 : static_assert(0 < 2, "There is no slot for us");
345 :
346 : static bool
347 3 : open(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
348 : {
349 3 : unsigned argcount = std::min(args.length(), 5u);
350 3 : switch (argcount) {
351 : case 2: {
352 0 : nsCString arg0;
353 0 : if (!ConvertJSValueToByteString(cx, args[0], false, arg0)) {
354 0 : return false;
355 : }
356 0 : binding_detail::FakeString arg1;
357 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
358 0 : return false;
359 : }
360 0 : NormalizeUSVString(arg1);
361 0 : binding_detail::FastErrorResult rv;
362 0 : self->Open(Constify(arg0), Constify(arg1), rv);
363 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
364 0 : return false;
365 : }
366 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
367 0 : args.rval().setUndefined();
368 0 : return true;
369 : break;
370 : }
371 : case 3: {
372 : MOZ_FALLTHROUGH;
373 : }
374 : case 4: {
375 : MOZ_FALLTHROUGH;
376 : }
377 : case 5: {
378 6 : nsCString arg0;
379 3 : if (!ConvertJSValueToByteString(cx, args[0], false, arg0)) {
380 0 : return false;
381 : }
382 6 : binding_detail::FakeString arg1;
383 3 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
384 0 : return false;
385 : }
386 3 : NormalizeUSVString(arg1);
387 : bool arg2;
388 3 : if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
389 0 : return false;
390 : }
391 6 : binding_detail::FakeString arg3;
392 3 : if (args.hasDefined(3)) {
393 0 : if (!ConvertJSValueToString(cx, args[3], eNull, eNull, arg3)) {
394 0 : return false;
395 : }
396 0 : NormalizeUSVString(arg3);
397 : } else {
398 3 : arg3.SetIsVoid(true);
399 : }
400 6 : binding_detail::FakeString arg4;
401 3 : if (args.hasDefined(4)) {
402 0 : if (!ConvertJSValueToString(cx, args[4], eNull, eNull, arg4)) {
403 0 : return false;
404 : }
405 0 : NormalizeUSVString(arg4);
406 : } else {
407 3 : arg4.SetIsVoid(true);
408 : }
409 6 : binding_detail::FastErrorResult rv;
410 3 : self->Open(Constify(arg0), Constify(arg1), arg2, Constify(arg3), Constify(arg4), rv);
411 3 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
412 0 : return false;
413 : }
414 3 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
415 3 : args.rval().setUndefined();
416 3 : return true;
417 : break;
418 : }
419 : default: {
420 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLHttpRequest.open");
421 : break;
422 : }
423 : }
424 : MOZ_CRASH("We have an always-returning default case");
425 : return false;
426 : }
427 :
428 : static const JSJitInfo open_methodinfo = {
429 : { (JSJitGetterOp)open },
430 : { prototypes::id::XMLHttpRequest },
431 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
432 : JSJitInfo::Method,
433 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
434 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
435 : false, /* isInfallible. False in setters. */
436 : false, /* isMovable. Not relevant for setters. */
437 : false, /* isEliminatable. Not relevant for setters. */
438 : false, /* isAlwaysInSlot. Only relevant for getters. */
439 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
440 : false, /* isTypedMethod. Only relevant for methods. */
441 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
442 : };
443 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
444 : static_assert(0 < 2, "There is no slot for us");
445 :
446 : static bool
447 0 : setRequestHeader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
448 : {
449 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
450 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLHttpRequest.setRequestHeader");
451 : }
452 0 : nsCString arg0;
453 0 : if (!ConvertJSValueToByteString(cx, args[0], false, arg0)) {
454 0 : return false;
455 : }
456 0 : nsCString arg1;
457 0 : if (!ConvertJSValueToByteString(cx, args[1], false, arg1)) {
458 0 : return false;
459 : }
460 0 : binding_detail::FastErrorResult rv;
461 0 : self->SetRequestHeader(Constify(arg0), Constify(arg1), rv);
462 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
463 0 : return false;
464 : }
465 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
466 0 : args.rval().setUndefined();
467 0 : return true;
468 : }
469 :
470 : static const JSJitInfo setRequestHeader_methodinfo = {
471 : { (JSJitGetterOp)setRequestHeader },
472 : { prototypes::id::XMLHttpRequest },
473 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
474 : JSJitInfo::Method,
475 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
476 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
477 : false, /* isInfallible. False in setters. */
478 : false, /* isMovable. Not relevant for setters. */
479 : false, /* isEliminatable. Not relevant for setters. */
480 : false, /* isAlwaysInSlot. Only relevant for getters. */
481 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
482 : false, /* isTypedMethod. Only relevant for methods. */
483 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
484 : };
485 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
486 : static_assert(0 < 2, "There is no slot for us");
487 :
488 : static bool
489 0 : get_timeout(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
490 : {
491 0 : uint32_t result(self->Timeout());
492 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
493 0 : args.rval().setNumber(result);
494 0 : return true;
495 : }
496 :
497 : static bool
498 0 : set_timeout(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitSetterCallArgs args)
499 : {
500 : uint32_t arg0;
501 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
502 0 : return false;
503 : }
504 0 : binding_detail::FastErrorResult rv;
505 0 : self->SetTimeout(arg0, rv);
506 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
507 0 : return false;
508 : }
509 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
510 :
511 0 : return true;
512 : }
513 :
514 : static const JSJitInfo timeout_getterinfo = {
515 : { (JSJitGetterOp)get_timeout },
516 : { prototypes::id::XMLHttpRequest },
517 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
518 : JSJitInfo::Getter,
519 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
520 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
521 : true, /* isInfallible. False in setters. */
522 : false, /* isMovable. Not relevant for setters. */
523 : false, /* isEliminatable. Not relevant for setters. */
524 : false, /* isAlwaysInSlot. Only relevant for getters. */
525 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
526 : false, /* isTypedMethod. Only relevant for methods. */
527 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
528 : };
529 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
530 : static_assert(0 < 2, "There is no slot for us");
531 : static const JSJitInfo timeout_setterinfo = {
532 : { (JSJitGetterOp)set_timeout },
533 : { prototypes::id::XMLHttpRequest },
534 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
535 : JSJitInfo::Setter,
536 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
537 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
538 : false, /* isInfallible. False in setters. */
539 : false, /* isMovable. Not relevant for setters. */
540 : false, /* isEliminatable. Not relevant for setters. */
541 : false, /* isAlwaysInSlot. Only relevant for getters. */
542 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
543 : false, /* isTypedMethod. Only relevant for methods. */
544 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
545 : };
546 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
547 : static_assert(0 < 2, "There is no slot for us");
548 :
549 : static bool
550 0 : get_withCredentials(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
551 : {
552 0 : bool result(self->WithCredentials());
553 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
554 0 : args.rval().setBoolean(result);
555 0 : return true;
556 : }
557 :
558 : static bool
559 0 : set_withCredentials(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitSetterCallArgs args)
560 : {
561 : bool arg0;
562 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
563 0 : return false;
564 : }
565 0 : binding_detail::FastErrorResult rv;
566 0 : self->SetWithCredentials(arg0, rv);
567 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
568 0 : return false;
569 : }
570 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
571 :
572 0 : return true;
573 : }
574 :
575 : static const JSJitInfo withCredentials_getterinfo = {
576 : { (JSJitGetterOp)get_withCredentials },
577 : { prototypes::id::XMLHttpRequest },
578 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
579 : JSJitInfo::Getter,
580 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
581 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
582 : true, /* isInfallible. False in setters. */
583 : false, /* isMovable. Not relevant for setters. */
584 : false, /* isEliminatable. Not relevant for setters. */
585 : false, /* isAlwaysInSlot. Only relevant for getters. */
586 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
587 : false, /* isTypedMethod. Only relevant for methods. */
588 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
589 : };
590 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
591 : static_assert(0 < 2, "There is no slot for us");
592 : static const JSJitInfo withCredentials_setterinfo = {
593 : { (JSJitGetterOp)set_withCredentials },
594 : { prototypes::id::XMLHttpRequest },
595 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
596 : JSJitInfo::Setter,
597 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
598 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
599 : false, /* isInfallible. False in setters. */
600 : false, /* isMovable. Not relevant for setters. */
601 : false, /* isEliminatable. Not relevant for setters. */
602 : false, /* isAlwaysInSlot. Only relevant for getters. */
603 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
604 : false, /* isTypedMethod. Only relevant for methods. */
605 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
606 : };
607 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
608 : static_assert(0 < 2, "There is no slot for us");
609 :
610 : static bool
611 0 : get_upload(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
612 : {
613 0 : binding_detail::FastErrorResult rv;
614 0 : auto result(StrongOrRawPtr<mozilla::dom::XMLHttpRequestUpload>(self->GetUpload(rv)));
615 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
616 0 : return false;
617 : }
618 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
619 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
620 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
621 0 : return false;
622 : }
623 0 : return true;
624 : }
625 :
626 : static const JSJitInfo upload_getterinfo = {
627 : { (JSJitGetterOp)get_upload },
628 : { prototypes::id::XMLHttpRequest },
629 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
630 : JSJitInfo::Getter,
631 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
632 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
633 : false, /* isInfallible. False in setters. */
634 : false, /* isMovable. Not relevant for setters. */
635 : false, /* isEliminatable. Not relevant for setters. */
636 : false, /* isAlwaysInSlot. Only relevant for getters. */
637 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
638 : false, /* isTypedMethod. Only relevant for methods. */
639 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
640 : };
641 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
642 : static_assert(0 < 2, "There is no slot for us");
643 :
644 : static bool
645 2 : send(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
646 : {
647 2 : unsigned argcount = std::min(args.length(), 1u);
648 2 : switch (argcount) {
649 : case 0: {
650 4 : binding_detail::FastErrorResult rv;
651 2 : self->Send(cx, rv);
652 2 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
653 0 : return false;
654 : }
655 2 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
656 2 : args.rval().setUndefined();
657 2 : return true;
658 : break;
659 : }
660 : case 1: {
661 0 : if (args[0].isObject()) {
662 : do {
663 0 : RootedTypedArray<ArrayBuffer> arg0(cx);
664 0 : if (!arg0.Init(&args[0].toObject())) {
665 0 : break;
666 : }
667 0 : binding_detail::FastErrorResult rv;
668 0 : self->Send(cx, Constify(arg0), rv);
669 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
670 0 : return false;
671 : }
672 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
673 0 : args.rval().setUndefined();
674 0 : return true;
675 : } while (0);
676 : do {
677 0 : RootedTypedArray<ArrayBufferView> arg0(cx);
678 0 : if (!arg0.Init(&args[0].toObject())) {
679 0 : break;
680 : }
681 0 : binding_detail::FastErrorResult rv;
682 0 : self->Send(cx, Constify(arg0), rv);
683 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
684 0 : return false;
685 : }
686 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
687 0 : args.rval().setUndefined();
688 0 : return true;
689 : } while (0);
690 : do {
691 0 : NonNull<mozilla::dom::Blob> arg0;
692 : {
693 0 : nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
694 0 : if (NS_FAILED(rv)) {
695 0 : break;
696 : }
697 : }
698 0 : binding_detail::FastErrorResult rv;
699 0 : self->Send(cx, NonNullHelper(arg0), rv);
700 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
701 0 : return false;
702 : }
703 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
704 0 : args.rval().setUndefined();
705 0 : return true;
706 : } while (0);
707 : do {
708 0 : NonNull<nsIDocument> arg0;
709 : {
710 0 : nsresult rv = UnwrapObject<prototypes::id::Document, nsIDocument>(args[0], arg0);
711 0 : if (NS_FAILED(rv)) {
712 0 : break;
713 : }
714 : }
715 0 : binding_detail::FastErrorResult rv;
716 0 : self->Send(cx, NonNullHelper(arg0), rv);
717 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
718 0 : return false;
719 : }
720 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
721 0 : args.rval().setUndefined();
722 0 : return true;
723 : } while (0);
724 : do {
725 0 : NonNull<mozilla::dom::FormData> arg0;
726 : {
727 0 : nsresult rv = UnwrapObject<prototypes::id::FormData, mozilla::dom::FormData>(args[0], arg0);
728 0 : if (NS_FAILED(rv)) {
729 0 : break;
730 : }
731 : }
732 0 : binding_detail::FastErrorResult rv;
733 0 : self->Send(cx, NonNullHelper(arg0), rv);
734 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
735 0 : return false;
736 : }
737 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
738 0 : args.rval().setUndefined();
739 0 : return true;
740 : } while (0);
741 : do {
742 : nsIInputStream* arg0;
743 0 : RefPtr<nsIInputStream> arg0_holder;
744 0 : JS::Rooted<JSObject*> source(cx, &args[0].toObject());
745 0 : if (NS_FAILED(UnwrapArg<nsIInputStream>(cx, source, getter_AddRefs(arg0_holder)))) {
746 0 : break;
747 : }
748 0 : MOZ_ASSERT(arg0_holder);
749 0 : arg0 = arg0_holder;
750 0 : binding_detail::FastErrorResult rv;
751 0 : self->Send(cx, NonNullHelper(arg0), rv);
752 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
753 0 : return false;
754 : }
755 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
756 0 : args.rval().setUndefined();
757 0 : return true;
758 : } while (0);
759 : do {
760 0 : NonNull<mozilla::dom::URLSearchParams> arg0;
761 : {
762 0 : nsresult rv = UnwrapObject<prototypes::id::URLSearchParams, mozilla::dom::URLSearchParams>(args[0], arg0);
763 0 : if (NS_FAILED(rv)) {
764 0 : break;
765 : }
766 : }
767 0 : binding_detail::FastErrorResult rv;
768 0 : self->Send(cx, NonNullHelper(arg0), rv);
769 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
770 0 : return false;
771 : }
772 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
773 0 : args.rval().setUndefined();
774 0 : return true;
775 : } while (0);
776 : }
777 0 : binding_detail::FakeString arg0;
778 0 : if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) {
779 0 : return false;
780 : }
781 0 : NormalizeUSVString(arg0);
782 0 : binding_detail::FastErrorResult rv;
783 0 : self->Send(cx, Constify(arg0), rv);
784 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
785 0 : return false;
786 : }
787 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
788 0 : args.rval().setUndefined();
789 0 : return true;
790 : break;
791 : }
792 : default: {
793 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLHttpRequest.send");
794 : break;
795 : }
796 : }
797 : MOZ_CRASH("We have an always-returning default case");
798 : return false;
799 : }
800 :
801 : static const JSJitInfo send_methodinfo = {
802 : { (JSJitGetterOp)send },
803 : { prototypes::id::XMLHttpRequest },
804 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
805 : JSJitInfo::Method,
806 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
807 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
808 : false, /* isInfallible. False in setters. */
809 : false, /* isMovable. Not relevant for setters. */
810 : false, /* isEliminatable. Not relevant for setters. */
811 : false, /* isAlwaysInSlot. Only relevant for getters. */
812 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
813 : false, /* isTypedMethod. Only relevant for methods. */
814 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
815 : };
816 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
817 : static_assert(0 < 2, "There is no slot for us");
818 :
819 : static bool
820 0 : abort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
821 : {
822 0 : binding_detail::FastErrorResult rv;
823 0 : self->Abort(rv);
824 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
825 0 : return false;
826 : }
827 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
828 0 : args.rval().setUndefined();
829 0 : return true;
830 : }
831 :
832 : static const JSJitInfo abort_methodinfo = {
833 : { (JSJitGetterOp)abort },
834 : { prototypes::id::XMLHttpRequest },
835 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
836 : JSJitInfo::Method,
837 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
838 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
839 : false, /* isInfallible. False in setters. */
840 : false, /* isMovable. Not relevant for setters. */
841 : false, /* isEliminatable. Not relevant for setters. */
842 : false, /* isAlwaysInSlot. Only relevant for getters. */
843 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
844 : false, /* isTypedMethod. Only relevant for methods. */
845 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
846 : };
847 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
848 : static_assert(0 < 2, "There is no slot for us");
849 :
850 : static bool
851 0 : get_responseURL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
852 : {
853 0 : DOMString result;
854 0 : self->GetResponseURL(result);
855 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
856 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
857 0 : return false;
858 : }
859 0 : return true;
860 : }
861 :
862 : static const JSJitInfo responseURL_getterinfo = {
863 : { (JSJitGetterOp)get_responseURL },
864 : { prototypes::id::XMLHttpRequest },
865 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
866 : JSJitInfo::Getter,
867 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
868 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
869 : false, /* isInfallible. False in setters. */
870 : false, /* isMovable. Not relevant for setters. */
871 : false, /* isEliminatable. Not relevant for setters. */
872 : false, /* isAlwaysInSlot. Only relevant for getters. */
873 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
874 : false, /* isTypedMethod. Only relevant for methods. */
875 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
876 : };
877 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
878 : static_assert(0 < 2, "There is no slot for us");
879 :
880 : static bool
881 0 : get_status(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
882 : {
883 0 : binding_detail::FastErrorResult rv;
884 0 : uint16_t result(self->GetStatus(rv));
885 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
886 0 : return false;
887 : }
888 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
889 0 : args.rval().setInt32(int32_t(result));
890 0 : return true;
891 : }
892 :
893 : static const JSJitInfo status_getterinfo = {
894 : { (JSJitGetterOp)get_status },
895 : { prototypes::id::XMLHttpRequest },
896 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
897 : JSJitInfo::Getter,
898 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
899 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
900 : false, /* isInfallible. False in setters. */
901 : false, /* isMovable. Not relevant for setters. */
902 : false, /* isEliminatable. Not relevant for setters. */
903 : false, /* isAlwaysInSlot. Only relevant for getters. */
904 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
905 : false, /* isTypedMethod. Only relevant for methods. */
906 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
907 : };
908 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
909 : static_assert(0 < 2, "There is no slot for us");
910 :
911 : static bool
912 0 : get_statusText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
913 : {
914 0 : binding_detail::FastErrorResult rv;
915 0 : nsCString result;
916 0 : self->GetStatusText(result, rv);
917 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
918 0 : return false;
919 : }
920 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
921 0 : if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
922 0 : return false;
923 : }
924 0 : return true;
925 : }
926 :
927 : static const JSJitInfo statusText_getterinfo = {
928 : { (JSJitGetterOp)get_statusText },
929 : { prototypes::id::XMLHttpRequest },
930 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
931 : JSJitInfo::Getter,
932 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
933 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
934 : false, /* isInfallible. False in setters. */
935 : false, /* isMovable. Not relevant for setters. */
936 : false, /* isEliminatable. Not relevant for setters. */
937 : false, /* isAlwaysInSlot. Only relevant for getters. */
938 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
939 : false, /* isTypedMethod. Only relevant for methods. */
940 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
941 : };
942 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
943 : static_assert(0 < 2, "There is no slot for us");
944 :
945 : static bool
946 0 : getResponseHeader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
947 : {
948 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
949 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLHttpRequest.getResponseHeader");
950 : }
951 0 : nsCString arg0;
952 0 : if (!ConvertJSValueToByteString(cx, args[0], false, arg0)) {
953 0 : return false;
954 : }
955 0 : binding_detail::FastErrorResult rv;
956 0 : nsCString result;
957 0 : self->GetResponseHeader(Constify(arg0), result, rv);
958 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
959 0 : return false;
960 : }
961 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
962 0 : if (!ByteStringToJsval(cx, result, args.rval())) {
963 0 : return false;
964 : }
965 0 : return true;
966 : }
967 :
968 : static const JSJitInfo getResponseHeader_methodinfo = {
969 : { (JSJitGetterOp)getResponseHeader },
970 : { prototypes::id::XMLHttpRequest },
971 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
972 : JSJitInfo::Method,
973 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
974 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
975 : false, /* isInfallible. False in setters. */
976 : false, /* isMovable. Not relevant for setters. */
977 : false, /* isEliminatable. Not relevant for setters. */
978 : false, /* isAlwaysInSlot. Only relevant for getters. */
979 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
980 : false, /* isTypedMethod. Only relevant for methods. */
981 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
982 : };
983 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
984 : static_assert(0 < 2, "There is no slot for us");
985 :
986 : static bool
987 0 : getAllResponseHeaders(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
988 : {
989 0 : binding_detail::FastErrorResult rv;
990 0 : nsCString result;
991 0 : self->GetAllResponseHeaders(result, rv);
992 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
993 0 : return false;
994 : }
995 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
996 0 : if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
997 0 : return false;
998 : }
999 0 : return true;
1000 : }
1001 :
1002 : static const JSJitInfo getAllResponseHeaders_methodinfo = {
1003 : { (JSJitGetterOp)getAllResponseHeaders },
1004 : { prototypes::id::XMLHttpRequest },
1005 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1006 : JSJitInfo::Method,
1007 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1008 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1009 : false, /* isInfallible. False in setters. */
1010 : false, /* isMovable. Not relevant for setters. */
1011 : false, /* isEliminatable. Not relevant for setters. */
1012 : false, /* isAlwaysInSlot. Only relevant for getters. */
1013 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1014 : false, /* isTypedMethod. Only relevant for methods. */
1015 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1016 : };
1017 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1018 : static_assert(0 < 2, "There is no slot for us");
1019 :
1020 : static bool
1021 0 : overrideMimeType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
1022 : {
1023 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1024 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLHttpRequest.overrideMimeType");
1025 : }
1026 0 : binding_detail::FakeString arg0;
1027 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1028 0 : return false;
1029 : }
1030 0 : binding_detail::FastErrorResult rv;
1031 0 : self->OverrideMimeType(NonNullHelper(Constify(arg0)), rv);
1032 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1033 0 : return false;
1034 : }
1035 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1036 0 : args.rval().setUndefined();
1037 0 : return true;
1038 : }
1039 :
1040 : static const JSJitInfo overrideMimeType_methodinfo = {
1041 : { (JSJitGetterOp)overrideMimeType },
1042 : { prototypes::id::XMLHttpRequest },
1043 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1044 : JSJitInfo::Method,
1045 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1046 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1047 : false, /* isInfallible. False in setters. */
1048 : false, /* isMovable. Not relevant for setters. */
1049 : false, /* isEliminatable. Not relevant for setters. */
1050 : false, /* isAlwaysInSlot. Only relevant for getters. */
1051 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1052 : false, /* isTypedMethod. Only relevant for methods. */
1053 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1054 : };
1055 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1056 : static_assert(0 < 2, "There is no slot for us");
1057 :
1058 : static bool
1059 0 : get_responseType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1060 : {
1061 0 : XMLHttpRequestResponseType result(self->ResponseType());
1062 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1063 0 : if (!ToJSValue(cx, result, args.rval())) {
1064 0 : return false;
1065 : }
1066 0 : return true;
1067 : }
1068 :
1069 : static bool
1070 3 : set_responseType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitSetterCallArgs args)
1071 : {
1072 : XMLHttpRequestResponseType arg0;
1073 : {
1074 : int index;
1075 3 : if (!FindEnumStringIndex<false>(cx, args[0], XMLHttpRequestResponseTypeValues::strings, "XMLHttpRequestResponseType", "Value being assigned to XMLHttpRequest.responseType", &index)) {
1076 0 : return false;
1077 : }
1078 3 : if (index < 0) {
1079 0 : return true;
1080 : }
1081 3 : arg0 = static_cast<XMLHttpRequestResponseType>(index);
1082 : }
1083 5 : binding_detail::FastErrorResult rv;
1084 3 : self->SetResponseType(arg0, rv);
1085 2 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1086 0 : return false;
1087 : }
1088 2 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1089 :
1090 2 : return true;
1091 : }
1092 :
1093 : static const JSJitInfo responseType_getterinfo = {
1094 : { (JSJitGetterOp)get_responseType },
1095 : { prototypes::id::XMLHttpRequest },
1096 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1097 : JSJitInfo::Getter,
1098 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1099 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1100 : false, /* isInfallible. False in setters. */
1101 : false, /* isMovable. Not relevant for setters. */
1102 : false, /* isEliminatable. Not relevant for setters. */
1103 : false, /* isAlwaysInSlot. Only relevant for getters. */
1104 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1105 : false, /* isTypedMethod. Only relevant for methods. */
1106 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1107 : };
1108 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1109 : static_assert(0 < 2, "There is no slot for us");
1110 : static const JSJitInfo responseType_setterinfo = {
1111 : { (JSJitGetterOp)set_responseType },
1112 : { prototypes::id::XMLHttpRequest },
1113 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1114 : JSJitInfo::Setter,
1115 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1116 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1117 : false, /* isInfallible. False in setters. */
1118 : false, /* isMovable. Not relevant for setters. */
1119 : false, /* isEliminatable. Not relevant for setters. */
1120 : false, /* isAlwaysInSlot. Only relevant for getters. */
1121 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1122 : false, /* isTypedMethod. Only relevant for methods. */
1123 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1124 : };
1125 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1126 : static_assert(0 < 2, "There is no slot for us");
1127 :
1128 : static bool
1129 0 : get_response(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1130 : {
1131 0 : binding_detail::FastErrorResult rv;
1132 0 : JS::Rooted<JS::Value> result(cx);
1133 0 : self->GetResponse(cx, &result, rv);
1134 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1135 0 : return false;
1136 : }
1137 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1138 0 : JS::ExposeValueToActiveJS(result);
1139 0 : args.rval().set(result);
1140 0 : if (!MaybeWrapValue(cx, args.rval())) {
1141 0 : return false;
1142 : }
1143 0 : return true;
1144 : }
1145 :
1146 : static const JSJitInfo response_getterinfo = {
1147 : { (JSJitGetterOp)get_response },
1148 : { prototypes::id::XMLHttpRequest },
1149 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1150 : JSJitInfo::Getter,
1151 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1152 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1153 : false, /* isInfallible. False in setters. */
1154 : false, /* isMovable. Not relevant for setters. */
1155 : false, /* isEliminatable. Not relevant for setters. */
1156 : false, /* isAlwaysInSlot. Only relevant for getters. */
1157 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1158 : false, /* isTypedMethod. Only relevant for methods. */
1159 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1160 : };
1161 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1162 : static_assert(0 < 2, "There is no slot for us");
1163 :
1164 : static bool
1165 2 : get_responseText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1166 : {
1167 : // Have to either root across the getter call or reget after.
1168 : bool isXray;
1169 4 : JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
1170 2 : if (!slotStorage) {
1171 0 : return false;
1172 : }
1173 2 : const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
1174 2 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1175 : {
1176 : // Scope for cachedVal
1177 2 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1178 2 : if (!cachedVal.isUndefined()) {
1179 0 : args.rval().set(cachedVal);
1180 : // The cached value is in the compartment of slotStorage,
1181 : // so wrap into the caller compartment as needed.
1182 0 : return MaybeWrapValue(cx, args.rval());
1183 : }
1184 : }
1185 :
1186 4 : binding_detail::FastErrorResult rv;
1187 4 : DOMString result;
1188 2 : self->GetResponseText(result, rv);
1189 2 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1190 0 : return false;
1191 : }
1192 2 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1193 : {
1194 4 : JS::Rooted<JSObject*> conversionScope(cx, isXray ? obj : slotStorage);
1195 4 : JSAutoCompartment ac(cx, conversionScope);
1196 : do { // block we break out of when done wrapping
1197 2 : if (!xpc::StringToJsval(cx, result, args.rval())) {
1198 0 : return false;
1199 : }
1200 2 : break;
1201 : } while (0);
1202 : }
1203 : { // And now store things in the compartment of our slotStorage.
1204 4 : JSAutoCompartment ac(cx, slotStorage);
1205 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
1206 4 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
1207 2 : if (!MaybeWrapValue(cx, &storedVal)) {
1208 0 : return false;
1209 : }
1210 2 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1211 2 : if (!isXray) {
1212 : // In the Xray case we don't need to do this, because getting the
1213 : // expando object already preserved our wrapper.
1214 2 : PreserveWrapper(self);
1215 : }
1216 : }
1217 : // And now make sure args.rval() is in the caller compartment
1218 2 : return MaybeWrapValue(cx, args.rval());
1219 : }
1220 :
1221 : static const JSJitInfo responseText_getterinfo = {
1222 : { (JSJitGetterOp)get_responseText },
1223 : { prototypes::id::XMLHttpRequest },
1224 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1225 : JSJitInfo::Getter,
1226 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
1227 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1228 : false, /* isInfallible. False in setters. */
1229 : false, /* isMovable. Not relevant for setters. */
1230 : false, /* isEliminatable. Not relevant for setters. */
1231 : false, /* isAlwaysInSlot. Only relevant for getters. */
1232 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
1233 : false, /* isTypedMethod. Only relevant for methods. */
1234 : (DOM_INSTANCE_RESERVED_SLOTS + 0) /* Reserved slot index, if we're stored in a slot, else 0. */
1235 : };
1236 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
1237 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
1238 :
1239 : static bool
1240 0 : get_responseXML(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1241 : {
1242 0 : binding_detail::FastErrorResult rv;
1243 0 : auto result(StrongOrRawPtr<nsIDocument>(self->GetResponseXML(rv)));
1244 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1245 0 : return false;
1246 : }
1247 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1248 0 : if (!result) {
1249 0 : args.rval().setNull();
1250 0 : return true;
1251 : }
1252 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1253 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1254 0 : return false;
1255 : }
1256 0 : return true;
1257 : }
1258 :
1259 : static const JSJitInfo responseXML_getterinfo = {
1260 : { (JSJitGetterOp)get_responseXML },
1261 : { prototypes::id::XMLHttpRequest },
1262 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1263 : JSJitInfo::Getter,
1264 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1265 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1266 : false, /* isInfallible. False in setters. */
1267 : false, /* isMovable. Not relevant for setters. */
1268 : false, /* isEliminatable. Not relevant for setters. */
1269 : false, /* isAlwaysInSlot. Only relevant for getters. */
1270 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1271 : false, /* isTypedMethod. Only relevant for methods. */
1272 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1273 : };
1274 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1275 : static_assert(0 < 2, "There is no slot for us");
1276 :
1277 : static bool
1278 0 : get_mozBackgroundRequest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1279 : {
1280 0 : bool result(self->MozBackgroundRequest());
1281 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1282 0 : args.rval().setBoolean(result);
1283 0 : return true;
1284 : }
1285 :
1286 : static bool
1287 0 : set_mozBackgroundRequest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitSetterCallArgs args)
1288 : {
1289 : bool arg0;
1290 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
1291 0 : return false;
1292 : }
1293 0 : binding_detail::FastErrorResult rv;
1294 0 : self->SetMozBackgroundRequest(arg0, rv);
1295 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1296 0 : return false;
1297 : }
1298 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1299 :
1300 0 : return true;
1301 : }
1302 :
1303 : static const JSJitInfo mozBackgroundRequest_getterinfo = {
1304 : { (JSJitGetterOp)get_mozBackgroundRequest },
1305 : { prototypes::id::XMLHttpRequest },
1306 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1307 : JSJitInfo::Getter,
1308 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1309 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1310 : true, /* isInfallible. False in setters. */
1311 : false, /* isMovable. Not relevant for setters. */
1312 : false, /* isEliminatable. Not relevant for setters. */
1313 : false, /* isAlwaysInSlot. Only relevant for getters. */
1314 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1315 : false, /* isTypedMethod. Only relevant for methods. */
1316 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1317 : };
1318 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1319 : static_assert(0 < 2, "There is no slot for us");
1320 : static const JSJitInfo mozBackgroundRequest_setterinfo = {
1321 : { (JSJitGetterOp)set_mozBackgroundRequest },
1322 : { prototypes::id::XMLHttpRequest },
1323 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1324 : JSJitInfo::Setter,
1325 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1326 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1327 : false, /* isInfallible. False in setters. */
1328 : false, /* isMovable. Not relevant for setters. */
1329 : false, /* isEliminatable. Not relevant for setters. */
1330 : false, /* isAlwaysInSlot. Only relevant for getters. */
1331 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1332 : false, /* isTypedMethod. Only relevant for methods. */
1333 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1334 : };
1335 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1336 : static_assert(0 < 2, "There is no slot for us");
1337 :
1338 : static bool
1339 0 : get_channel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1340 : {
1341 0 : auto result(StrongOrRawPtr<nsIChannel>(self->GetChannel()));
1342 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1343 0 : if (!result) {
1344 0 : args.rval().setNull();
1345 0 : return true;
1346 : }
1347 0 : if (!WrapObject(cx, result, &NS_GET_IID(nsIChannel), args.rval())) {
1348 0 : return false;
1349 : }
1350 0 : return true;
1351 : }
1352 :
1353 : static const JSJitInfo channel_getterinfo = {
1354 : { (JSJitGetterOp)get_channel },
1355 : { prototypes::id::XMLHttpRequest },
1356 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1357 : JSJitInfo::Getter,
1358 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1359 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1360 : false, /* isInfallible. False in setters. */
1361 : false, /* isMovable. Not relevant for setters. */
1362 : false, /* isEliminatable. Not relevant for setters. */
1363 : false, /* isAlwaysInSlot. Only relevant for getters. */
1364 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1365 : false, /* isTypedMethod. Only relevant for methods. */
1366 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1367 : };
1368 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1369 : static_assert(0 < 2, "There is no slot for us");
1370 :
1371 : static bool
1372 0 : get_networkInterfaceId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1373 : {
1374 0 : nsCString result;
1375 0 : self->GetNetworkInterfaceId(result);
1376 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1377 0 : if (!ByteStringToJsval(cx, result, args.rval())) {
1378 0 : return false;
1379 : }
1380 0 : return true;
1381 : }
1382 :
1383 : static bool
1384 0 : set_networkInterfaceId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitSetterCallArgs args)
1385 : {
1386 0 : nsCString arg0;
1387 0 : if (!ConvertJSValueToByteString(cx, args[0], true, arg0)) {
1388 0 : return false;
1389 : }
1390 0 : self->SetNetworkInterfaceId(Constify(arg0));
1391 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1392 :
1393 0 : return true;
1394 : }
1395 :
1396 : static const JSJitInfo networkInterfaceId_getterinfo = {
1397 : { (JSJitGetterOp)get_networkInterfaceId },
1398 : { prototypes::id::XMLHttpRequest },
1399 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1400 : JSJitInfo::Getter,
1401 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1402 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1403 : false, /* isInfallible. False in setters. */
1404 : false, /* isMovable. Not relevant for setters. */
1405 : false, /* isEliminatable. Not relevant for setters. */
1406 : false, /* isAlwaysInSlot. Only relevant for getters. */
1407 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1408 : false, /* isTypedMethod. Only relevant for methods. */
1409 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1410 : };
1411 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1412 : static_assert(0 < 2, "There is no slot for us");
1413 : static const JSJitInfo networkInterfaceId_setterinfo = {
1414 : { (JSJitGetterOp)set_networkInterfaceId },
1415 : { prototypes::id::XMLHttpRequest },
1416 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1417 : JSJitInfo::Setter,
1418 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1419 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1420 : false, /* isInfallible. False in setters. */
1421 : false, /* isMovable. Not relevant for setters. */
1422 : false, /* isEliminatable. Not relevant for setters. */
1423 : false, /* isAlwaysInSlot. Only relevant for getters. */
1424 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1425 : false, /* isTypedMethod. Only relevant for methods. */
1426 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1427 : };
1428 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1429 : static_assert(0 < 2, "There is no slot for us");
1430 :
1431 : static bool
1432 0 : getInterface(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
1433 : {
1434 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1435 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLHttpRequest.getInterface");
1436 : }
1437 : nsIJSID* arg0;
1438 0 : RefPtr<nsIJSID> arg0_holder;
1439 0 : if (args[0].isObject()) {
1440 0 : JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1441 0 : if (NS_FAILED(UnwrapArg<nsIJSID>(cx, source, getter_AddRefs(arg0_holder)))) {
1442 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XMLHttpRequest.getInterface", "IID");
1443 0 : return false;
1444 : }
1445 0 : MOZ_ASSERT(arg0_holder);
1446 0 : arg0 = arg0_holder;
1447 : } else {
1448 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XMLHttpRequest.getInterface");
1449 0 : return false;
1450 : }
1451 0 : binding_detail::FastErrorResult rv;
1452 0 : JS::Rooted<JS::Value> result(cx);
1453 0 : self->GetInterface(cx, NonNullHelper(arg0), &result, rv);
1454 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1455 0 : return false;
1456 : }
1457 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1458 0 : JS::ExposeValueToActiveJS(result);
1459 0 : args.rval().set(result);
1460 0 : if (!MaybeWrapValue(cx, args.rval())) {
1461 0 : return false;
1462 : }
1463 0 : return true;
1464 : }
1465 :
1466 : static const JSJitInfo getInterface_methodinfo = {
1467 : { (JSJitGetterOp)getInterface },
1468 : { prototypes::id::XMLHttpRequest },
1469 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1470 : JSJitInfo::Method,
1471 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1472 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1473 : false, /* isInfallible. False in setters. */
1474 : false, /* isMovable. Not relevant for setters. */
1475 : false, /* isEliminatable. Not relevant for setters. */
1476 : false, /* isAlwaysInSlot. Only relevant for getters. */
1477 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1478 : false, /* isTypedMethod. Only relevant for methods. */
1479 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1480 : };
1481 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1482 : static_assert(0 < 2, "There is no slot for us");
1483 :
1484 : static bool
1485 0 : setOriginAttributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, const JSJitMethodCallArgs& args)
1486 : {
1487 0 : binding_detail::FastOriginAttributesDictionary arg0;
1488 0 : if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of XMLHttpRequest.setOriginAttributes", false)) {
1489 0 : return false;
1490 : }
1491 0 : self->SetOriginAttributes(Constify(arg0));
1492 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1493 0 : args.rval().setUndefined();
1494 0 : return true;
1495 : }
1496 :
1497 : static const JSJitInfo setOriginAttributes_methodinfo = {
1498 : { (JSJitGetterOp)setOriginAttributes },
1499 : { prototypes::id::XMLHttpRequest },
1500 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1501 : JSJitInfo::Method,
1502 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1503 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1504 : false, /* isInfallible. False in setters. */
1505 : false, /* isMovable. Not relevant for setters. */
1506 : false, /* isEliminatable. Not relevant for setters. */
1507 : false, /* isAlwaysInSlot. Only relevant for getters. */
1508 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1509 : false, /* isTypedMethod. Only relevant for methods. */
1510 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1511 : };
1512 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1513 : static_assert(0 < 2, "There is no slot for us");
1514 :
1515 : static bool
1516 0 : get_errorCode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1517 : {
1518 0 : uint16_t result(self->ErrorCode());
1519 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1520 0 : args.rval().setInt32(int32_t(result));
1521 0 : return true;
1522 : }
1523 :
1524 : static const JSJitInfo errorCode_getterinfo = {
1525 : { (JSJitGetterOp)get_errorCode },
1526 : { prototypes::id::XMLHttpRequest },
1527 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1528 : JSJitInfo::Getter,
1529 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1530 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
1531 : true, /* isInfallible. False in setters. */
1532 : false, /* isMovable. Not relevant for setters. */
1533 : false, /* isEliminatable. Not relevant for setters. */
1534 : false, /* isAlwaysInSlot. Only relevant for getters. */
1535 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1536 : false, /* isTypedMethod. Only relevant for methods. */
1537 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1538 : };
1539 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1540 : static_assert(0 < 2, "There is no slot for us");
1541 :
1542 : static bool
1543 0 : get_mozAnon(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1544 : {
1545 0 : bool result(self->MozAnon());
1546 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1547 0 : args.rval().setBoolean(result);
1548 0 : return true;
1549 : }
1550 :
1551 : static const JSJitInfo mozAnon_getterinfo = {
1552 : { (JSJitGetterOp)get_mozAnon },
1553 : { prototypes::id::XMLHttpRequest },
1554 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1555 : JSJitInfo::Getter,
1556 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1557 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1558 : true, /* isInfallible. False in setters. */
1559 : false, /* isMovable. Not relevant for setters. */
1560 : false, /* isEliminatable. Not relevant for setters. */
1561 : false, /* isAlwaysInSlot. Only relevant for getters. */
1562 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1563 : false, /* isTypedMethod. Only relevant for methods. */
1564 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1565 : };
1566 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1567 : static_assert(0 < 2, "There is no slot for us");
1568 :
1569 : static bool
1570 0 : get_mozSystem(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLHttpRequest* self, JSJitGetterCallArgs args)
1571 : {
1572 0 : bool result(self->MozSystem());
1573 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1574 0 : args.rval().setBoolean(result);
1575 0 : return true;
1576 : }
1577 :
1578 : static const JSJitInfo mozSystem_getterinfo = {
1579 : { (JSJitGetterOp)get_mozSystem },
1580 : { prototypes::id::XMLHttpRequest },
1581 : { PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth },
1582 : JSJitInfo::Getter,
1583 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1584 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1585 : true, /* isInfallible. False in setters. */
1586 : false, /* isMovable. Not relevant for setters. */
1587 : false, /* isEliminatable. Not relevant for setters. */
1588 : false, /* isAlwaysInSlot. Only relevant for getters. */
1589 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1590 : false, /* isTypedMethod. Only relevant for methods. */
1591 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1592 : };
1593 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1594 : static_assert(0 < 2, "There is no slot for us");
1595 :
1596 : static bool
1597 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1598 : {
1599 0 : mozilla::dom::XMLHttpRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XMLHttpRequest>(obj);
1600 : // We don't want to preserve if we don't have a wrapper, and we
1601 : // obviously can't preserve if we're not initialized.
1602 0 : if (self && self->GetWrapperPreserveColor()) {
1603 0 : PreserveWrapper(self);
1604 : }
1605 0 : return true;
1606 : }
1607 :
1608 : static void
1609 0 : _finalize(js::FreeOp* fop, JSObject* obj)
1610 : {
1611 0 : mozilla::dom::XMLHttpRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XMLHttpRequest>(obj);
1612 0 : if (self) {
1613 0 : ClearWrapper(self, self, obj);
1614 0 : AddForDeferredFinalization<mozilla::dom::XMLHttpRequest>(self);
1615 : }
1616 0 : }
1617 :
1618 : static void
1619 0 : _objectMoved(JSObject* obj, const JSObject* old)
1620 : {
1621 0 : mozilla::dom::XMLHttpRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XMLHttpRequest>(obj);
1622 0 : if (self) {
1623 0 : UpdateWrapper(self, self, obj, old);
1624 : }
1625 0 : }
1626 :
1627 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1628 : #if defined(__clang__)
1629 : #pragma clang diagnostic push
1630 : #pragma clang diagnostic ignored "-Wmissing-braces"
1631 : #endif
1632 : static const JSFunctionSpec sMethods_specs[] = {
1633 : JS_FNSPEC("open", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&open_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1634 : JS_FNSPEC("setRequestHeader", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setRequestHeader_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1635 : JS_FNSPEC("send", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&send_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1636 : JS_FNSPEC("abort", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&abort_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1637 : JS_FNSPEC("getResponseHeader", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getResponseHeader_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1638 : JS_FNSPEC("getAllResponseHeaders", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAllResponseHeaders_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1639 : JS_FNSPEC("overrideMimeType", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&overrideMimeType_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1640 : JS_FS_END,
1641 : JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
1642 : JS_FS_END
1643 : };
1644 : #if defined(__clang__)
1645 : #pragma clang diagnostic pop
1646 : #endif
1647 :
1648 : static PrefableDisablers sMethods_disablers8 = {
1649 : true, false, 0, &WantsQueryInterface<mozilla::dom::XMLHttpRequest>::Enabled
1650 : };
1651 :
1652 : // Can't be const because the pref-enabled boolean needs to be writable
1653 : static Prefable<const JSFunctionSpec> sMethods[] = {
1654 : { nullptr, &sMethods_specs[0] },
1655 : { &sMethods_disablers8, &sMethods_specs[8] },
1656 : { nullptr, nullptr }
1657 : };
1658 :
1659 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1660 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1661 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1662 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1663 :
1664 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1665 : #if defined(__clang__)
1666 : #pragma clang diagnostic push
1667 : #pragma clang diagnostic ignored "-Wmissing-braces"
1668 : #endif
1669 : static const JSFunctionSpec sChromeMethods_specs[] = {
1670 : JS_FNSPEC("getInterface", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getInterface_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1671 : JS_FNSPEC("setOriginAttributes", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setOriginAttributes_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1672 : JS_FS_END
1673 : };
1674 : #if defined(__clang__)
1675 : #pragma clang diagnostic pop
1676 : #endif
1677 :
1678 : static PrefableDisablers sChromeMethods_disablers0 = {
1679 : true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
1680 : };
1681 :
1682 : // Can't be const because the pref-enabled boolean needs to be writable
1683 : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
1684 : { &sChromeMethods_disablers0, &sChromeMethods_specs[0] },
1685 : { nullptr, nullptr }
1686 : };
1687 :
1688 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1689 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1690 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1691 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1692 :
1693 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1694 : #if defined(__clang__)
1695 : #pragma clang diagnostic push
1696 : #pragma clang diagnostic ignored "-Wmissing-braces"
1697 : #endif
1698 : static const JSPropertySpec sAttributes_specs[] = {
1699 : { "onreadystatechange", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onreadystatechange_getterinfo, GenericBindingSetter, &onreadystatechange_setterinfo },
1700 : { "readyState", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &readyState_getterinfo, nullptr, nullptr },
1701 : { "timeout", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &timeout_getterinfo, GenericBindingSetter, &timeout_setterinfo },
1702 : { "withCredentials", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &withCredentials_getterinfo, GenericBindingSetter, &withCredentials_setterinfo },
1703 : { "upload", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &upload_getterinfo, nullptr, nullptr },
1704 : { "responseURL", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &responseURL_getterinfo, nullptr, nullptr },
1705 : { "status", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &status_getterinfo, nullptr, nullptr },
1706 : { "statusText", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &statusText_getterinfo, nullptr, nullptr },
1707 : { "responseType", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &responseType_getterinfo, GenericBindingSetter, &responseType_setterinfo },
1708 : { "response", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &response_getterinfo, nullptr, nullptr },
1709 : { "responseText", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &responseText_getterinfo, nullptr, nullptr },
1710 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1711 : { "responseXML", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &responseXML_getterinfo, nullptr, nullptr },
1712 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1713 : { "mozAnon", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozAnon_getterinfo, nullptr, nullptr },
1714 : { "mozSystem", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozSystem_getterinfo, nullptr, nullptr },
1715 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1716 : };
1717 : #if defined(__clang__)
1718 : #pragma clang diagnostic pop
1719 : #endif
1720 :
1721 : static PrefableDisablers sAttributes_disablers12 = {
1722 : true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
1723 : };
1724 :
1725 : // Can't be const because the pref-enabled boolean needs to be writable
1726 : static Prefable<const JSPropertySpec> sAttributes[] = {
1727 : { nullptr, &sAttributes_specs[0] },
1728 : { &sAttributes_disablers12, &sAttributes_specs[12] },
1729 : { nullptr, &sAttributes_specs[14] },
1730 : { nullptr, nullptr }
1731 : };
1732 :
1733 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1734 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1735 : static_assert(11 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1736 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1737 :
1738 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1739 : #if defined(__clang__)
1740 : #pragma clang diagnostic push
1741 : #pragma clang diagnostic ignored "-Wmissing-braces"
1742 : #endif
1743 : static const JSPropertySpec sChromeAttributes_specs[] = {
1744 : { "mozBackgroundRequest", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozBackgroundRequest_getterinfo, GenericBindingSetter, &mozBackgroundRequest_setterinfo },
1745 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1746 : { "channel", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &channel_getterinfo, nullptr, nullptr },
1747 : { "networkInterfaceId", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &networkInterfaceId_getterinfo, GenericBindingSetter, &networkInterfaceId_setterinfo },
1748 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1749 : { "errorCode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &errorCode_getterinfo, nullptr, nullptr },
1750 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1751 : };
1752 : #if defined(__clang__)
1753 : #pragma clang diagnostic pop
1754 : #endif
1755 :
1756 : static PrefableDisablers sChromeAttributes_disablers2 = {
1757 : true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
1758 : };
1759 :
1760 : // Can't be const because the pref-enabled boolean needs to be writable
1761 : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
1762 : { nullptr, &sChromeAttributes_specs[0] },
1763 : { &sChromeAttributes_disablers2, &sChromeAttributes_specs[2] },
1764 : { nullptr, &sChromeAttributes_specs[5] },
1765 : { nullptr, nullptr }
1766 : };
1767 :
1768 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1769 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1770 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1771 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1772 :
1773 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1774 : #if defined(__clang__)
1775 : #pragma clang diagnostic push
1776 : #pragma clang diagnostic ignored "-Wmissing-braces"
1777 : #endif
1778 : static const ConstantSpec sConstants_specs[] = {
1779 : { "UNSENT", JS::Int32Value(0) },
1780 : { "OPENED", JS::Int32Value(1) },
1781 : { "HEADERS_RECEIVED", JS::Int32Value(2) },
1782 : { "LOADING", JS::Int32Value(3) },
1783 : { "DONE", JS::Int32Value(4) },
1784 : { 0, JS::UndefinedValue() }
1785 : };
1786 : #if defined(__clang__)
1787 : #pragma clang diagnostic pop
1788 : #endif
1789 :
1790 :
1791 : // Can't be const because the pref-enabled boolean needs to be writable
1792 : static Prefable<const ConstantSpec> sConstants[] = {
1793 : { nullptr, &sConstants_specs[0] },
1794 : { nullptr, nullptr }
1795 : };
1796 :
1797 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1798 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1799 : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1800 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1801 :
1802 :
1803 : static uint16_t sNativeProperties_sortedPropertyIndices[27];
1804 : static PropertyInfo sNativeProperties_propertyInfos[27];
1805 :
1806 : static const NativePropertiesN<3> sNativeProperties = {
1807 : false, 0,
1808 : false, 0,
1809 : true, 0 /* sMethods */,
1810 : true, 1 /* sAttributes */,
1811 : false, 0,
1812 : false, 0,
1813 : true, 2 /* sConstants */,
1814 : -1,
1815 : 27,
1816 : sNativeProperties_sortedPropertyIndices,
1817 : {
1818 : { sMethods, &sNativeProperties_propertyInfos[0] },
1819 : { sAttributes, &sNativeProperties_propertyInfos[8] },
1820 : { sConstants, &sNativeProperties_propertyInfos[22] }
1821 : }
1822 : };
1823 : static_assert(27 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1824 : "We have a property info count that is oversized");
1825 :
1826 : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[6];
1827 : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[6];
1828 :
1829 : static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
1830 : false, 0,
1831 : false, 0,
1832 : true, 0 /* sChromeMethods */,
1833 : true, 1 /* sChromeAttributes */,
1834 : false, 0,
1835 : false, 0,
1836 : false, 0,
1837 : -1,
1838 : 6,
1839 : sChromeOnlyNativeProperties_sortedPropertyIndices,
1840 : {
1841 : { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
1842 : { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[2] }
1843 : }
1844 : };
1845 : static_assert(6 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1846 : "We have a property info count that is oversized");
1847 :
1848 : static bool
1849 3 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1850 : {
1851 3 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1852 6 : JS::Rooted<JSObject*> obj(cx, &args.callee());
1853 3 : if (!args.isConstructing()) {
1854 : // XXXbz wish I could get the name from the callee instead of
1855 : // Adding more relocations
1856 0 : return ThrowConstructorWithoutNew(cx, "XMLHttpRequest");
1857 : }
1858 :
1859 6 : GlobalObject global(cx, obj);
1860 3 : if (global.Failed()) {
1861 0 : return false;
1862 : }
1863 :
1864 6 : JS::Rooted<JSObject*> desiredProto(cx);
1865 3 : if (!GetDesiredProto(cx, args, &desiredProto)) {
1866 0 : return false;
1867 : }
1868 :
1869 3 : unsigned argcount = std::min(args.length(), 1u);
1870 3 : switch (argcount) {
1871 : case 0: {
1872 3 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1873 3 : binding_detail::FastMozXMLHttpRequestParameters arg0;
1874 3 : if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of XMLHttpRequest.constructor", false)) {
1875 0 : return false;
1876 : }
1877 6 : Maybe<JSAutoCompartment> ac;
1878 3 : if (objIsXray) {
1879 0 : obj = js::CheckedUnwrap(obj);
1880 0 : if (!obj) {
1881 0 : return false;
1882 : }
1883 0 : ac.emplace(cx, obj);
1884 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1885 0 : return false;
1886 : }
1887 : }
1888 6 : binding_detail::FastErrorResult rv;
1889 6 : auto result(StrongOrRawPtr<mozilla::dom::XMLHttpRequest>(mozilla::dom::XMLHttpRequest::Constructor(global, Constify(arg0), rv)));
1890 3 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1891 0 : return false;
1892 : }
1893 3 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1894 : static_assert(!IsPointer<decltype(result)>::value,
1895 : "NewObject implies that we need to keep the object alive with a strong reference.");
1896 3 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1897 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1898 0 : return false;
1899 : }
1900 3 : return true;
1901 : break;
1902 : }
1903 : case 1: {
1904 0 : if (args[0].isNullOrUndefined()) {
1905 0 : binding_detail::FastMozXMLHttpRequestParameters arg0;
1906 0 : if (!arg0.Init(cx, args[0], "Argument 1 of XMLHttpRequest", false)) {
1907 0 : return false;
1908 : }
1909 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1910 0 : Maybe<JSAutoCompartment> ac;
1911 0 : if (objIsXray) {
1912 0 : obj = js::CheckedUnwrap(obj);
1913 0 : if (!obj) {
1914 0 : return false;
1915 : }
1916 0 : ac.emplace(cx, obj);
1917 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1918 0 : return false;
1919 : }
1920 : }
1921 0 : binding_detail::FastErrorResult rv;
1922 0 : auto result(StrongOrRawPtr<mozilla::dom::XMLHttpRequest>(mozilla::dom::XMLHttpRequest::Constructor(global, Constify(arg0), rv)));
1923 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1924 0 : return false;
1925 : }
1926 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1927 : static_assert(!IsPointer<decltype(result)>::value,
1928 : "NewObject implies that we need to keep the object alive with a strong reference.");
1929 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1930 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1931 0 : return false;
1932 : }
1933 0 : return true;
1934 : }
1935 0 : if (args[0].isObject()) {
1936 : do {
1937 0 : binding_detail::FastMozXMLHttpRequestParameters arg0;
1938 0 : if (!arg0.Init(cx, args[0], "Argument 1 of XMLHttpRequest", false)) {
1939 0 : return false;
1940 : }
1941 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1942 0 : Maybe<JSAutoCompartment> ac;
1943 0 : if (objIsXray) {
1944 0 : obj = js::CheckedUnwrap(obj);
1945 0 : if (!obj) {
1946 0 : return false;
1947 : }
1948 0 : ac.emplace(cx, obj);
1949 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1950 0 : return false;
1951 : }
1952 : }
1953 0 : binding_detail::FastErrorResult rv;
1954 0 : auto result(StrongOrRawPtr<mozilla::dom::XMLHttpRequest>(mozilla::dom::XMLHttpRequest::Constructor(global, Constify(arg0), rv)));
1955 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1956 0 : return false;
1957 : }
1958 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1959 : static_assert(!IsPointer<decltype(result)>::value,
1960 : "NewObject implies that we need to keep the object alive with a strong reference.");
1961 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1962 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1963 0 : return false;
1964 : }
1965 0 : return true;
1966 : } while (0);
1967 : }
1968 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1969 0 : binding_detail::FakeString arg0;
1970 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1971 0 : return false;
1972 : }
1973 0 : Maybe<JSAutoCompartment> ac;
1974 0 : if (objIsXray) {
1975 0 : obj = js::CheckedUnwrap(obj);
1976 0 : if (!obj) {
1977 0 : return false;
1978 : }
1979 0 : ac.emplace(cx, obj);
1980 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1981 0 : return false;
1982 : }
1983 : }
1984 0 : binding_detail::FastErrorResult rv;
1985 0 : auto result(StrongOrRawPtr<mozilla::dom::XMLHttpRequest>(mozilla::dom::XMLHttpRequest::Constructor(global, NonNullHelper(Constify(arg0)), rv)));
1986 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1987 0 : return false;
1988 : }
1989 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1990 : static_assert(!IsPointer<decltype(result)>::value,
1991 : "NewObject implies that we need to keep the object alive with a strong reference.");
1992 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1993 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1994 0 : return false;
1995 : }
1996 0 : return true;
1997 : break;
1998 : }
1999 : default: {
2000 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLHttpRequest");
2001 : break;
2002 : }
2003 : }
2004 : MOZ_CRASH("We have an always-returning default case");
2005 : return false;
2006 : }
2007 :
2008 : static const js::ClassOps sInterfaceObjectClassOps = {
2009 : nullptr, /* addProperty */
2010 : nullptr, /* delProperty */
2011 : nullptr, /* getProperty */
2012 : nullptr, /* setProperty */
2013 : nullptr, /* enumerate */
2014 : nullptr, /* newEnumerate */
2015 : nullptr, /* resolve */
2016 : nullptr, /* mayResolve */
2017 : nullptr, /* finalize */
2018 : _constructor, /* call */
2019 : nullptr, /* hasInstance */
2020 : _constructor, /* construct */
2021 : nullptr, /* trace */
2022 : };
2023 :
2024 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2025 : {
2026 : "Function",
2027 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
2028 : &sInterfaceObjectClassOps,
2029 : JS_NULL_CLASS_SPEC,
2030 : JS_NULL_CLASS_EXT,
2031 : &sInterfaceObjectClassObjectOps
2032 : },
2033 : eInterface,
2034 : true,
2035 : prototypes::id::XMLHttpRequest,
2036 : PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth,
2037 : sNativePropertyHooks,
2038 : "function XMLHttpRequest() {\n [native code]\n}",
2039 : XMLHttpRequestEventTargetBinding::GetConstructorObject
2040 : };
2041 :
2042 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
2043 : {
2044 : "XMLHttpRequestPrototype",
2045 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
2046 : JS_NULL_CLASS_OPS,
2047 : JS_NULL_CLASS_SPEC,
2048 : JS_NULL_CLASS_EXT,
2049 : JS_NULL_OBJECT_OPS
2050 : },
2051 : eInterfacePrototype,
2052 : false,
2053 : prototypes::id::XMLHttpRequest,
2054 : PrototypeTraits<prototypes::id::XMLHttpRequest>::Depth,
2055 : sNativePropertyHooks,
2056 : "[object XMLHttpRequestPrototype]",
2057 : XMLHttpRequestEventTargetBinding::GetProtoObject
2058 : };
2059 :
2060 : bool
2061 1 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
2062 : {
2063 1 : if (!NS_IsMainThread()) {
2064 1 : const char* name = js::GetObjectClass(aObj)->name;
2065 1 : if (strcmp(name, "DedicatedWorkerGlobalScope") && strcmp(name, "SharedWorkerGlobalScope")) {
2066 0 : return false;
2067 : }
2068 : }
2069 :
2070 1 : return true;
2071 : }
2072 :
2073 : JSObject*
2074 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
2075 : {
2076 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
2077 : }
2078 :
2079 : static const js::ClassOps sClassOps = {
2080 : _addProperty, /* addProperty */
2081 : nullptr, /* delProperty */
2082 : nullptr, /* getProperty */
2083 : nullptr, /* setProperty */
2084 : nullptr, /* enumerate */
2085 : nullptr, /* newEnumerate */
2086 : nullptr, /* resolve */
2087 : nullptr, /* mayResolve */
2088 : _finalize, /* finalize */
2089 : nullptr, /* call */
2090 : nullptr, /* hasInstance */
2091 : nullptr, /* construct */
2092 : nullptr, /* trace */
2093 : };
2094 :
2095 : static const js::ClassExtension sClassExtension = {
2096 : nullptr, /* weakmapKeyDelegateOp */
2097 : _objectMoved /* objectMovedOp */
2098 : };
2099 :
2100 : static const DOMJSClass sClass = {
2101 : { "XMLHttpRequest",
2102 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
2103 : &sClassOps,
2104 : JS_NULL_CLASS_SPEC,
2105 : &sClassExtension,
2106 : JS_NULL_OBJECT_OPS
2107 : },
2108 : { prototypes::id::EventTarget, prototypes::id::XMLHttpRequestEventTarget, prototypes::id::XMLHttpRequest, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
2109 : IsBaseOf<nsISupports, mozilla::dom::XMLHttpRequest >::value,
2110 : sNativePropertyHooks,
2111 : FindAssociatedGlobalForNative<mozilla::dom::XMLHttpRequest>::Get,
2112 : GetProtoObjectHandle,
2113 : GetCCParticipant<mozilla::dom::XMLHttpRequest>::Get()
2114 : };
2115 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
2116 : "Must have the right minimal number of reserved slots.");
2117 : static_assert(2 >= 2,
2118 : "Must have enough reserved slots.");
2119 :
2120 : const JSClass*
2121 0 : GetJSClass()
2122 : {
2123 0 : return sClass.ToJSClass();
2124 : }
2125 :
2126 : bool
2127 6 : Wrap(JSContext* aCx, mozilla::dom::XMLHttpRequest* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2128 : {
2129 : MOZ_ASSERT(static_cast<mozilla::dom::XMLHttpRequest*>(aObject) ==
2130 : reinterpret_cast<mozilla::dom::XMLHttpRequest*>(aObject),
2131 : "Multiple inheritance for mozilla::dom::XMLHttpRequest is broken.");
2132 : MOZ_ASSERT(static_cast<mozilla::dom::XMLHttpRequestEventTarget*>(aObject) ==
2133 : reinterpret_cast<mozilla::dom::XMLHttpRequestEventTarget*>(aObject),
2134 : "Multiple inheritance for mozilla::dom::XMLHttpRequestEventTarget is broken.");
2135 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
2136 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
2137 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
2138 6 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2139 6 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2140 6 : MOZ_ASSERT(!aCache->GetWrapper(),
2141 : "You should probably not be using Wrap() directly; use "
2142 : "GetOrCreateDOMReflector instead");
2143 :
2144 6 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2145 : "nsISupports must be on our primary inheritance chain");
2146 :
2147 12 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2148 6 : if (!global) {
2149 0 : return false;
2150 : }
2151 6 : MOZ_ASSERT(JS_IsGlobalObject(global));
2152 6 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
2153 :
2154 : // That might have ended up wrapping us already, due to the wonders
2155 : // of XBL. Check for that, and bail out as needed.
2156 6 : aReflector.set(aCache->GetWrapper());
2157 6 : if (aReflector) {
2158 : #ifdef DEBUG
2159 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2160 : #endif // DEBUG
2161 0 : return true;
2162 : }
2163 :
2164 12 : JSAutoCompartment ac(aCx, global);
2165 6 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2166 6 : if (!canonicalProto) {
2167 0 : return false;
2168 : }
2169 12 : JS::Rooted<JSObject*> proto(aCx);
2170 6 : if (aGivenProto) {
2171 3 : proto = aGivenProto;
2172 : // Unfortunately, while aGivenProto was in the compartment of aCx
2173 : // coming in, we changed compartments to that of "parent" so may need
2174 : // to wrap the proto here.
2175 3 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2176 0 : if (!JS_WrapObject(aCx, &proto)) {
2177 0 : return false;
2178 : }
2179 : }
2180 : } else {
2181 3 : proto = canonicalProto;
2182 : }
2183 :
2184 12 : BindingJSObjectCreator<mozilla::dom::XMLHttpRequest> creator(aCx);
2185 6 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
2186 6 : if (!aReflector) {
2187 0 : return false;
2188 : }
2189 :
2190 6 : aCache->SetWrapper(aReflector);
2191 6 : creator.InitializationSucceeded();
2192 :
2193 6 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
2194 : aCache->GetWrapperPreserveColor() == aReflector);
2195 : // If proto != canonicalProto, we have to preserve our wrapper;
2196 : // otherwise we won't be able to properly recreate it later, since
2197 : // we won't know what proto to use. Note that we don't check
2198 : // aGivenProto here, since it's entirely possible (and even
2199 : // somewhat common) to have a non-null aGivenProto which is the
2200 : // same as canonicalProto.
2201 6 : if (proto != canonicalProto) {
2202 0 : PreserveWrapper(aObject);
2203 : }
2204 :
2205 6 : return true;
2206 : }
2207 :
2208 : // This may allocate too many slots, because we only really need
2209 : // slots for our non-interface-typed members that we cache. But
2210 : // allocating slots only for those would make the slot index
2211 : // computations much more complicated, so let's do this the simple
2212 : // way for now.
2213 : DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
2214 :
2215 : const NativePropertyHooks sNativePropertyHooks[] = { {
2216 : nullptr,
2217 : nullptr,
2218 : nullptr,
2219 : { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
2220 : prototypes::id::XMLHttpRequest,
2221 : constructors::id::XMLHttpRequest,
2222 : XMLHttpRequestEventTargetBinding::sNativePropertyHooks,
2223 : &sXrayExpandoObjectClass
2224 : } };
2225 :
2226 : void
2227 26 : ClearCachedResponseTextValue(mozilla::dom::XMLHttpRequest* aObject)
2228 : {
2229 : JSObject* obj;
2230 26 : obj = aObject->GetWrapper();
2231 26 : if (!obj) {
2232 3 : return;
2233 : }
2234 23 : js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 0), JS::UndefinedValue());
2235 23 : xpc::ClearXrayExpandoSlots(obj, (xpc::JSSLOT_EXPANDO_COUNT + 0));
2236 : }
2237 :
2238 : void
2239 6 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2240 : {
2241 6 : JS::Handle<JSObject*> parentProto(XMLHttpRequestEventTargetBinding::GetProtoObjectHandle(aCx));
2242 6 : if (!parentProto) {
2243 0 : return;
2244 : }
2245 :
2246 6 : JS::Handle<JSObject*> constructorProto(XMLHttpRequestEventTargetBinding::GetConstructorObjectHandle(aCx));
2247 6 : if (!constructorProto) {
2248 0 : return;
2249 : }
2250 :
2251 : static bool sIdsInited = false;
2252 6 : if (!sIdsInited && NS_IsMainThread()) {
2253 2 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
2254 0 : return;
2255 : }
2256 2 : if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
2257 0 : return;
2258 : }
2259 2 : sIdsInited = true;
2260 : }
2261 :
2262 6 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XMLHttpRequest);
2263 6 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XMLHttpRequest);
2264 12 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2265 : &sPrototypeClass.mBase, protoCache,
2266 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
2267 : interfaceCache,
2268 : sNativeProperties.Upcast(),
2269 6 : nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
2270 : "XMLHttpRequest", aDefineOnGlobal,
2271 : nullptr,
2272 6 : false);
2273 : }
2274 :
2275 : JS::Handle<JSObject*>
2276 6 : GetProtoObjectHandle(JSContext* aCx)
2277 : {
2278 : /* Get the interface prototype object for this class. This will create the
2279 : object as needed. */
2280 6 : bool aDefineOnGlobal = true;
2281 :
2282 : /* Make sure our global is sane. Hopefully we can remove this sometime */
2283 6 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
2284 6 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
2285 0 : return nullptr;
2286 : }
2287 :
2288 : /* Check to see whether the interface objects are already installed */
2289 6 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
2290 6 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::XMLHttpRequest)) {
2291 2 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
2292 1 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
2293 : }
2294 :
2295 : /*
2296 : * The object might _still_ be null, but that's OK.
2297 : *
2298 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
2299 : * traced by TraceProtoAndIfaceCache() and its contents are never
2300 : * changed after they have been set.
2301 : *
2302 : * Calling address() avoids the read read barrier that does gray
2303 : * unmarking, but it's not possible for the object to be gray here.
2304 : */
2305 :
2306 6 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::XMLHttpRequest);
2307 6 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
2308 6 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
2309 : }
2310 :
2311 : JS::Handle<JSObject*>
2312 5 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
2313 : {
2314 : /* Get the interface object for this class. This will create the object as
2315 : needed. */
2316 :
2317 : /* Make sure our global is sane. Hopefully we can remove this sometime */
2318 5 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
2319 5 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
2320 0 : return nullptr;
2321 : }
2322 :
2323 : /* Check to see whether the interface objects are already installed */
2324 5 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
2325 5 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::XMLHttpRequest)) {
2326 10 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
2327 5 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
2328 : }
2329 :
2330 : /*
2331 : * The object might _still_ be null, but that's OK.
2332 : *
2333 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
2334 : * traced by TraceProtoAndIfaceCache() and its contents are never
2335 : * changed after they have been set.
2336 : *
2337 : * Calling address() avoids the read read barrier that does gray
2338 : * unmarking, but it's not possible for the object to be gray here.
2339 : */
2340 :
2341 5 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::XMLHttpRequest);
2342 5 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
2343 5 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
2344 : }
2345 :
2346 : JSObject*
2347 5 : GetConstructorObject(JSContext* aCx)
2348 : {
2349 5 : return GetConstructorObjectHandle(aCx);
2350 : }
2351 :
2352 : } // namespace XMLHttpRequestBinding
2353 :
2354 :
2355 :
2356 : } // namespace dom
2357 : } // namespace mozilla
|