/work/obj-fuzz/dom/bindings/RequestBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Request.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "RequestBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "jsapi.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/dom/AbortSignal.h" |
9 | | #include "mozilla/dom/BindingUtils.h" |
10 | | #include "mozilla/dom/DOMJSClass.h" |
11 | | #include "mozilla/dom/DOMPrefs.h" |
12 | | #include "mozilla/dom/Headers.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/PrimitiveConversions.h" |
15 | | #include "mozilla/dom/Promise.h" |
16 | | #include "mozilla/dom/Request.h" |
17 | | #include "mozilla/dom/ScriptSettings.h" |
18 | | #include "mozilla/dom/ToJSValue.h" |
19 | | #include "mozilla/dom/UnionConversions.h" |
20 | | #include "mozilla/dom/XrayExpandoClass.h" |
21 | | #include "nsContentUtils.h" |
22 | | |
23 | | namespace mozilla { |
24 | | namespace dom { |
25 | | |
26 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
27 | | using namespace mozilla::dom::binding_detail; |
28 | | |
29 | | |
30 | | namespace RequestDestinationValues { |
31 | | extern const EnumEntry strings[19] = { |
32 | | {"", 0}, |
33 | | {"audio", 5}, |
34 | | {"audioworklet", 12}, |
35 | | {"document", 8}, |
36 | | {"embed", 5}, |
37 | | {"font", 4}, |
38 | | {"image", 5}, |
39 | | {"manifest", 8}, |
40 | | {"object", 6}, |
41 | | {"paintworklet", 12}, |
42 | | {"report", 6}, |
43 | | {"script", 6}, |
44 | | {"sharedworker", 12}, |
45 | | {"style", 5}, |
46 | | {"track", 5}, |
47 | | {"video", 5}, |
48 | | {"worker", 6}, |
49 | | {"xslt", 4}, |
50 | | { nullptr, 0 } |
51 | | }; |
52 | | } // namespace RequestDestinationValues |
53 | | |
54 | | bool |
55 | | ToJSValue(JSContext* aCx, RequestDestination aArgument, JS::MutableHandle<JS::Value> aValue) |
56 | 0 | { |
57 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestDestinationValues::strings)); |
58 | 0 | JSString* resultStr = |
59 | 0 | JS_NewStringCopyN(aCx, RequestDestinationValues::strings[uint32_t(aArgument)].value, |
60 | 0 | RequestDestinationValues::strings[uint32_t(aArgument)].length); |
61 | 0 | if (!resultStr) { |
62 | 0 | return false; |
63 | 0 | } |
64 | 0 | aValue.setString(resultStr); |
65 | 0 | return true; |
66 | 0 | } |
67 | | |
68 | | |
69 | | namespace RequestModeValues { |
70 | | extern const EnumEntry strings[5] = { |
71 | | {"same-origin", 11}, |
72 | | {"no-cors", 7}, |
73 | | {"cors", 4}, |
74 | | {"navigate", 8}, |
75 | | { nullptr, 0 } |
76 | | }; |
77 | | } // namespace RequestModeValues |
78 | | |
79 | | bool |
80 | | ToJSValue(JSContext* aCx, RequestMode aArgument, JS::MutableHandle<JS::Value> aValue) |
81 | 0 | { |
82 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestModeValues::strings)); |
83 | 0 | JSString* resultStr = |
84 | 0 | JS_NewStringCopyN(aCx, RequestModeValues::strings[uint32_t(aArgument)].value, |
85 | 0 | RequestModeValues::strings[uint32_t(aArgument)].length); |
86 | 0 | if (!resultStr) { |
87 | 0 | return false; |
88 | 0 | } |
89 | 0 | aValue.setString(resultStr); |
90 | 0 | return true; |
91 | 0 | } |
92 | | |
93 | | |
94 | | namespace RequestCredentialsValues { |
95 | | extern const EnumEntry strings[4] = { |
96 | | {"omit", 4}, |
97 | | {"same-origin", 11}, |
98 | | {"include", 7}, |
99 | | { nullptr, 0 } |
100 | | }; |
101 | | } // namespace RequestCredentialsValues |
102 | | |
103 | | bool |
104 | | ToJSValue(JSContext* aCx, RequestCredentials aArgument, JS::MutableHandle<JS::Value> aValue) |
105 | 0 | { |
106 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestCredentialsValues::strings)); |
107 | 0 | JSString* resultStr = |
108 | 0 | JS_NewStringCopyN(aCx, RequestCredentialsValues::strings[uint32_t(aArgument)].value, |
109 | 0 | RequestCredentialsValues::strings[uint32_t(aArgument)].length); |
110 | 0 | if (!resultStr) { |
111 | 0 | return false; |
112 | 0 | } |
113 | 0 | aValue.setString(resultStr); |
114 | 0 | return true; |
115 | 0 | } |
116 | | |
117 | | |
118 | | namespace RequestCacheValues { |
119 | | extern const EnumEntry strings[7] = { |
120 | | {"default", 7}, |
121 | | {"no-store", 8}, |
122 | | {"reload", 6}, |
123 | | {"no-cache", 8}, |
124 | | {"force-cache", 11}, |
125 | | {"only-if-cached", 14}, |
126 | | { nullptr, 0 } |
127 | | }; |
128 | | } // namespace RequestCacheValues |
129 | | |
130 | | bool |
131 | | ToJSValue(JSContext* aCx, RequestCache aArgument, JS::MutableHandle<JS::Value> aValue) |
132 | 0 | { |
133 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestCacheValues::strings)); |
134 | 0 | JSString* resultStr = |
135 | 0 | JS_NewStringCopyN(aCx, RequestCacheValues::strings[uint32_t(aArgument)].value, |
136 | 0 | RequestCacheValues::strings[uint32_t(aArgument)].length); |
137 | 0 | if (!resultStr) { |
138 | 0 | return false; |
139 | 0 | } |
140 | 0 | aValue.setString(resultStr); |
141 | 0 | return true; |
142 | 0 | } |
143 | | |
144 | | |
145 | | namespace RequestRedirectValues { |
146 | | extern const EnumEntry strings[4] = { |
147 | | {"follow", 6}, |
148 | | {"error", 5}, |
149 | | {"manual", 6}, |
150 | | { nullptr, 0 } |
151 | | }; |
152 | | } // namespace RequestRedirectValues |
153 | | |
154 | | bool |
155 | | ToJSValue(JSContext* aCx, RequestRedirect aArgument, JS::MutableHandle<JS::Value> aValue) |
156 | 0 | { |
157 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestRedirectValues::strings)); |
158 | 0 | JSString* resultStr = |
159 | 0 | JS_NewStringCopyN(aCx, RequestRedirectValues::strings[uint32_t(aArgument)].value, |
160 | 0 | RequestRedirectValues::strings[uint32_t(aArgument)].length); |
161 | 0 | if (!resultStr) { |
162 | 0 | return false; |
163 | 0 | } |
164 | 0 | aValue.setString(resultStr); |
165 | 0 | return true; |
166 | 0 | } |
167 | | |
168 | | |
169 | | namespace ReferrerPolicyValues { |
170 | | extern const EnumEntry strings[10] = { |
171 | | {"", 0}, |
172 | | {"no-referrer", 11}, |
173 | | {"no-referrer-when-downgrade", 26}, |
174 | | {"origin", 6}, |
175 | | {"origin-when-cross-origin", 24}, |
176 | | {"unsafe-url", 10}, |
177 | | {"same-origin", 11}, |
178 | | {"strict-origin", 13}, |
179 | | {"strict-origin-when-cross-origin", 31}, |
180 | | { nullptr, 0 } |
181 | | }; |
182 | | } // namespace ReferrerPolicyValues |
183 | | |
184 | | bool |
185 | | ToJSValue(JSContext* aCx, ReferrerPolicy aArgument, JS::MutableHandle<JS::Value> aValue) |
186 | 0 | { |
187 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ReferrerPolicyValues::strings)); |
188 | 0 | JSString* resultStr = |
189 | 0 | JS_NewStringCopyN(aCx, ReferrerPolicyValues::strings[uint32_t(aArgument)].value, |
190 | 0 | ReferrerPolicyValues::strings[uint32_t(aArgument)].length); |
191 | 0 | if (!resultStr) { |
192 | 0 | return false; |
193 | 0 | } |
194 | 0 | aValue.setString(resultStr); |
195 | 0 | return true; |
196 | 0 | } |
197 | | |
198 | | |
199 | | void |
200 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningRequestOrUSVString& aUnion, const char* aName, uint32_t aFlags) |
201 | 0 | { |
202 | 0 | if (aUnion.IsRequest()) { |
203 | 0 | ImplCycleCollectionTraverse(aCallback, aUnion.GetAsRequest(), "mRequest", aFlags); |
204 | 0 | } |
205 | 0 | } |
206 | | |
207 | | |
208 | | void |
209 | | ImplCycleCollectionUnlink(OwningRequestOrUSVString& aUnion) |
210 | 0 | { |
211 | 0 | aUnion.Uninit(); |
212 | 0 | } |
213 | | |
214 | | |
215 | | |
216 | | RequestInit::RequestInit() |
217 | 0 | { |
218 | 0 | // Safe to pass a null context if we pass a null value |
219 | 0 | Init(nullptr, JS::NullHandleValue); |
220 | 0 | } |
221 | | |
222 | | |
223 | | bool |
224 | | RequestInit::InitIds(JSContext* cx, RequestInitAtoms* atomsCache) |
225 | 0 | { |
226 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
227 | 0 |
|
228 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
229 | 0 | // uninitialized. |
230 | 0 | if (!atomsCache->signal_id.init(cx, "signal") || |
231 | 0 | !atomsCache->referrerPolicy_id.init(cx, "referrerPolicy") || |
232 | 0 | !atomsCache->referrer_id.init(cx, "referrer") || |
233 | 0 | !atomsCache->redirect_id.init(cx, "redirect") || |
234 | 0 | !atomsCache->observe_id.init(cx, "observe") || |
235 | 0 | !atomsCache->mozErrors_id.init(cx, "mozErrors") || |
236 | 0 | !atomsCache->mode_id.init(cx, "mode") || |
237 | 0 | !atomsCache->method_id.init(cx, "method") || |
238 | 0 | !atomsCache->integrity_id.init(cx, "integrity") || |
239 | 0 | !atomsCache->headers_id.init(cx, "headers") || |
240 | 0 | !atomsCache->credentials_id.init(cx, "credentials") || |
241 | 0 | !atomsCache->cache_id.init(cx, "cache") || |
242 | 0 | !atomsCache->body_id.init(cx, "body")) { |
243 | 0 | return false; |
244 | 0 | } |
245 | 0 | return true; |
246 | 0 | } |
247 | | |
248 | | bool |
249 | | RequestInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
250 | 0 | { |
251 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
252 | 0 | // Since in that case we will not have to do any property gets |
253 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
254 | 0 | // checkers by static analysis tools |
255 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
256 | 0 | RequestInitAtoms* atomsCache = nullptr; |
257 | 0 | if (cx) { |
258 | 0 | atomsCache = GetAtomCache<RequestInitAtoms>(cx); |
259 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
260 | 0 | return false; |
261 | 0 | } |
262 | 0 | } |
263 | 0 | |
264 | 0 | if (!IsConvertibleToDictionary(val)) { |
265 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
266 | 0 | } |
267 | 0 | |
268 | 0 | bool isNull = val.isNullOrUndefined(); |
269 | 0 | // We only need these if !isNull, in which case we have |cx|. |
270 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
271 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
272 | 0 | if (!isNull) { |
273 | 0 | MOZ_ASSERT(cx); |
274 | 0 | object.emplace(cx, &val.toObject()); |
275 | 0 | temp.emplace(cx); |
276 | 0 | } |
277 | 0 | if (!isNull) { |
278 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->body_id, temp.ptr())) { |
279 | 0 | return false; |
280 | 0 | } |
281 | 0 | } |
282 | 0 | if (!isNull && !temp->isUndefined()) { |
283 | 0 | mBody.Construct(); |
284 | 0 | if (temp.ref().isNullOrUndefined()) { |
285 | 0 | (mBody.Value()).SetNull(); |
286 | 0 | } else { |
287 | 0 | { |
288 | 0 | bool done = false, failed = false, tryNext; |
289 | 0 | if (temp.ref().isObject()) { |
290 | 0 | done = (failed = !(mBody.Value()).SetValue().TrySetToBlob(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext || |
291 | 0 | (failed = !(mBody.Value()).SetValue().TrySetToArrayBufferView(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext || |
292 | 0 | (failed = !(mBody.Value()).SetValue().TrySetToArrayBuffer(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext || |
293 | 0 | (failed = !(mBody.Value()).SetValue().TrySetToFormData(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext || |
294 | 0 | (failed = !(mBody.Value()).SetValue().TrySetToURLSearchParams(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext; |
295 | 0 |
|
296 | 0 | } |
297 | 0 | if (!done) { |
298 | 0 | do { |
299 | 0 | done = (failed = !(mBody.Value()).SetValue().TrySetToUSVString(cx, temp.ref(), tryNext)) || !tryNext; |
300 | 0 | break; |
301 | 0 | } while (false); |
302 | 0 | } |
303 | 0 | if (failed) { |
304 | 0 | return false; |
305 | 0 | } |
306 | 0 | if (!done) { |
307 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'body' member of RequestInit", "Blob, ArrayBufferView, ArrayBuffer, FormData, URLSearchParams"); |
308 | 0 | return false; |
309 | 0 | } |
310 | 0 | } |
311 | 0 | } |
312 | 0 | mIsAnyMemberPresent = true; |
313 | 0 | } |
314 | 0 |
|
315 | 0 | if (!isNull) { |
316 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->cache_id, temp.ptr())) { |
317 | 0 | return false; |
318 | 0 | } |
319 | 0 | } |
320 | 0 | if (!isNull && !temp->isUndefined()) { |
321 | 0 | mCache.Construct(); |
322 | 0 | { |
323 | 0 | int index; |
324 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestCacheValues::strings, "RequestCache", "'cache' member of RequestInit", &index)) { |
325 | 0 | return false; |
326 | 0 | } |
327 | 0 | MOZ_ASSERT(index >= 0); |
328 | 0 | (mCache.Value()) = static_cast<RequestCache>(index); |
329 | 0 | } |
330 | 0 | mIsAnyMemberPresent = true; |
331 | 0 | } |
332 | 0 |
|
333 | 0 | if (!isNull) { |
334 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->credentials_id, temp.ptr())) { |
335 | 0 | return false; |
336 | 0 | } |
337 | 0 | } |
338 | 0 | if (!isNull && !temp->isUndefined()) { |
339 | 0 | mCredentials.Construct(); |
340 | 0 | { |
341 | 0 | int index; |
342 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestCredentialsValues::strings, "RequestCredentials", "'credentials' member of RequestInit", &index)) { |
343 | 0 | return false; |
344 | 0 | } |
345 | 0 | MOZ_ASSERT(index >= 0); |
346 | 0 | (mCredentials.Value()) = static_cast<RequestCredentials>(index); |
347 | 0 | } |
348 | 0 | mIsAnyMemberPresent = true; |
349 | 0 | } |
350 | 0 |
|
351 | 0 | if (!isNull) { |
352 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->headers_id, temp.ptr())) { |
353 | 0 | return false; |
354 | 0 | } |
355 | 0 | } |
356 | 0 | if (!isNull && !temp->isUndefined()) { |
357 | 0 | mHeaders.Construct(); |
358 | 0 | { |
359 | 0 | bool done = false, failed = false, tryNext; |
360 | 0 | if (temp.ref().isObject()) { |
361 | 0 | done = (failed = !(mHeaders.Value()).TrySetToHeaders(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext; |
362 | 0 |
|
363 | 0 | if (!done) { |
364 | 0 | done = (failed = !(mHeaders.Value()).TrySetToByteStringSequenceSequence(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext; |
365 | 0 | } |
366 | 0 | if (!done) { |
367 | 0 | done = (failed = !(mHeaders.Value()).TrySetToByteStringByteStringRecord(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext; |
368 | 0 | } |
369 | 0 | } |
370 | 0 | if (failed) { |
371 | 0 | return false; |
372 | 0 | } |
373 | 0 | if (!done) { |
374 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'headers' member of RequestInit", "Headers, ByteStringSequenceSequence, ByteStringByteStringRecord"); |
375 | 0 | return false; |
376 | 0 | } |
377 | 0 | } |
378 | 0 | mIsAnyMemberPresent = true; |
379 | 0 | } |
380 | 0 |
|
381 | 0 | if (!isNull) { |
382 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->integrity_id, temp.ptr())) { |
383 | 0 | return false; |
384 | 0 | } |
385 | 0 | } |
386 | 0 | if (!isNull && !temp->isUndefined()) { |
387 | 0 | mIntegrity.Construct(); |
388 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mIntegrity.Value()))) { |
389 | 0 | return false; |
390 | 0 | } |
391 | 0 | mIsAnyMemberPresent = true; |
392 | 0 | } |
393 | 0 |
|
394 | 0 | if (!isNull) { |
395 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->method_id, temp.ptr())) { |
396 | 0 | return false; |
397 | 0 | } |
398 | 0 | } |
399 | 0 | if (!isNull && !temp->isUndefined()) { |
400 | 0 | mMethod.Construct(); |
401 | 0 | if (!ConvertJSValueToByteString(cx, temp.ref(), false, (mMethod.Value()))) { |
402 | 0 | return false; |
403 | 0 | } |
404 | 0 | mIsAnyMemberPresent = true; |
405 | 0 | } |
406 | 0 |
|
407 | 0 | if (!isNull) { |
408 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mode_id, temp.ptr())) { |
409 | 0 | return false; |
410 | 0 | } |
411 | 0 | } |
412 | 0 | if (!isNull && !temp->isUndefined()) { |
413 | 0 | mMode.Construct(); |
414 | 0 | { |
415 | 0 | int index; |
416 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestModeValues::strings, "RequestMode", "'mode' member of RequestInit", &index)) { |
417 | 0 | return false; |
418 | 0 | } |
419 | 0 | MOZ_ASSERT(index >= 0); |
420 | 0 | (mMode.Value()) = static_cast<RequestMode>(index); |
421 | 0 | } |
422 | 0 | mIsAnyMemberPresent = true; |
423 | 0 | } |
424 | 0 |
|
425 | 0 | if (!isNull) { |
426 | 0 | if (nsContentUtils::ThreadsafeIsSystemCaller(cx)) { |
427 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mozErrors_id, temp.ptr())) { |
428 | 0 | return false; |
429 | 0 | } |
430 | 0 | } else { |
431 | 0 | temp->setUndefined(); |
432 | 0 | } |
433 | 0 | } |
434 | 0 | if (!isNull && !temp->isUndefined()) { |
435 | 0 | mMozErrors.Construct(); |
436 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mMozErrors.Value()))) { |
437 | 0 | return false; |
438 | 0 | } |
439 | 0 | mIsAnyMemberPresent = true; |
440 | 0 | } |
441 | 0 |
|
442 | 0 | if (!isNull) { |
443 | 0 | if (mozilla::dom::DOMPrefs::dom_fetchObserver_enabled(cx, *object)) { |
444 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->observe_id, temp.ptr())) { |
445 | 0 | return false; |
446 | 0 | } |
447 | 0 | } else { |
448 | 0 | temp->setUndefined(); |
449 | 0 | } |
450 | 0 | } |
451 | 0 | if (!isNull && !temp->isUndefined()) { |
452 | 0 | mObserve.Construct(); |
453 | 0 | if (temp.ref().isObject()) { |
454 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
455 | 0 | JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject()); |
456 | 0 | JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx)); |
457 | 0 | (mObserve.Value()) = new ObserverCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal()); |
458 | 0 | } |
459 | 0 | } else { |
460 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'observe' member of RequestInit"); |
461 | 0 | return false; |
462 | 0 | } |
463 | 0 | mIsAnyMemberPresent = true; |
464 | 0 | } |
465 | 0 |
|
466 | 0 | if (!isNull) { |
467 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->redirect_id, temp.ptr())) { |
468 | 0 | return false; |
469 | 0 | } |
470 | 0 | } |
471 | 0 | if (!isNull && !temp->isUndefined()) { |
472 | 0 | mRedirect.Construct(); |
473 | 0 | { |
474 | 0 | int index; |
475 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestRedirectValues::strings, "RequestRedirect", "'redirect' member of RequestInit", &index)) { |
476 | 0 | return false; |
477 | 0 | } |
478 | 0 | MOZ_ASSERT(index >= 0); |
479 | 0 | (mRedirect.Value()) = static_cast<RequestRedirect>(index); |
480 | 0 | } |
481 | 0 | mIsAnyMemberPresent = true; |
482 | 0 | } |
483 | 0 |
|
484 | 0 | if (!isNull) { |
485 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->referrer_id, temp.ptr())) { |
486 | 0 | return false; |
487 | 0 | } |
488 | 0 | } |
489 | 0 | if (!isNull && !temp->isUndefined()) { |
490 | 0 | mReferrer.Construct(); |
491 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mReferrer.Value()))) { |
492 | 0 | return false; |
493 | 0 | } |
494 | 0 | NormalizeUSVString((mReferrer.Value())); |
495 | 0 | mIsAnyMemberPresent = true; |
496 | 0 | } |
497 | 0 |
|
498 | 0 | if (!isNull) { |
499 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->referrerPolicy_id, temp.ptr())) { |
500 | 0 | return false; |
501 | 0 | } |
502 | 0 | } |
503 | 0 | if (!isNull && !temp->isUndefined()) { |
504 | 0 | mReferrerPolicy.Construct(); |
505 | 0 | { |
506 | 0 | int index; |
507 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), ReferrerPolicyValues::strings, "ReferrerPolicy", "'referrerPolicy' member of RequestInit", &index)) { |
508 | 0 | return false; |
509 | 0 | } |
510 | 0 | MOZ_ASSERT(index >= 0); |
511 | 0 | (mReferrerPolicy.Value()) = static_cast<ReferrerPolicy>(index); |
512 | 0 | } |
513 | 0 | mIsAnyMemberPresent = true; |
514 | 0 | } |
515 | 0 |
|
516 | 0 | if (!isNull) { |
517 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->signal_id, temp.ptr())) { |
518 | 0 | return false; |
519 | 0 | } |
520 | 0 | } |
521 | 0 | if (!isNull && !temp->isUndefined()) { |
522 | 0 | mSignal.Construct(); |
523 | 0 | if (temp.ref().isObject()) { |
524 | 0 | static_assert(IsRefcounted<mozilla::dom::AbortSignal>::value, "We can only store refcounted classes.");{ |
525 | 0 | nsresult rv = UnwrapObject<prototypes::id::AbortSignal, mozilla::dom::AbortSignal>(temp.ptr(), (mSignal.Value())); |
526 | 0 | if (NS_FAILED(rv)) { |
527 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'signal' member of RequestInit", "AbortSignal"); |
528 | 0 | return false; |
529 | 0 | } |
530 | 0 | } |
531 | 0 | } else if (temp.ref().isNullOrUndefined()) { |
532 | 0 | (mSignal.Value()) = nullptr; |
533 | 0 | } else { |
534 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'signal' member of RequestInit"); |
535 | 0 | return false; |
536 | 0 | } |
537 | 0 | mIsAnyMemberPresent = true; |
538 | 0 | } |
539 | 0 | return true; |
540 | 0 | } |
541 | | |
542 | | bool |
543 | | RequestInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
544 | 0 | { |
545 | 0 | RequestInitAtoms* atomsCache = GetAtomCache<RequestInitAtoms>(cx); |
546 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
547 | 0 | return false; |
548 | 0 | } |
549 | 0 | |
550 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
551 | 0 | if (!obj) { |
552 | 0 | return false; |
553 | 0 | } |
554 | 0 | rval.set(JS::ObjectValue(*obj)); |
555 | 0 |
|
556 | 0 | if (mBody.WasPassed()) { |
557 | 0 | do { |
558 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
559 | 0 | JS::Rooted<JS::Value> temp(cx); |
560 | 0 | Nullable<OwningBlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString > const & currentValue = mBody.InternalValue(); |
561 | 0 | if (currentValue.IsNull()) { |
562 | 0 | temp.setNull(); |
563 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->body_id, temp, JSPROP_ENUMERATE)) { |
564 | 0 | return false; |
565 | 0 | } |
566 | 0 | break; |
567 | 0 | } |
568 | 0 | if (!currentValue.Value().ToJSVal(cx, obj, &temp)) { |
569 | 0 | return false; |
570 | 0 | } |
571 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->body_id, temp, JSPROP_ENUMERATE)) { |
572 | 0 | return false; |
573 | 0 | } |
574 | 0 | break; |
575 | 0 | } while(false); |
576 | 0 | } |
577 | 0 |
|
578 | 0 | if (mCache.WasPassed()) { |
579 | 0 | do { |
580 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
581 | 0 | JS::Rooted<JS::Value> temp(cx); |
582 | 0 | RequestCache const & currentValue = mCache.InternalValue(); |
583 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
584 | 0 | return false; |
585 | 0 | } |
586 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->cache_id, temp, JSPROP_ENUMERATE)) { |
587 | 0 | return false; |
588 | 0 | } |
589 | 0 | break; |
590 | 0 | } while(false); |
591 | 0 | } |
592 | 0 |
|
593 | 0 | if (mCredentials.WasPassed()) { |
594 | 0 | do { |
595 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
596 | 0 | JS::Rooted<JS::Value> temp(cx); |
597 | 0 | RequestCredentials const & currentValue = mCredentials.InternalValue(); |
598 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
599 | 0 | return false; |
600 | 0 | } |
601 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->credentials_id, temp, JSPROP_ENUMERATE)) { |
602 | 0 | return false; |
603 | 0 | } |
604 | 0 | break; |
605 | 0 | } while(false); |
606 | 0 | } |
607 | 0 |
|
608 | 0 | if (mHeaders.WasPassed()) { |
609 | 0 | do { |
610 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
611 | 0 | JS::Rooted<JS::Value> temp(cx); |
612 | 0 | OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord const & currentValue = mHeaders.InternalValue(); |
613 | 0 | if (!currentValue.ToJSVal(cx, obj, &temp)) { |
614 | 0 | return false; |
615 | 0 | } |
616 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->headers_id, temp, JSPROP_ENUMERATE)) { |
617 | 0 | return false; |
618 | 0 | } |
619 | 0 | break; |
620 | 0 | } while(false); |
621 | 0 | } |
622 | 0 |
|
623 | 0 | if (mIntegrity.WasPassed()) { |
624 | 0 | do { |
625 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
626 | 0 | JS::Rooted<JS::Value> temp(cx); |
627 | 0 | nsString const & currentValue = mIntegrity.InternalValue(); |
628 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
629 | 0 | return false; |
630 | 0 | } |
631 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->integrity_id, temp, JSPROP_ENUMERATE)) { |
632 | 0 | return false; |
633 | 0 | } |
634 | 0 | break; |
635 | 0 | } while(false); |
636 | 0 | } |
637 | 0 |
|
638 | 0 | if (mMethod.WasPassed()) { |
639 | 0 | do { |
640 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
641 | 0 | JS::Rooted<JS::Value> temp(cx); |
642 | 0 | nsCString const & currentValue = mMethod.InternalValue(); |
643 | 0 | if (!NonVoidByteStringToJsval(cx, currentValue, &temp)) { |
644 | 0 | return false; |
645 | 0 | } |
646 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->method_id, temp, JSPROP_ENUMERATE)) { |
647 | 0 | return false; |
648 | 0 | } |
649 | 0 | break; |
650 | 0 | } while(false); |
651 | 0 | } |
652 | 0 |
|
653 | 0 | if (mMode.WasPassed()) { |
654 | 0 | do { |
655 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
656 | 0 | JS::Rooted<JS::Value> temp(cx); |
657 | 0 | RequestMode const & currentValue = mMode.InternalValue(); |
658 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
659 | 0 | return false; |
660 | 0 | } |
661 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mode_id, temp, JSPROP_ENUMERATE)) { |
662 | 0 | return false; |
663 | 0 | } |
664 | 0 | break; |
665 | 0 | } while(false); |
666 | 0 | } |
667 | 0 |
|
668 | 0 | if (nsContentUtils::ThreadsafeIsSystemCaller(cx)) { |
669 | 0 | if (mMozErrors.WasPassed()) { |
670 | 0 | do { |
671 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
672 | 0 | JS::Rooted<JS::Value> temp(cx); |
673 | 0 | bool const & currentValue = mMozErrors.InternalValue(); |
674 | 0 | temp.setBoolean(currentValue); |
675 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mozErrors_id, temp, JSPROP_ENUMERATE)) { |
676 | 0 | return false; |
677 | 0 | } |
678 | 0 | break; |
679 | 0 | } while(false); |
680 | 0 | } |
681 | 0 | } |
682 | 0 |
|
683 | 0 | if (mozilla::dom::DOMPrefs::dom_fetchObserver_enabled(cx, obj)) { |
684 | 0 | if (mObserve.WasPassed()) { |
685 | 0 | do { |
686 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
687 | 0 | JS::Rooted<JS::Value> temp(cx); |
688 | 0 | OwningNonNull<ObserverCallback> const & currentValue = mObserve.InternalValue(); |
689 | 0 | temp.setObjectOrNull(GetCallbackFromCallbackObject(cx, currentValue)); |
690 | 0 | if (!MaybeWrapObjectValue(cx, &temp)) { |
691 | 0 | return false; |
692 | 0 | } |
693 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->observe_id, temp, JSPROP_ENUMERATE)) { |
694 | 0 | return false; |
695 | 0 | } |
696 | 0 | break; |
697 | 0 | } while(false); |
698 | 0 | } |
699 | 0 | } |
700 | 0 |
|
701 | 0 | if (mRedirect.WasPassed()) { |
702 | 0 | do { |
703 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
704 | 0 | JS::Rooted<JS::Value> temp(cx); |
705 | 0 | RequestRedirect const & currentValue = mRedirect.InternalValue(); |
706 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
707 | 0 | return false; |
708 | 0 | } |
709 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->redirect_id, temp, JSPROP_ENUMERATE)) { |
710 | 0 | return false; |
711 | 0 | } |
712 | 0 | break; |
713 | 0 | } while(false); |
714 | 0 | } |
715 | 0 |
|
716 | 0 | if (mReferrer.WasPassed()) { |
717 | 0 | do { |
718 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
719 | 0 | JS::Rooted<JS::Value> temp(cx); |
720 | 0 | nsString const & currentValue = mReferrer.InternalValue(); |
721 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
722 | 0 | return false; |
723 | 0 | } |
724 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->referrer_id, temp, JSPROP_ENUMERATE)) { |
725 | 0 | return false; |
726 | 0 | } |
727 | 0 | break; |
728 | 0 | } while(false); |
729 | 0 | } |
730 | 0 |
|
731 | 0 | if (mReferrerPolicy.WasPassed()) { |
732 | 0 | do { |
733 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
734 | 0 | JS::Rooted<JS::Value> temp(cx); |
735 | 0 | ReferrerPolicy const & currentValue = mReferrerPolicy.InternalValue(); |
736 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
737 | 0 | return false; |
738 | 0 | } |
739 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->referrerPolicy_id, temp, JSPROP_ENUMERATE)) { |
740 | 0 | return false; |
741 | 0 | } |
742 | 0 | break; |
743 | 0 | } while(false); |
744 | 0 | } |
745 | 0 |
|
746 | 0 | if (mSignal.WasPassed()) { |
747 | 0 | do { |
748 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
749 | 0 | JS::Rooted<JS::Value> temp(cx); |
750 | 0 | RefPtr<mozilla::dom::AbortSignal> const & currentValue = mSignal.InternalValue(); |
751 | 0 | if (!currentValue) { |
752 | 0 | temp.setNull(); |
753 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->signal_id, temp, JSPROP_ENUMERATE)) { |
754 | 0 | return false; |
755 | 0 | } |
756 | 0 | break; |
757 | 0 | } |
758 | 0 | if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) { |
759 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
760 | 0 | return false; |
761 | 0 | } |
762 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->signal_id, temp, JSPROP_ENUMERATE)) { |
763 | 0 | return false; |
764 | 0 | } |
765 | 0 | break; |
766 | 0 | } while(false); |
767 | 0 | } |
768 | 0 |
|
769 | 0 | return true; |
770 | 0 | } |
771 | | |
772 | | void |
773 | | RequestInit::TraceDictionary(JSTracer* trc) |
774 | 0 | { |
775 | 0 | if (mBody.WasPassed()) { |
776 | 0 | if (!mBody.Value().IsNull()) { |
777 | 0 | mBody.Value().Value().TraceUnion(trc); |
778 | 0 | } |
779 | 0 | } |
780 | 0 | } |
781 | | |
782 | | |
783 | | |
784 | | namespace binding_detail { |
785 | | } // namespace binding_detail |
786 | | |
787 | | |
788 | | bool |
789 | | RequestOrUSVString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
790 | 0 | { |
791 | 0 | switch (mType) { |
792 | 0 | case eUninitialized: { |
793 | 0 | return false; |
794 | 0 | break; |
795 | 0 | } |
796 | 0 | case eRequest: { |
797 | 0 | if (!GetOrCreateDOMReflector(cx, mValue.mRequest.Value(), rval)) { |
798 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
799 | 0 | return false; |
800 | 0 | } |
801 | 0 | return true; |
802 | 0 | break; |
803 | 0 | } |
804 | 0 | case eUSVString: { |
805 | 0 | if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVString.Value(), rval)) { |
806 | 0 | return false; |
807 | 0 | } |
808 | 0 | return true; |
809 | 0 | break; |
810 | 0 | } |
811 | 0 | default: { |
812 | 0 | return false; |
813 | 0 | break; |
814 | 0 | } |
815 | 0 | } |
816 | 0 | |
817 | 0 | return false; |
818 | 0 | } |
819 | | |
820 | | |
821 | | OwningNonNull<mozilla::dom::Request>& |
822 | | OwningRequestOrUSVString::RawSetAsRequest() |
823 | 0 | { |
824 | 0 | if (mType == eRequest) { |
825 | 0 | return mValue.mRequest.Value(); |
826 | 0 | } |
827 | 0 | MOZ_ASSERT(mType == eUninitialized); |
828 | 0 | mType = eRequest; |
829 | 0 | return mValue.mRequest.SetValue(); |
830 | 0 | } |
831 | | |
832 | | OwningNonNull<mozilla::dom::Request>& |
833 | | OwningRequestOrUSVString::SetAsRequest() |
834 | 0 | { |
835 | 0 | if (mType == eRequest) { |
836 | 0 | return mValue.mRequest.Value(); |
837 | 0 | } |
838 | 0 | Uninit(); |
839 | 0 | mType = eRequest; |
840 | 0 | return mValue.mRequest.SetValue(); |
841 | 0 | } |
842 | | |
843 | | bool |
844 | | OwningRequestOrUSVString::TrySetToRequest(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
845 | 0 | { |
846 | 0 | tryNext = false; |
847 | 0 | { // scope for memberSlot |
848 | 0 | OwningNonNull<mozilla::dom::Request>& memberSlot = RawSetAsRequest(); |
849 | 0 | static_assert(IsRefcounted<mozilla::dom::Request>::value, "We can only store refcounted classes.");{ |
850 | 0 | nsresult rv = UnwrapObject<prototypes::id::Request, mozilla::dom::Request>(value, memberSlot); |
851 | 0 | if (NS_FAILED(rv)) { |
852 | 0 | DestroyRequest(); |
853 | 0 | tryNext = true; |
854 | 0 | return true; |
855 | 0 | } |
856 | 0 | } |
857 | 0 | } |
858 | 0 | return true; |
859 | 0 | } |
860 | | |
861 | | void |
862 | | OwningRequestOrUSVString::DestroyRequest() |
863 | 0 | { |
864 | 0 | MOZ_ASSERT(IsRequest(), "Wrong type!"); |
865 | 0 | mValue.mRequest.Destroy(); |
866 | 0 | mType = eUninitialized; |
867 | 0 | } |
868 | | |
869 | | |
870 | | |
871 | | |
872 | | nsString& |
873 | | OwningRequestOrUSVString::RawSetAsUSVString() |
874 | 0 | { |
875 | 0 | if (mType == eUSVString) { |
876 | 0 | return mValue.mUSVString.Value(); |
877 | 0 | } |
878 | 0 | MOZ_ASSERT(mType == eUninitialized); |
879 | 0 | mType = eUSVString; |
880 | 0 | return mValue.mUSVString.SetValue(); |
881 | 0 | } |
882 | | |
883 | | nsString& |
884 | | OwningRequestOrUSVString::SetAsUSVString() |
885 | 0 | { |
886 | 0 | if (mType == eUSVString) { |
887 | 0 | return mValue.mUSVString.Value(); |
888 | 0 | } |
889 | 0 | Uninit(); |
890 | 0 | mType = eUSVString; |
891 | 0 | return mValue.mUSVString.SetValue(); |
892 | 0 | } |
893 | | |
894 | | bool |
895 | | OwningRequestOrUSVString::TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
896 | 0 | { |
897 | 0 | tryNext = false; |
898 | 0 | { // scope for memberSlot |
899 | 0 | nsString& memberSlot = RawSetAsUSVString(); |
900 | 0 | if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) { |
901 | 0 | return false; |
902 | 0 | } |
903 | 0 | NormalizeUSVString(memberSlot); |
904 | 0 | } |
905 | 0 | return true; |
906 | 0 | } |
907 | | |
908 | | |
909 | | void |
910 | | OwningRequestOrUSVString::DestroyUSVString() |
911 | 0 | { |
912 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
913 | 0 | mValue.mUSVString.Destroy(); |
914 | 0 | mType = eUninitialized; |
915 | 0 | } |
916 | | |
917 | | |
918 | | |
919 | | |
920 | | void |
921 | | OwningRequestOrUSVString::Uninit() |
922 | | { |
923 | | switch (mType) { |
924 | | case eUninitialized: { |
925 | | break; |
926 | | } |
927 | | case eRequest: { |
928 | | DestroyRequest(); |
929 | | break; |
930 | | } |
931 | | case eUSVString: { |
932 | | DestroyUSVString(); |
933 | | break; |
934 | | } |
935 | | } |
936 | | } |
937 | | |
938 | | bool |
939 | | OwningRequestOrUSVString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
940 | 0 | { |
941 | 0 | switch (mType) { |
942 | 0 | case eUninitialized: { |
943 | 0 | return false; |
944 | 0 | break; |
945 | 0 | } |
946 | 0 | case eRequest: { |
947 | 0 | if (!GetOrCreateDOMReflector(cx, mValue.mRequest.Value(), rval)) { |
948 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
949 | 0 | return false; |
950 | 0 | } |
951 | 0 | return true; |
952 | 0 | break; |
953 | 0 | } |
954 | 0 | case eUSVString: { |
955 | 0 | if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVString.Value(), rval)) { |
956 | 0 | return false; |
957 | 0 | } |
958 | 0 | return true; |
959 | 0 | break; |
960 | 0 | } |
961 | 0 | default: { |
962 | 0 | return false; |
963 | 0 | break; |
964 | 0 | } |
965 | 0 | } |
966 | 0 | |
967 | 0 | return false; |
968 | 0 | } |
969 | | |
970 | | void |
971 | | OwningRequestOrUSVString::TraceUnion(JSTracer* trc) |
972 | 0 | { |
973 | 0 | } |
974 | | |
975 | | OwningRequestOrUSVString& |
976 | | OwningRequestOrUSVString::operator=(const OwningRequestOrUSVString& aOther) |
977 | 0 | { |
978 | 0 | switch (aOther.mType) { |
979 | 0 | case eUninitialized: { |
980 | 0 | MOZ_ASSERT(mType == eUninitialized, |
981 | 0 | "We need to destroy ourselves?"); |
982 | 0 | break; |
983 | 0 | } |
984 | 0 | case eRequest: { |
985 | 0 | SetAsRequest() = aOther.GetAsRequest(); |
986 | 0 | break; |
987 | 0 | } |
988 | 0 | case eUSVString: { |
989 | 0 | SetAsUSVString() = aOther.GetAsUSVString(); |
990 | 0 | break; |
991 | 0 | } |
992 | 0 | } |
993 | 0 | return *this; |
994 | 0 | } |
995 | | |
996 | | |
997 | | namespace Request_Binding { |
998 | | |
999 | | MOZ_CAN_RUN_SCRIPT static bool |
1000 | | get_method(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1001 | 0 | { |
1002 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.method", DOM, cx); |
1003 | 0 |
|
1004 | 0 | nsCString result; |
1005 | 0 | self->GetMethod(result); |
1006 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1007 | 0 | if (!NonVoidByteStringToJsval(cx, result, args.rval())) { |
1008 | 0 | return false; |
1009 | 0 | } |
1010 | 0 | return true; |
1011 | 0 | } |
1012 | | |
1013 | | static const JSJitInfo method_getterinfo = { |
1014 | | { (JSJitGetterOp)get_method }, |
1015 | | { prototypes::id::Request }, |
1016 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1017 | | JSJitInfo::Getter, |
1018 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1019 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1020 | | false, /* isInfallible. False in setters. */ |
1021 | | false, /* isMovable. Not relevant for setters. */ |
1022 | | false, /* isEliminatable. Not relevant for setters. */ |
1023 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1024 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1025 | | false, /* isTypedMethod. Only relevant for methods. */ |
1026 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1027 | | }; |
1028 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1029 | | static_assert(0 < 1, "There is no slot for us"); |
1030 | | |
1031 | | MOZ_CAN_RUN_SCRIPT static bool |
1032 | | get_url(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1033 | 0 | { |
1034 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.url", DOM, cx); |
1035 | 0 |
|
1036 | 0 | DOMString result; |
1037 | 0 | self->GetUrl(result); |
1038 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1039 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1040 | 0 | return false; |
1041 | 0 | } |
1042 | 0 | return true; |
1043 | 0 | } |
1044 | | |
1045 | | static const JSJitInfo url_getterinfo = { |
1046 | | { (JSJitGetterOp)get_url }, |
1047 | | { prototypes::id::Request }, |
1048 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1049 | | JSJitInfo::Getter, |
1050 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1051 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1052 | | false, /* isInfallible. False in setters. */ |
1053 | | false, /* isMovable. Not relevant for setters. */ |
1054 | | false, /* isEliminatable. Not relevant for setters. */ |
1055 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1056 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1057 | | false, /* isTypedMethod. Only relevant for methods. */ |
1058 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1059 | | }; |
1060 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1061 | | static_assert(0 < 1, "There is no slot for us"); |
1062 | | |
1063 | | MOZ_CAN_RUN_SCRIPT static bool |
1064 | | get_headers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1065 | 0 | { |
1066 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.headers", DOM, cx); |
1067 | 0 |
|
1068 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Headers>(self->Headers_())); |
1069 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1070 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1071 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1072 | 0 | return false; |
1073 | 0 | } |
1074 | 0 | return true; |
1075 | 0 | } |
1076 | | |
1077 | | static const JSJitInfo headers_getterinfo = { |
1078 | | { (JSJitGetterOp)get_headers }, |
1079 | | { prototypes::id::Request }, |
1080 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1081 | | JSJitInfo::Getter, |
1082 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
1083 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1084 | | false, /* isInfallible. False in setters. */ |
1085 | | true, /* isMovable. Not relevant for setters. */ |
1086 | | true, /* isEliminatable. Not relevant for setters. */ |
1087 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1088 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1089 | | false, /* isTypedMethod. Only relevant for methods. */ |
1090 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1091 | | }; |
1092 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1093 | | static_assert(0 < 1, "There is no slot for us"); |
1094 | | |
1095 | | MOZ_CAN_RUN_SCRIPT static bool |
1096 | | get_destination(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1097 | 0 | { |
1098 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.destination", DOM, cx); |
1099 | 0 |
|
1100 | 0 | RequestDestination result(self->Destination()); |
1101 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1102 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1103 | 0 | return false; |
1104 | 0 | } |
1105 | 0 | return true; |
1106 | 0 | } |
1107 | | |
1108 | | static const JSJitInfo destination_getterinfo = { |
1109 | | { (JSJitGetterOp)get_destination }, |
1110 | | { prototypes::id::Request }, |
1111 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1112 | | JSJitInfo::Getter, |
1113 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1114 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1115 | | false, /* isInfallible. False in setters. */ |
1116 | | false, /* isMovable. Not relevant for setters. */ |
1117 | | false, /* isEliminatable. Not relevant for setters. */ |
1118 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1119 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1120 | | false, /* isTypedMethod. Only relevant for methods. */ |
1121 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1122 | | }; |
1123 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1124 | | static_assert(0 < 1, "There is no slot for us"); |
1125 | | |
1126 | | MOZ_CAN_RUN_SCRIPT static bool |
1127 | | get_referrer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1128 | 0 | { |
1129 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.referrer", DOM, cx); |
1130 | 0 |
|
1131 | 0 | DOMString result; |
1132 | 0 | self->GetReferrer(result); |
1133 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1134 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1135 | 0 | return false; |
1136 | 0 | } |
1137 | 0 | return true; |
1138 | 0 | } |
1139 | | |
1140 | | static const JSJitInfo referrer_getterinfo = { |
1141 | | { (JSJitGetterOp)get_referrer }, |
1142 | | { prototypes::id::Request }, |
1143 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1144 | | JSJitInfo::Getter, |
1145 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1146 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1147 | | false, /* isInfallible. False in setters. */ |
1148 | | false, /* isMovable. Not relevant for setters. */ |
1149 | | false, /* isEliminatable. Not relevant for setters. */ |
1150 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1151 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1152 | | false, /* isTypedMethod. Only relevant for methods. */ |
1153 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1154 | | }; |
1155 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1156 | | static_assert(0 < 1, "There is no slot for us"); |
1157 | | |
1158 | | MOZ_CAN_RUN_SCRIPT static bool |
1159 | | get_referrerPolicy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1160 | 0 | { |
1161 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.referrerPolicy", DOM, cx); |
1162 | 0 |
|
1163 | 0 | ReferrerPolicy result(self->ReferrerPolicy_()); |
1164 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1165 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1166 | 0 | return false; |
1167 | 0 | } |
1168 | 0 | return true; |
1169 | 0 | } |
1170 | | |
1171 | | static const JSJitInfo referrerPolicy_getterinfo = { |
1172 | | { (JSJitGetterOp)get_referrerPolicy }, |
1173 | | { prototypes::id::Request }, |
1174 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1175 | | JSJitInfo::Getter, |
1176 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1177 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1178 | | false, /* isInfallible. False in setters. */ |
1179 | | false, /* isMovable. Not relevant for setters. */ |
1180 | | false, /* isEliminatable. Not relevant for setters. */ |
1181 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1182 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1183 | | false, /* isTypedMethod. Only relevant for methods. */ |
1184 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1185 | | }; |
1186 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1187 | | static_assert(0 < 1, "There is no slot for us"); |
1188 | | |
1189 | | MOZ_CAN_RUN_SCRIPT static bool |
1190 | | get_mode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1191 | 0 | { |
1192 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.mode", DOM, cx); |
1193 | 0 |
|
1194 | 0 | RequestMode result(self->Mode()); |
1195 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1196 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1197 | 0 | return false; |
1198 | 0 | } |
1199 | 0 | return true; |
1200 | 0 | } |
1201 | | |
1202 | | static const JSJitInfo mode_getterinfo = { |
1203 | | { (JSJitGetterOp)get_mode }, |
1204 | | { prototypes::id::Request }, |
1205 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1206 | | JSJitInfo::Getter, |
1207 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1208 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1209 | | false, /* isInfallible. False in setters. */ |
1210 | | false, /* isMovable. Not relevant for setters. */ |
1211 | | false, /* isEliminatable. Not relevant for setters. */ |
1212 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1213 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1214 | | false, /* isTypedMethod. Only relevant for methods. */ |
1215 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1216 | | }; |
1217 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1218 | | static_assert(0 < 1, "There is no slot for us"); |
1219 | | |
1220 | | MOZ_CAN_RUN_SCRIPT static bool |
1221 | | get_credentials(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1222 | 0 | { |
1223 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.credentials", DOM, cx); |
1224 | 0 |
|
1225 | 0 | RequestCredentials result(self->Credentials()); |
1226 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1227 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1228 | 0 | return false; |
1229 | 0 | } |
1230 | 0 | return true; |
1231 | 0 | } |
1232 | | |
1233 | | static const JSJitInfo credentials_getterinfo = { |
1234 | | { (JSJitGetterOp)get_credentials }, |
1235 | | { prototypes::id::Request }, |
1236 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1237 | | JSJitInfo::Getter, |
1238 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1239 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1240 | | false, /* isInfallible. False in setters. */ |
1241 | | false, /* isMovable. Not relevant for setters. */ |
1242 | | false, /* isEliminatable. Not relevant for setters. */ |
1243 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1244 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1245 | | false, /* isTypedMethod. Only relevant for methods. */ |
1246 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1247 | | }; |
1248 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1249 | | static_assert(0 < 1, "There is no slot for us"); |
1250 | | |
1251 | | MOZ_CAN_RUN_SCRIPT static bool |
1252 | | get_cache(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1253 | 0 | { |
1254 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.cache", DOM, cx); |
1255 | 0 |
|
1256 | 0 | RequestCache result(self->Cache()); |
1257 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1258 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1259 | 0 | return false; |
1260 | 0 | } |
1261 | 0 | return true; |
1262 | 0 | } |
1263 | | |
1264 | | static const JSJitInfo cache_getterinfo = { |
1265 | | { (JSJitGetterOp)get_cache }, |
1266 | | { prototypes::id::Request }, |
1267 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1268 | | JSJitInfo::Getter, |
1269 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1270 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1271 | | false, /* isInfallible. False in setters. */ |
1272 | | false, /* isMovable. Not relevant for setters. */ |
1273 | | false, /* isEliminatable. Not relevant for setters. */ |
1274 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1275 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1276 | | false, /* isTypedMethod. Only relevant for methods. */ |
1277 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1278 | | }; |
1279 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1280 | | static_assert(0 < 1, "There is no slot for us"); |
1281 | | |
1282 | | MOZ_CAN_RUN_SCRIPT static bool |
1283 | | get_redirect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1284 | 0 | { |
1285 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.redirect", DOM, cx); |
1286 | 0 |
|
1287 | 0 | RequestRedirect result(self->Redirect()); |
1288 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1289 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1290 | 0 | return false; |
1291 | 0 | } |
1292 | 0 | return true; |
1293 | 0 | } |
1294 | | |
1295 | | static const JSJitInfo redirect_getterinfo = { |
1296 | | { (JSJitGetterOp)get_redirect }, |
1297 | | { prototypes::id::Request }, |
1298 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1299 | | JSJitInfo::Getter, |
1300 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1301 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1302 | | false, /* isInfallible. False in setters. */ |
1303 | | false, /* isMovable. Not relevant for setters. */ |
1304 | | false, /* isEliminatable. Not relevant for setters. */ |
1305 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1306 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1307 | | false, /* isTypedMethod. Only relevant for methods. */ |
1308 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1309 | | }; |
1310 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1311 | | static_assert(0 < 1, "There is no slot for us"); |
1312 | | |
1313 | | MOZ_CAN_RUN_SCRIPT static bool |
1314 | | get_integrity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1315 | 0 | { |
1316 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.integrity", DOM, cx); |
1317 | 0 |
|
1318 | 0 | DOMString result; |
1319 | 0 | self->GetIntegrity(result); |
1320 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1321 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1322 | 0 | return false; |
1323 | 0 | } |
1324 | 0 | return true; |
1325 | 0 | } |
1326 | | |
1327 | | static const JSJitInfo integrity_getterinfo = { |
1328 | | { (JSJitGetterOp)get_integrity }, |
1329 | | { prototypes::id::Request }, |
1330 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1331 | | JSJitInfo::Getter, |
1332 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1333 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1334 | | false, /* isInfallible. False in setters. */ |
1335 | | false, /* isMovable. Not relevant for setters. */ |
1336 | | false, /* isEliminatable. Not relevant for setters. */ |
1337 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1338 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1339 | | false, /* isTypedMethod. Only relevant for methods. */ |
1340 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1341 | | }; |
1342 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1343 | | static_assert(0 < 1, "There is no slot for us"); |
1344 | | |
1345 | | MOZ_CAN_RUN_SCRIPT static bool |
1346 | | get_mozErrors(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1347 | 0 | { |
1348 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.mozErrors", DOM, cx); |
1349 | 0 |
|
1350 | 0 | bool result(self->MozErrors()); |
1351 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1352 | 0 | args.rval().setBoolean(result); |
1353 | 0 | return true; |
1354 | 0 | } |
1355 | | |
1356 | | static const JSJitInfo mozErrors_getterinfo = { |
1357 | | { (JSJitGetterOp)get_mozErrors }, |
1358 | | { prototypes::id::Request }, |
1359 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1360 | | JSJitInfo::Getter, |
1361 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1362 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1363 | | true, /* isInfallible. False in setters. */ |
1364 | | false, /* isMovable. Not relevant for setters. */ |
1365 | | false, /* isEliminatable. Not relevant for setters. */ |
1366 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1367 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1368 | | false, /* isTypedMethod. Only relevant for methods. */ |
1369 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1370 | | }; |
1371 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1372 | | static_assert(0 < 1, "There is no slot for us"); |
1373 | | |
1374 | | MOZ_CAN_RUN_SCRIPT static bool |
1375 | | get_signal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1376 | 0 | { |
1377 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.signal", DOM, cx); |
1378 | 0 |
|
1379 | 0 | auto result(StrongOrRawPtr<mozilla::dom::AbortSignal>(self->GetOrCreateSignal())); |
1380 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1381 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1382 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1383 | 0 | return false; |
1384 | 0 | } |
1385 | 0 | return true; |
1386 | 0 | } |
1387 | | |
1388 | | static const JSJitInfo signal_getterinfo = { |
1389 | | { (JSJitGetterOp)get_signal }, |
1390 | | { prototypes::id::Request }, |
1391 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1392 | | JSJitInfo::Getter, |
1393 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1394 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1395 | | false, /* isInfallible. False in setters. */ |
1396 | | false, /* isMovable. Not relevant for setters. */ |
1397 | | false, /* isEliminatable. Not relevant for setters. */ |
1398 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1399 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1400 | | false, /* isTypedMethod. Only relevant for methods. */ |
1401 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1402 | | }; |
1403 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1404 | | static_assert(0 < 1, "There is no slot for us"); |
1405 | | |
1406 | | MOZ_CAN_RUN_SCRIPT static bool |
1407 | | clone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1408 | 0 | { |
1409 | 0 | AUTO_PROFILER_LABEL_FAST("Request.clone", DOM, cx); |
1410 | 0 |
|
1411 | 0 | FastErrorResult rv; |
1412 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Request>(self->Clone(rv))); |
1413 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1414 | 0 | return false; |
1415 | 0 | } |
1416 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1417 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1418 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1419 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1420 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1421 | 0 | return false; |
1422 | 0 | } |
1423 | 0 | return true; |
1424 | 0 | } |
1425 | | |
1426 | | static const JSJitInfo clone_methodinfo = { |
1427 | | { (JSJitGetterOp)clone }, |
1428 | | { prototypes::id::Request }, |
1429 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1430 | | JSJitInfo::Method, |
1431 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1432 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1433 | | false, /* isInfallible. False in setters. */ |
1434 | | false, /* isMovable. Not relevant for setters. */ |
1435 | | false, /* isEliminatable. Not relevant for setters. */ |
1436 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1437 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1438 | | false, /* isTypedMethod. Only relevant for methods. */ |
1439 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1440 | | }; |
1441 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1442 | | static_assert(0 < 1, "There is no slot for us"); |
1443 | | |
1444 | | MOZ_CAN_RUN_SCRIPT static bool |
1445 | | overrideContentPolicyType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1446 | 0 | { |
1447 | 0 | AUTO_PROFILER_LABEL_FAST("Request.overrideContentPolicyType", DOM, cx); |
1448 | 0 |
|
1449 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1450 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Request.overrideContentPolicyType"); |
1451 | 0 | } |
1452 | 0 | uint32_t arg0; |
1453 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
1454 | 0 | return false; |
1455 | 0 | } |
1456 | 0 | self->OverrideContentPolicyType(arg0); |
1457 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1458 | 0 | args.rval().setUndefined(); |
1459 | 0 | return true; |
1460 | 0 | } |
1461 | | |
1462 | | static const JSJitInfo overrideContentPolicyType_methodinfo = { |
1463 | | { (JSJitGetterOp)overrideContentPolicyType }, |
1464 | | { prototypes::id::Request }, |
1465 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1466 | | JSJitInfo::Method, |
1467 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1468 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1469 | | false, /* isInfallible. False in setters. */ |
1470 | | false, /* isMovable. Not relevant for setters. */ |
1471 | | false, /* isEliminatable. Not relevant for setters. */ |
1472 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1473 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1474 | | false, /* isTypedMethod. Only relevant for methods. */ |
1475 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1476 | | }; |
1477 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1478 | | static_assert(0 < 1, "There is no slot for us"); |
1479 | | |
1480 | | MOZ_CAN_RUN_SCRIPT static bool |
1481 | | get_bodyUsed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args) |
1482 | 0 | { |
1483 | 0 | AUTO_PROFILER_LABEL_FAST("get Request.bodyUsed", DOM, cx); |
1484 | 0 |
|
1485 | 0 | bool result(self->BodyUsed()); |
1486 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1487 | 0 | args.rval().setBoolean(result); |
1488 | 0 | return true; |
1489 | 0 | } |
1490 | | |
1491 | | static const JSJitInfo bodyUsed_getterinfo = { |
1492 | | { (JSJitGetterOp)get_bodyUsed }, |
1493 | | { prototypes::id::Request }, |
1494 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1495 | | JSJitInfo::Getter, |
1496 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1497 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1498 | | true, /* isInfallible. False in setters. */ |
1499 | | false, /* isMovable. Not relevant for setters. */ |
1500 | | false, /* isEliminatable. Not relevant for setters. */ |
1501 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1502 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1503 | | false, /* isTypedMethod. Only relevant for methods. */ |
1504 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1505 | | }; |
1506 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1507 | | static_assert(0 < 1, "There is no slot for us"); |
1508 | | |
1509 | | MOZ_CAN_RUN_SCRIPT static bool |
1510 | | arrayBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1511 | 0 | { |
1512 | 0 | AUTO_PROFILER_LABEL_FAST("Request.arrayBuffer", DOM, cx); |
1513 | 0 |
|
1514 | 0 | FastErrorResult rv; |
1515 | 0 | auto result(StrongOrRawPtr<Promise>(self->ArrayBuffer(cx, rv))); |
1516 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1517 | 0 | return false; |
1518 | 0 | } |
1519 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1520 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1521 | 0 | return false; |
1522 | 0 | } |
1523 | 0 | return true; |
1524 | 0 | } |
1525 | | |
1526 | | MOZ_CAN_RUN_SCRIPT static bool |
1527 | | arrayBuffer_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1528 | 0 | { |
1529 | 0 | bool ok = arrayBuffer(cx, obj, self, args); |
1530 | 0 | if (ok) { |
1531 | 0 | return true; |
1532 | 0 | } |
1533 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
1534 | 0 | } |
1535 | | |
1536 | | static const JSJitInfo arrayBuffer_methodinfo = { |
1537 | | { (JSJitGetterOp)arrayBuffer_promiseWrapper }, |
1538 | | { prototypes::id::Request }, |
1539 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1540 | | JSJitInfo::Method, |
1541 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1542 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1543 | | false, /* isInfallible. False in setters. */ |
1544 | | false, /* isMovable. Not relevant for setters. */ |
1545 | | false, /* isEliminatable. Not relevant for setters. */ |
1546 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1547 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1548 | | false, /* isTypedMethod. Only relevant for methods. */ |
1549 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1550 | | }; |
1551 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1552 | | static_assert(0 < 1, "There is no slot for us"); |
1553 | | |
1554 | | MOZ_CAN_RUN_SCRIPT static bool |
1555 | | blob(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1556 | 0 | { |
1557 | 0 | AUTO_PROFILER_LABEL_FAST("Request.blob", DOM, cx); |
1558 | 0 |
|
1559 | 0 | FastErrorResult rv; |
1560 | 0 | auto result(StrongOrRawPtr<Promise>(self->Blob(cx, rv))); |
1561 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1562 | 0 | return false; |
1563 | 0 | } |
1564 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1565 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1566 | 0 | return false; |
1567 | 0 | } |
1568 | 0 | return true; |
1569 | 0 | } |
1570 | | |
1571 | | MOZ_CAN_RUN_SCRIPT static bool |
1572 | | blob_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1573 | 0 | { |
1574 | 0 | bool ok = blob(cx, obj, self, args); |
1575 | 0 | if (ok) { |
1576 | 0 | return true; |
1577 | 0 | } |
1578 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
1579 | 0 | } |
1580 | | |
1581 | | static const JSJitInfo blob_methodinfo = { |
1582 | | { (JSJitGetterOp)blob_promiseWrapper }, |
1583 | | { prototypes::id::Request }, |
1584 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1585 | | JSJitInfo::Method, |
1586 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1587 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1588 | | false, /* isInfallible. False in setters. */ |
1589 | | false, /* isMovable. Not relevant for setters. */ |
1590 | | false, /* isEliminatable. Not relevant for setters. */ |
1591 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1592 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1593 | | false, /* isTypedMethod. Only relevant for methods. */ |
1594 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1595 | | }; |
1596 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1597 | | static_assert(0 < 1, "There is no slot for us"); |
1598 | | |
1599 | | MOZ_CAN_RUN_SCRIPT static bool |
1600 | | formData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1601 | 0 | { |
1602 | 0 | AUTO_PROFILER_LABEL_FAST("Request.formData", DOM, cx); |
1603 | 0 |
|
1604 | 0 | FastErrorResult rv; |
1605 | 0 | auto result(StrongOrRawPtr<Promise>(self->FormData(cx, rv))); |
1606 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1607 | 0 | return false; |
1608 | 0 | } |
1609 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1610 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1611 | 0 | return false; |
1612 | 0 | } |
1613 | 0 | return true; |
1614 | 0 | } |
1615 | | |
1616 | | MOZ_CAN_RUN_SCRIPT static bool |
1617 | | formData_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1618 | 0 | { |
1619 | 0 | bool ok = formData(cx, obj, self, args); |
1620 | 0 | if (ok) { |
1621 | 0 | return true; |
1622 | 0 | } |
1623 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
1624 | 0 | } |
1625 | | |
1626 | | static const JSJitInfo formData_methodinfo = { |
1627 | | { (JSJitGetterOp)formData_promiseWrapper }, |
1628 | | { prototypes::id::Request }, |
1629 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1630 | | JSJitInfo::Method, |
1631 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1632 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1633 | | false, /* isInfallible. False in setters. */ |
1634 | | false, /* isMovable. Not relevant for setters. */ |
1635 | | false, /* isEliminatable. Not relevant for setters. */ |
1636 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1637 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1638 | | false, /* isTypedMethod. Only relevant for methods. */ |
1639 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1640 | | }; |
1641 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1642 | | static_assert(0 < 1, "There is no slot for us"); |
1643 | | |
1644 | | MOZ_CAN_RUN_SCRIPT static bool |
1645 | | json(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1646 | 0 | { |
1647 | 0 | AUTO_PROFILER_LABEL_FAST("Request.json", DOM, cx); |
1648 | 0 |
|
1649 | 0 | FastErrorResult rv; |
1650 | 0 | auto result(StrongOrRawPtr<Promise>(self->Json(cx, rv))); |
1651 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1652 | 0 | return false; |
1653 | 0 | } |
1654 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1655 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1656 | 0 | return false; |
1657 | 0 | } |
1658 | 0 | return true; |
1659 | 0 | } |
1660 | | |
1661 | | MOZ_CAN_RUN_SCRIPT static bool |
1662 | | json_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1663 | 0 | { |
1664 | 0 | bool ok = json(cx, obj, self, args); |
1665 | 0 | if (ok) { |
1666 | 0 | return true; |
1667 | 0 | } |
1668 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
1669 | 0 | } |
1670 | | |
1671 | | static const JSJitInfo json_methodinfo = { |
1672 | | { (JSJitGetterOp)json_promiseWrapper }, |
1673 | | { prototypes::id::Request }, |
1674 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1675 | | JSJitInfo::Method, |
1676 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1677 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1678 | | false, /* isInfallible. False in setters. */ |
1679 | | false, /* isMovable. Not relevant for setters. */ |
1680 | | false, /* isEliminatable. Not relevant for setters. */ |
1681 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1682 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1683 | | false, /* isTypedMethod. Only relevant for methods. */ |
1684 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1685 | | }; |
1686 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1687 | | static_assert(0 < 1, "There is no slot for us"); |
1688 | | |
1689 | | MOZ_CAN_RUN_SCRIPT static bool |
1690 | | text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1691 | 0 | { |
1692 | 0 | AUTO_PROFILER_LABEL_FAST("Request.text", DOM, cx); |
1693 | 0 |
|
1694 | 0 | FastErrorResult rv; |
1695 | 0 | auto result(StrongOrRawPtr<Promise>(self->Text(cx, rv))); |
1696 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1697 | 0 | return false; |
1698 | 0 | } |
1699 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1700 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1701 | 0 | return false; |
1702 | 0 | } |
1703 | 0 | return true; |
1704 | 0 | } |
1705 | | |
1706 | | MOZ_CAN_RUN_SCRIPT static bool |
1707 | | text_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args) |
1708 | 0 | { |
1709 | 0 | bool ok = text(cx, obj, self, args); |
1710 | 0 | if (ok) { |
1711 | 0 | return true; |
1712 | 0 | } |
1713 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
1714 | 0 | } |
1715 | | |
1716 | | static const JSJitInfo text_methodinfo = { |
1717 | | { (JSJitGetterOp)text_promiseWrapper }, |
1718 | | { prototypes::id::Request }, |
1719 | | { PrototypeTraits<prototypes::id::Request>::Depth }, |
1720 | | JSJitInfo::Method, |
1721 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1722 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1723 | | false, /* isInfallible. False in setters. */ |
1724 | | false, /* isMovable. Not relevant for setters. */ |
1725 | | false, /* isEliminatable. Not relevant for setters. */ |
1726 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1727 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1728 | | false, /* isTypedMethod. Only relevant for methods. */ |
1729 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1730 | | }; |
1731 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1732 | | static_assert(0 < 1, "There is no slot for us"); |
1733 | | |
1734 | | static bool |
1735 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1736 | 0 | { |
1737 | 0 | mozilla::dom::Request* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Request>(obj); |
1738 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1739 | 0 | // obviously can't preserve if we're not initialized. |
1740 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1741 | 0 | PreserveWrapper(self); |
1742 | 0 | } |
1743 | 0 | return true; |
1744 | 0 | } |
1745 | | |
1746 | | static void |
1747 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1748 | 0 | { |
1749 | 0 | mozilla::dom::Request* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Request>(obj); |
1750 | 0 | if (self) { |
1751 | 0 | ClearWrapper(self, self, obj); |
1752 | 0 | AddForDeferredFinalization<mozilla::dom::Request>(self); |
1753 | 0 | } |
1754 | 0 | } |
1755 | | |
1756 | | static size_t |
1757 | | _objectMoved(JSObject* obj, JSObject* old) |
1758 | 0 | { |
1759 | 0 | mozilla::dom::Request* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Request>(obj); |
1760 | 0 | if (self) { |
1761 | 0 | UpdateWrapper(self, self, obj, old); |
1762 | 0 | } |
1763 | 0 |
|
1764 | 0 | return 0; |
1765 | 0 | } |
1766 | | |
1767 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1768 | | #if defined(__clang__) |
1769 | | #pragma clang diagnostic push |
1770 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1771 | | #endif |
1772 | | static const JSFunctionSpec sMethods_specs[] = { |
1773 | | JS_FNSPEC("clone", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clone_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1774 | | JS_FNSPEC("arrayBuffer", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&arrayBuffer_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1775 | | JS_FNSPEC("blob", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&blob_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1776 | | JS_FNSPEC("formData", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&formData_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1777 | | JS_FNSPEC("json", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&json_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1778 | | JS_FNSPEC("text", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&text_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1779 | | JS_FS_END |
1780 | | }; |
1781 | | #if defined(__clang__) |
1782 | | #pragma clang diagnostic pop |
1783 | | #endif |
1784 | | |
1785 | | |
1786 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1787 | | { nullptr, &sMethods_specs[0] }, |
1788 | | { nullptr, nullptr } |
1789 | | }; |
1790 | | |
1791 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1792 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1793 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1794 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1795 | | |
1796 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1797 | | #if defined(__clang__) |
1798 | | #pragma clang diagnostic push |
1799 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1800 | | #endif |
1801 | | static const JSFunctionSpec sChromeMethods_specs[] = { |
1802 | | JS_FNSPEC("overrideContentPolicyType", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&overrideContentPolicyType_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1803 | | JS_FS_END |
1804 | | }; |
1805 | | #if defined(__clang__) |
1806 | | #pragma clang diagnostic pop |
1807 | | #endif |
1808 | | |
1809 | | |
1810 | | static const Prefable<const JSFunctionSpec> sChromeMethods[] = { |
1811 | | { nullptr, &sChromeMethods_specs[0] }, |
1812 | | { nullptr, nullptr } |
1813 | | }; |
1814 | | |
1815 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1816 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1817 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1818 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1819 | | |
1820 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1821 | | #if defined(__clang__) |
1822 | | #pragma clang diagnostic push |
1823 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1824 | | #endif |
1825 | | static const JSPropertySpec sAttributes_specs[] = { |
1826 | | { "method", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &method_getterinfo, nullptr, nullptr }, |
1827 | | { "url", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &url_getterinfo, nullptr, nullptr }, |
1828 | | { "headers", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &headers_getterinfo, nullptr, nullptr }, |
1829 | | { "destination", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &destination_getterinfo, nullptr, nullptr }, |
1830 | | { "referrer", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &referrer_getterinfo, nullptr, nullptr }, |
1831 | | { "referrerPolicy", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &referrerPolicy_getterinfo, nullptr, nullptr }, |
1832 | | { "mode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mode_getterinfo, nullptr, nullptr }, |
1833 | | { "credentials", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &credentials_getterinfo, nullptr, nullptr }, |
1834 | | { "cache", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &cache_getterinfo, nullptr, nullptr }, |
1835 | | { "redirect", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &redirect_getterinfo, nullptr, nullptr }, |
1836 | | { "integrity", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &integrity_getterinfo, nullptr, nullptr }, |
1837 | | { "signal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &signal_getterinfo, nullptr, nullptr }, |
1838 | | { "bodyUsed", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &bodyUsed_getterinfo, nullptr, nullptr }, |
1839 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1840 | | }; |
1841 | | #if defined(__clang__) |
1842 | | #pragma clang diagnostic pop |
1843 | | #endif |
1844 | | |
1845 | | |
1846 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1847 | | { nullptr, &sAttributes_specs[0] }, |
1848 | | { nullptr, nullptr } |
1849 | | }; |
1850 | | |
1851 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1852 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1853 | | static_assert(13 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1854 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1855 | | |
1856 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1857 | | #if defined(__clang__) |
1858 | | #pragma clang diagnostic push |
1859 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1860 | | #endif |
1861 | | static const JSPropertySpec sChromeAttributes_specs[] = { |
1862 | | { "mozErrors", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozErrors_getterinfo, nullptr, nullptr }, |
1863 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1864 | | }; |
1865 | | #if defined(__clang__) |
1866 | | #pragma clang diagnostic pop |
1867 | | #endif |
1868 | | |
1869 | | |
1870 | | static const Prefable<const JSPropertySpec> sChromeAttributes[] = { |
1871 | | { nullptr, &sChromeAttributes_specs[0] }, |
1872 | | { nullptr, nullptr } |
1873 | | }; |
1874 | | |
1875 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1876 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1877 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1878 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1879 | | |
1880 | | |
1881 | | static uint16_t sNativeProperties_sortedPropertyIndices[19]; |
1882 | | static PropertyInfo sNativeProperties_propertyInfos[19]; |
1883 | | |
1884 | | static const NativePropertiesN<2> sNativeProperties = { |
1885 | | false, 0, |
1886 | | false, 0, |
1887 | | true, 0 /* sMethods */, |
1888 | | true, 1 /* sAttributes */, |
1889 | | false, 0, |
1890 | | false, 0, |
1891 | | false, 0, |
1892 | | -1, |
1893 | | 19, |
1894 | | sNativeProperties_sortedPropertyIndices, |
1895 | | { |
1896 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1897 | | { sAttributes, &sNativeProperties_propertyInfos[6] } |
1898 | | } |
1899 | | }; |
1900 | | static_assert(19 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1901 | | "We have a property info count that is oversized"); |
1902 | | |
1903 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2]; |
1904 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2]; |
1905 | | |
1906 | | static const NativePropertiesN<2> sChromeOnlyNativeProperties = { |
1907 | | false, 0, |
1908 | | false, 0, |
1909 | | true, 0 /* sChromeMethods */, |
1910 | | true, 1 /* sChromeAttributes */, |
1911 | | false, 0, |
1912 | | false, 0, |
1913 | | false, 0, |
1914 | | -1, |
1915 | | 2, |
1916 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
1917 | | { |
1918 | | { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }, |
1919 | | { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[1] } |
1920 | | } |
1921 | | }; |
1922 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
1923 | | "We have a property info count that is oversized"); |
1924 | | |
1925 | | static bool |
1926 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
1927 | 0 | { |
1928 | 0 | AUTO_PROFILER_LABEL_FAST("Request constructor", DOM, cx); |
1929 | 0 |
|
1930 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
1931 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
1932 | 0 | if (!args.isConstructing()) { |
1933 | 0 | // XXXbz wish I could get the name from the callee instead of |
1934 | 0 | // Adding more relocations |
1935 | 0 | return ThrowConstructorWithoutNew(cx, "Request"); |
1936 | 0 | } |
1937 | 0 | |
1938 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
1939 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
1940 | 0 | return false; |
1941 | 0 | } |
1942 | 0 | |
1943 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1944 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Request"); |
1945 | 0 | } |
1946 | 0 | GlobalObject global(cx, obj); |
1947 | 0 | if (global.Failed()) { |
1948 | 0 | return false; |
1949 | 0 | } |
1950 | 0 | |
1951 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1952 | 0 | RequestOrUSVString arg0; |
1953 | 0 | RequestOrUSVStringArgument arg0_holder(arg0); |
1954 | 0 | { |
1955 | 0 | bool done = false, failed = false, tryNext; |
1956 | 0 | if (args[0].isObject()) { |
1957 | 0 | done = (failed = !arg0_holder.TrySetToRequest(cx, args[0], tryNext, false)) || !tryNext; |
1958 | 0 |
|
1959 | 0 | } |
1960 | 0 | if (!done) { |
1961 | 0 | do { |
1962 | 0 | done = (failed = !arg0_holder.TrySetToUSVString(cx, args[0], tryNext)) || !tryNext; |
1963 | 0 | break; |
1964 | 0 | } while (false); |
1965 | 0 | } |
1966 | 0 | if (failed) { |
1967 | 0 | return false; |
1968 | 0 | } |
1969 | 0 | if (!done) { |
1970 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Request.constructor", "Request"); |
1971 | 0 | return false; |
1972 | 0 | } |
1973 | 0 | } |
1974 | 0 | RootedDictionary<binding_detail::FastRequestInit> arg1(cx); |
1975 | 0 | if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of Request.constructor", false)) { |
1976 | 0 | return false; |
1977 | 0 | } |
1978 | 0 | Maybe<JSAutoRealm> ar; |
1979 | 0 | if (objIsXray) { |
1980 | 0 | obj = js::CheckedUnwrap(obj); |
1981 | 0 | if (!obj) { |
1982 | 0 | return false; |
1983 | 0 | } |
1984 | 0 | ar.emplace(cx, obj); |
1985 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1986 | 0 | return false; |
1987 | 0 | } |
1988 | 0 | if (arg1.mBody.WasPassed()) { |
1989 | 0 | if (arg1.mBody.Value().Value().IsArrayBufferView()) { |
1990 | 0 | if (!arg1.mBody.Value().Value().GetAsArrayBufferView().WrapIntoNewCompartment(cx)) { |
1991 | 0 | return false; |
1992 | 0 | } |
1993 | 0 | } |
1994 | 0 | else if (arg1.mBody.Value().Value().IsArrayBuffer()) { |
1995 | 0 | if (!arg1.mBody.Value().Value().GetAsArrayBuffer().WrapIntoNewCompartment(cx)) { |
1996 | 0 | return false; |
1997 | 0 | } |
1998 | 0 | } |
1999 | 0 | } |
2000 | 0 | } |
2001 | 0 | FastErrorResult rv; |
2002 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Request>(mozilla::dom::Request::Constructor(global, Constify(arg0), Constify(arg1), rv))); |
2003 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
2004 | 0 | return false; |
2005 | 0 | } |
2006 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2007 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
2008 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
2009 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
2010 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2011 | 0 | return false; |
2012 | 0 | } |
2013 | 0 | return true; |
2014 | 0 | } |
2015 | | |
2016 | | static const js::ClassOps sInterfaceObjectClassOps = { |
2017 | | nullptr, /* addProperty */ |
2018 | | nullptr, /* delProperty */ |
2019 | | nullptr, /* enumerate */ |
2020 | | nullptr, /* newEnumerate */ |
2021 | | nullptr, /* resolve */ |
2022 | | nullptr, /* mayResolve */ |
2023 | | nullptr, /* finalize */ |
2024 | | _constructor, /* call */ |
2025 | | nullptr, /* hasInstance */ |
2026 | | _constructor, /* construct */ |
2027 | | nullptr, /* trace */ |
2028 | | }; |
2029 | | |
2030 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
2031 | | { |
2032 | | "Function", |
2033 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
2034 | | &sInterfaceObjectClassOps, |
2035 | | JS_NULL_CLASS_SPEC, |
2036 | | JS_NULL_CLASS_EXT, |
2037 | | &sInterfaceObjectClassObjectOps |
2038 | | }, |
2039 | | eInterface, |
2040 | | true, |
2041 | | prototypes::id::Request, |
2042 | | PrototypeTraits<prototypes::id::Request>::Depth, |
2043 | | sNativePropertyHooks, |
2044 | | "function Request() {\n [native code]\n}", |
2045 | | JS::GetRealmFunctionPrototype |
2046 | | }; |
2047 | | |
2048 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
2049 | | { |
2050 | | "RequestPrototype", |
2051 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
2052 | | JS_NULL_CLASS_OPS, |
2053 | | JS_NULL_CLASS_SPEC, |
2054 | | JS_NULL_CLASS_EXT, |
2055 | | JS_NULL_OBJECT_OPS |
2056 | | }, |
2057 | | eInterfacePrototype, |
2058 | | false, |
2059 | | prototypes::id::Request, |
2060 | | PrototypeTraits<prototypes::id::Request>::Depth, |
2061 | | sNativePropertyHooks, |
2062 | | "[object RequestPrototype]", |
2063 | | JS::GetRealmObjectPrototype |
2064 | | }; |
2065 | | |
2066 | | static const js::ClassOps sClassOps = { |
2067 | | _addProperty, /* addProperty */ |
2068 | | nullptr, /* delProperty */ |
2069 | | nullptr, /* enumerate */ |
2070 | | nullptr, /* newEnumerate */ |
2071 | | nullptr, /* resolve */ |
2072 | | nullptr, /* mayResolve */ |
2073 | | _finalize, /* finalize */ |
2074 | | nullptr, /* call */ |
2075 | | nullptr, /* hasInstance */ |
2076 | | nullptr, /* construct */ |
2077 | | nullptr, /* trace */ |
2078 | | }; |
2079 | | |
2080 | | static const js::ClassExtension sClassExtension = { |
2081 | | nullptr, /* weakmapKeyDelegateOp */ |
2082 | | _objectMoved /* objectMovedOp */ |
2083 | | }; |
2084 | | |
2085 | | static const DOMJSClass sClass = { |
2086 | | { "Request", |
2087 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
2088 | | &sClassOps, |
2089 | | JS_NULL_CLASS_SPEC, |
2090 | | &sClassExtension, |
2091 | | JS_NULL_OBJECT_OPS |
2092 | | }, |
2093 | | { prototypes::id::Request, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
2094 | | IsBaseOf<nsISupports, mozilla::dom::Request >::value, |
2095 | | sNativePropertyHooks, |
2096 | | FindAssociatedGlobalForNative<mozilla::dom::Request>::Get, |
2097 | | GetProtoObjectHandle, |
2098 | | GetCCParticipant<mozilla::dom::Request>::Get() |
2099 | | }; |
2100 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
2101 | | "Must have the right minimal number of reserved slots."); |
2102 | | static_assert(1 >= 1, |
2103 | | "Must have enough reserved slots."); |
2104 | | |
2105 | | const JSClass* |
2106 | | GetJSClass() |
2107 | 0 | { |
2108 | 0 | return sClass.ToJSClass(); |
2109 | 0 | } |
2110 | | |
2111 | | bool |
2112 | | Wrap(JSContext* aCx, mozilla::dom::Request* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
2113 | 0 | { |
2114 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::Request>::value, |
2115 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
2116 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Request*>(aObject) == |
2117 | 0 | reinterpret_cast<mozilla::dom::Request*>(aObject), |
2118 | 0 | "Multiple inheritance for mozilla::dom::Request is broken."); |
2119 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
2120 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
2121 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
2122 | 0 | "You should probably not be using Wrap() directly; use " |
2123 | 0 | "GetOrCreateDOMReflector instead"); |
2124 | 0 |
|
2125 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
2126 | 0 | "nsISupports must be on our primary inheritance chain"); |
2127 | 0 |
|
2128 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
2129 | 0 | if (!global) { |
2130 | 0 | return false; |
2131 | 0 | } |
2132 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
2133 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
2134 | 0 |
|
2135 | 0 | // That might have ended up wrapping us already, due to the wonders |
2136 | 0 | // of XBL. Check for that, and bail out as needed. |
2137 | 0 | aReflector.set(aCache->GetWrapper()); |
2138 | 0 | if (aReflector) { |
2139 | | #ifdef DEBUG |
2140 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
2141 | | #endif // DEBUG |
2142 | | return true; |
2143 | 0 | } |
2144 | 0 |
|
2145 | 0 | JSAutoRealm ar(aCx, global); |
2146 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
2147 | 0 | if (!canonicalProto) { |
2148 | 0 | return false; |
2149 | 0 | } |
2150 | 0 | JS::Rooted<JSObject*> proto(aCx); |
2151 | 0 | if (aGivenProto) { |
2152 | 0 | proto = aGivenProto; |
2153 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
2154 | 0 | // coming in, we changed compartments to that of "parent" so may need |
2155 | 0 | // to wrap the proto here. |
2156 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
2157 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
2158 | 0 | return false; |
2159 | 0 | } |
2160 | 0 | } |
2161 | 0 | } else { |
2162 | 0 | proto = canonicalProto; |
2163 | 0 | } |
2164 | 0 |
|
2165 | 0 | BindingJSObjectCreator<mozilla::dom::Request> creator(aCx); |
2166 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
2167 | 0 | if (!aReflector) { |
2168 | 0 | return false; |
2169 | 0 | } |
2170 | 0 | |
2171 | 0 | aCache->SetWrapper(aReflector); |
2172 | 0 | creator.InitializationSucceeded(); |
2173 | 0 |
|
2174 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
2175 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
2176 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
2177 | 0 | // otherwise we won't be able to properly recreate it later, since |
2178 | 0 | // we won't know what proto to use. Note that we don't check |
2179 | 0 | // aGivenProto here, since it's entirely possible (and even |
2180 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
2181 | 0 | // same as canonicalProto. |
2182 | 0 | if (proto != canonicalProto) { |
2183 | 0 | PreserveWrapper(aObject); |
2184 | 0 | } |
2185 | 0 |
|
2186 | 0 | return true; |
2187 | 0 | } |
2188 | | |
2189 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
2190 | | nullptr, |
2191 | | nullptr, |
2192 | | nullptr, |
2193 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
2194 | | prototypes::id::Request, |
2195 | | constructors::id::Request, |
2196 | | nullptr, |
2197 | | &DefaultXrayExpandoObjectClass |
2198 | | } }; |
2199 | | |
2200 | | void |
2201 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
2202 | 0 | { |
2203 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
2204 | 0 | if (!parentProto) { |
2205 | 0 | return; |
2206 | 0 | } |
2207 | 0 | |
2208 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
2209 | 0 | if (!constructorProto) { |
2210 | 0 | return; |
2211 | 0 | } |
2212 | 0 | |
2213 | 0 | static bool sIdsInited = false; |
2214 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
2215 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
2216 | 0 | return; |
2217 | 0 | } |
2218 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
2219 | 0 | return; |
2220 | 0 | } |
2221 | 0 | sIdsInited = true; |
2222 | 0 | } |
2223 | 0 |
|
2224 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Request); |
2225 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Request); |
2226 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
2227 | 0 | &sPrototypeClass.mBase, protoCache, |
2228 | 0 | nullptr, |
2229 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr, |
2230 | 0 | interfaceCache, |
2231 | 0 | sNativeProperties.Upcast(), |
2232 | 0 | sChromeOnlyNativeProperties.Upcast(), |
2233 | 0 | "Request", aDefineOnGlobal, |
2234 | 0 | nullptr, |
2235 | 0 | false); |
2236 | 0 | } |
2237 | | |
2238 | | JSObject* |
2239 | | GetConstructorObject(JSContext* aCx) |
2240 | 0 | { |
2241 | 0 | return GetConstructorObjectHandle(aCx); |
2242 | 0 | } |
2243 | | |
2244 | | } // namespace Request_Binding |
2245 | | |
2246 | | |
2247 | | |
2248 | | } // namespace dom |
2249 | | } // namespace mozilla |