Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM MozSelfSupport.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "MozSelfSupportBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/dom/BindingUtils.h"
8 : #include "mozilla/dom/DOMJSClass.h"
9 : #include "mozilla/dom/NonRefcountedDOMObject.h"
10 : #include "mozilla/dom/PrimitiveConversions.h"
11 : #include "mozilla/dom/Promise.h"
12 : #include "mozilla/dom/ToJSValue.h"
13 : #include "mozilla/dom/XrayExpandoClass.h"
14 : #include "nsContentUtils.h"
15 : #include "nsIGlobalObject.h"
16 :
17 : namespace mozilla {
18 : namespace dom {
19 :
20 : namespace MozSelfSupportBinding {
21 :
22 : static bool
23 0 : get_healthReportDataSubmissionEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, JSJitGetterCallArgs args)
24 : {
25 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
26 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
27 0 : if (objIsXray) {
28 0 : unwrappedObj.emplace(cx, obj);
29 : }
30 0 : if (objIsXray) {
31 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
32 0 : if (!unwrappedObj.ref()) {
33 0 : return false;
34 : }
35 : }
36 0 : binding_detail::FastErrorResult rv;
37 0 : bool result(self->GetHealthReportDataSubmissionEnabled(rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj)));
38 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
39 0 : return false;
40 : }
41 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
42 0 : args.rval().setBoolean(result);
43 0 : return true;
44 : }
45 :
46 : static bool
47 0 : set_healthReportDataSubmissionEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, JSJitSetterCallArgs args)
48 : {
49 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
50 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
51 0 : if (objIsXray) {
52 0 : unwrappedObj.emplace(cx, obj);
53 : }
54 : bool arg0;
55 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
56 0 : return false;
57 : }
58 0 : if (objIsXray) {
59 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
60 0 : if (!unwrappedObj.ref()) {
61 0 : return false;
62 : }
63 : }
64 0 : binding_detail::FastErrorResult rv;
65 0 : self->SetHealthReportDataSubmissionEnabled(arg0, rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj));
66 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
67 0 : return false;
68 : }
69 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
70 :
71 0 : return true;
72 : }
73 :
74 : static const JSJitInfo healthReportDataSubmissionEnabled_getterinfo = {
75 : { (JSJitGetterOp)get_healthReportDataSubmissionEnabled },
76 : { prototypes::id::MozSelfSupport },
77 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
78 : JSJitInfo::Getter,
79 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
80 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
81 : false, /* isInfallible. False in setters. */
82 : false, /* isMovable. Not relevant for setters. */
83 : false, /* isEliminatable. Not relevant for setters. */
84 : false, /* isAlwaysInSlot. Only relevant for getters. */
85 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
86 : false, /* isTypedMethod. Only relevant for methods. */
87 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
88 : };
89 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
90 : static_assert(0 < 1, "There is no slot for us");
91 : static const JSJitInfo healthReportDataSubmissionEnabled_setterinfo = {
92 : { (JSJitGetterOp)set_healthReportDataSubmissionEnabled },
93 : { prototypes::id::MozSelfSupport },
94 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
95 : JSJitInfo::Setter,
96 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
97 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
98 : false, /* isInfallible. False in setters. */
99 : false, /* isMovable. Not relevant for setters. */
100 : false, /* isEliminatable. Not relevant for setters. */
101 : false, /* isAlwaysInSlot. Only relevant for getters. */
102 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
103 : false, /* isTypedMethod. Only relevant for methods. */
104 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
105 : };
106 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
107 : static_assert(0 < 1, "There is no slot for us");
108 :
109 : static bool
110 0 : getTelemetryPingList(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
111 : {
112 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
113 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
114 0 : if (objIsXray) {
115 0 : unwrappedObj.emplace(cx, obj);
116 : }
117 0 : if (objIsXray) {
118 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
119 0 : if (!unwrappedObj.ref()) {
120 0 : return false;
121 : }
122 : }
123 0 : binding_detail::FastErrorResult rv;
124 0 : auto result(StrongOrRawPtr<Promise>(self->GetTelemetryPingList(rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj))));
125 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
126 0 : return false;
127 : }
128 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
129 0 : if (!ToJSValue(cx, result, args.rval())) {
130 0 : return false;
131 : }
132 0 : return true;
133 : }
134 :
135 : static bool
136 0 : getTelemetryPingList_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
137 : {
138 : // Make sure to save the callee before someone maybe messes
139 : // with rval().
140 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
141 0 : bool ok = getTelemetryPingList(cx, obj, self, args);
142 0 : if (ok) {
143 0 : return true;
144 : }
145 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
146 0 : args.rval());
147 : }
148 :
149 : static const JSJitInfo getTelemetryPingList_methodinfo = {
150 : { (JSJitGetterOp)getTelemetryPingList_promiseWrapper },
151 : { prototypes::id::MozSelfSupport },
152 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
153 : JSJitInfo::Method,
154 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
155 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
156 : false, /* isInfallible. False in setters. */
157 : false, /* isMovable. Not relevant for setters. */
158 : false, /* isEliminatable. Not relevant for setters. */
159 : false, /* isAlwaysInSlot. Only relevant for getters. */
160 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
161 : false, /* isTypedMethod. Only relevant for methods. */
162 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
163 : };
164 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
165 : static_assert(0 < 1, "There is no slot for us");
166 :
167 : static bool
168 0 : getTelemetryPing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
169 : {
170 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
171 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MozSelfSupport.getTelemetryPing");
172 : }
173 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
174 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
175 0 : if (objIsXray) {
176 0 : unwrappedObj.emplace(cx, obj);
177 : }
178 0 : binding_detail::FakeString arg0;
179 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
180 0 : return false;
181 : }
182 0 : if (objIsXray) {
183 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
184 0 : if (!unwrappedObj.ref()) {
185 0 : return false;
186 : }
187 : }
188 0 : binding_detail::FastErrorResult rv;
189 0 : auto result(StrongOrRawPtr<Promise>(self->GetTelemetryPing(NonNullHelper(Constify(arg0)), rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj))));
190 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
191 0 : return false;
192 : }
193 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
194 0 : if (!ToJSValue(cx, result, args.rval())) {
195 0 : return false;
196 : }
197 0 : return true;
198 : }
199 :
200 : static bool
201 0 : getTelemetryPing_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
202 : {
203 : // Make sure to save the callee before someone maybe messes
204 : // with rval().
205 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
206 0 : bool ok = getTelemetryPing(cx, obj, self, args);
207 0 : if (ok) {
208 0 : return true;
209 : }
210 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
211 0 : args.rval());
212 : }
213 :
214 : static const JSJitInfo getTelemetryPing_methodinfo = {
215 : { (JSJitGetterOp)getTelemetryPing_promiseWrapper },
216 : { prototypes::id::MozSelfSupport },
217 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
218 : JSJitInfo::Method,
219 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
220 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
221 : false, /* isInfallible. False in setters. */
222 : false, /* isMovable. Not relevant for setters. */
223 : false, /* isEliminatable. Not relevant for setters. */
224 : false, /* isAlwaysInSlot. Only relevant for getters. */
225 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
226 : false, /* isTypedMethod. Only relevant for methods. */
227 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
228 : };
229 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
230 : static_assert(0 < 1, "There is no slot for us");
231 :
232 : static bool
233 0 : getCurrentTelemetryEnvironment(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
234 : {
235 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
236 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
237 0 : if (objIsXray) {
238 0 : unwrappedObj.emplace(cx, obj);
239 : }
240 0 : if (objIsXray) {
241 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
242 0 : if (!unwrappedObj.ref()) {
243 0 : return false;
244 : }
245 : }
246 0 : binding_detail::FastErrorResult rv;
247 0 : auto result(StrongOrRawPtr<Promise>(self->GetCurrentTelemetryEnvironment(rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj))));
248 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
249 0 : return false;
250 : }
251 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
252 0 : if (!ToJSValue(cx, result, args.rval())) {
253 0 : return false;
254 : }
255 0 : return true;
256 : }
257 :
258 : static bool
259 0 : getCurrentTelemetryEnvironment_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
260 : {
261 : // Make sure to save the callee before someone maybe messes
262 : // with rval().
263 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
264 0 : bool ok = getCurrentTelemetryEnvironment(cx, obj, self, args);
265 0 : if (ok) {
266 0 : return true;
267 : }
268 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
269 0 : args.rval());
270 : }
271 :
272 : static const JSJitInfo getCurrentTelemetryEnvironment_methodinfo = {
273 : { (JSJitGetterOp)getCurrentTelemetryEnvironment_promiseWrapper },
274 : { prototypes::id::MozSelfSupport },
275 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
276 : JSJitInfo::Method,
277 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
278 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
279 : false, /* isInfallible. False in setters. */
280 : false, /* isMovable. Not relevant for setters. */
281 : false, /* isEliminatable. Not relevant for setters. */
282 : false, /* isAlwaysInSlot. Only relevant for getters. */
283 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
284 : false, /* isTypedMethod. Only relevant for methods. */
285 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
286 : };
287 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
288 : static_assert(0 < 1, "There is no slot for us");
289 :
290 : static bool
291 0 : getCurrentTelemetrySubsessionPing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
292 : {
293 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
294 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
295 0 : if (objIsXray) {
296 0 : unwrappedObj.emplace(cx, obj);
297 : }
298 0 : if (objIsXray) {
299 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
300 0 : if (!unwrappedObj.ref()) {
301 0 : return false;
302 : }
303 : }
304 0 : binding_detail::FastErrorResult rv;
305 0 : auto result(StrongOrRawPtr<Promise>(self->GetCurrentTelemetrySubsessionPing(rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj))));
306 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
307 0 : return false;
308 : }
309 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
310 0 : if (!ToJSValue(cx, result, args.rval())) {
311 0 : return false;
312 : }
313 0 : return true;
314 : }
315 :
316 : static bool
317 0 : getCurrentTelemetrySubsessionPing_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
318 : {
319 : // Make sure to save the callee before someone maybe messes
320 : // with rval().
321 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
322 0 : bool ok = getCurrentTelemetrySubsessionPing(cx, obj, self, args);
323 0 : if (ok) {
324 0 : return true;
325 : }
326 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
327 0 : args.rval());
328 : }
329 :
330 : static const JSJitInfo getCurrentTelemetrySubsessionPing_methodinfo = {
331 : { (JSJitGetterOp)getCurrentTelemetrySubsessionPing_promiseWrapper },
332 : { prototypes::id::MozSelfSupport },
333 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
334 : JSJitInfo::Method,
335 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
336 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
337 : false, /* isInfallible. False in setters. */
338 : false, /* isMovable. Not relevant for setters. */
339 : false, /* isEliminatable. Not relevant for setters. */
340 : false, /* isAlwaysInSlot. Only relevant for getters. */
341 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
342 : false, /* isTypedMethod. Only relevant for methods. */
343 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
344 : };
345 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
346 : static_assert(0 < 1, "There is no slot for us");
347 :
348 : static bool
349 0 : resetPref(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
350 : {
351 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
352 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MozSelfSupport.resetPref");
353 : }
354 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
355 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
356 0 : if (objIsXray) {
357 0 : unwrappedObj.emplace(cx, obj);
358 : }
359 0 : binding_detail::FakeString arg0;
360 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
361 0 : return false;
362 : }
363 0 : if (objIsXray) {
364 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
365 0 : if (!unwrappedObj.ref()) {
366 0 : return false;
367 : }
368 : }
369 0 : binding_detail::FastErrorResult rv;
370 0 : self->ResetPref(NonNullHelper(Constify(arg0)), rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj));
371 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
372 0 : return false;
373 : }
374 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
375 0 : args.rval().setUndefined();
376 0 : return true;
377 : }
378 :
379 : static const JSJitInfo resetPref_methodinfo = {
380 : { (JSJitGetterOp)resetPref },
381 : { prototypes::id::MozSelfSupport },
382 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
383 : JSJitInfo::Method,
384 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
385 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
386 : false, /* isInfallible. False in setters. */
387 : false, /* isMovable. Not relevant for setters. */
388 : false, /* isEliminatable. Not relevant for setters. */
389 : false, /* isAlwaysInSlot. Only relevant for getters. */
390 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
391 : false, /* isTypedMethod. Only relevant for methods. */
392 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
393 : };
394 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
395 : static_assert(0 < 1, "There is no slot for us");
396 :
397 : static bool
398 0 : resetSearchEngines(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MozSelfSupport* self, const JSJitMethodCallArgs& args)
399 : {
400 0 : Maybe<JS::Rooted<JSObject*> > unwrappedObj;
401 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
402 0 : if (objIsXray) {
403 0 : unwrappedObj.emplace(cx, obj);
404 : }
405 0 : if (objIsXray) {
406 0 : unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
407 0 : if (!unwrappedObj.ref()) {
408 0 : return false;
409 : }
410 : }
411 0 : binding_detail::FastErrorResult rv;
412 0 : self->ResetSearchEngines(rv, js::GetObjectCompartment(unwrappedObj ? *unwrappedObj : obj));
413 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
414 0 : return false;
415 : }
416 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
417 0 : args.rval().setUndefined();
418 0 : return true;
419 : }
420 :
421 : static const JSJitInfo resetSearchEngines_methodinfo = {
422 : { (JSJitGetterOp)resetSearchEngines },
423 : { prototypes::id::MozSelfSupport },
424 : { PrototypeTraits<prototypes::id::MozSelfSupport>::Depth },
425 : JSJitInfo::Method,
426 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
427 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
428 : false, /* isInfallible. False in setters. */
429 : false, /* isMovable. Not relevant for setters. */
430 : false, /* isEliminatable. Not relevant for setters. */
431 : false, /* isAlwaysInSlot. Only relevant for getters. */
432 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
433 : false, /* isTypedMethod. Only relevant for methods. */
434 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
435 : };
436 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
437 : static_assert(0 < 1, "There is no slot for us");
438 :
439 : static bool
440 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
441 : {
442 0 : mozilla::dom::MozSelfSupport* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MozSelfSupport>(obj);
443 : // We don't want to preserve if we don't have a wrapper, and we
444 : // obviously can't preserve if we're not initialized.
445 0 : if (self && self->GetWrapperPreserveColor()) {
446 0 : PreserveWrapper(self);
447 : }
448 0 : return true;
449 : }
450 :
451 : static void
452 0 : _finalize(js::FreeOp* fop, JSObject* obj)
453 : {
454 0 : mozilla::dom::MozSelfSupport* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MozSelfSupport>(obj);
455 0 : if (self) {
456 0 : ClearWrapper(self, self, obj);
457 0 : AddForDeferredFinalization<mozilla::dom::MozSelfSupport>(self);
458 : }
459 0 : }
460 :
461 : static void
462 0 : _objectMoved(JSObject* obj, const JSObject* old)
463 : {
464 0 : mozilla::dom::MozSelfSupport* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MozSelfSupport>(obj);
465 0 : if (self) {
466 0 : UpdateWrapper(self, self, obj, old);
467 : }
468 0 : }
469 :
470 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
471 : #if defined(__clang__)
472 : #pragma clang diagnostic push
473 : #pragma clang diagnostic ignored "-Wmissing-braces"
474 : #endif
475 : static const JSFunctionSpec sChromeStaticMethods_specs[] = {
476 : JS_FNSPEC("_create", MozSelfSupport::_Create, nullptr, 2, 0, nullptr),
477 : JS_FS_END
478 : };
479 : #if defined(__clang__)
480 : #pragma clang diagnostic pop
481 : #endif
482 :
483 :
484 : // Can't be const because the pref-enabled boolean needs to be writable
485 : static Prefable<const JSFunctionSpec> sChromeStaticMethods[] = {
486 : { nullptr, &sChromeStaticMethods_specs[0] },
487 : { nullptr, nullptr }
488 : };
489 :
490 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
491 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
492 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
493 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
494 :
495 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
496 : #if defined(__clang__)
497 : #pragma clang diagnostic push
498 : #pragma clang diagnostic ignored "-Wmissing-braces"
499 : #endif
500 : static const JSFunctionSpec sMethods_specs[] = {
501 : JS_FNSPEC("getTelemetryPingList", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&getTelemetryPingList_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
502 : JS_FNSPEC("getTelemetryPing", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&getTelemetryPing_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
503 : JS_FNSPEC("getCurrentTelemetryEnvironment", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&getCurrentTelemetryEnvironment_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
504 : JS_FNSPEC("getCurrentTelemetrySubsessionPing", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&getCurrentTelemetrySubsessionPing_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
505 : JS_FNSPEC("resetPref", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&resetPref_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
506 : JS_FNSPEC("resetSearchEngines", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&resetSearchEngines_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
507 : JS_FS_END
508 : };
509 : #if defined(__clang__)
510 : #pragma clang diagnostic pop
511 : #endif
512 :
513 :
514 : // Can't be const because the pref-enabled boolean needs to be writable
515 : static Prefable<const JSFunctionSpec> sMethods[] = {
516 : { nullptr, &sMethods_specs[0] },
517 : { nullptr, nullptr }
518 : };
519 :
520 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
521 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
522 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
523 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
524 :
525 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
526 : #if defined(__clang__)
527 : #pragma clang diagnostic push
528 : #pragma clang diagnostic ignored "-Wmissing-braces"
529 : #endif
530 : static const JSPropertySpec sAttributes_specs[] = {
531 : { "healthReportDataSubmissionEnabled", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &healthReportDataSubmissionEnabled_getterinfo, GenericBindingSetter, &healthReportDataSubmissionEnabled_setterinfo },
532 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
533 : };
534 : #if defined(__clang__)
535 : #pragma clang diagnostic pop
536 : #endif
537 :
538 :
539 : // Can't be const because the pref-enabled boolean needs to be writable
540 : static Prefable<const JSPropertySpec> sAttributes[] = {
541 : { nullptr, &sAttributes_specs[0] },
542 : { nullptr, nullptr }
543 : };
544 :
545 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
546 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
547 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
548 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
549 :
550 :
551 : static uint16_t sNativeProperties_sortedPropertyIndices[7];
552 : static PropertyInfo sNativeProperties_propertyInfos[7];
553 :
554 : static const NativePropertiesN<2> sNativeProperties = {
555 : false, 0,
556 : false, 0,
557 : true, 0 /* sMethods */,
558 : true, 1 /* sAttributes */,
559 : false, 0,
560 : false, 0,
561 : false, 0,
562 : -1,
563 : 7,
564 : sNativeProperties_sortedPropertyIndices,
565 : {
566 : { sMethods, &sNativeProperties_propertyInfos[0] },
567 : { sAttributes, &sNativeProperties_propertyInfos[6] }
568 : }
569 : };
570 : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
571 : "We have a property info count that is oversized");
572 :
573 : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
574 : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
575 :
576 : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
577 : true, 0 /* sChromeStaticMethods */,
578 : false, 0,
579 : false, 0,
580 : false, 0,
581 : false, 0,
582 : false, 0,
583 : false, 0,
584 : -1,
585 : 1,
586 : sChromeOnlyNativeProperties_sortedPropertyIndices,
587 : {
588 : { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
589 : }
590 : };
591 : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
592 : "We have a property info count that is oversized");
593 :
594 : static bool
595 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
596 : {
597 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
598 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
599 0 : if (!args.isConstructing()) {
600 : // XXXbz wish I could get the name from the callee instead of
601 : // Adding more relocations
602 0 : return ThrowConstructorWithoutNew(cx, "MozSelfSupport");
603 : }
604 :
605 0 : GlobalObject global(cx, obj);
606 0 : if (global.Failed()) {
607 0 : return false;
608 : }
609 :
610 0 : JS::Rooted<JSObject*> desiredProto(cx);
611 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
612 0 : return false;
613 : }
614 :
615 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
616 0 : Maybe<JSAutoCompartment> ac;
617 0 : if (objIsXray) {
618 0 : obj = js::CheckedUnwrap(obj);
619 0 : if (!obj) {
620 0 : return false;
621 : }
622 0 : ac.emplace(cx, obj);
623 0 : if (!JS_WrapObject(cx, &desiredProto)) {
624 0 : return false;
625 : }
626 : }
627 0 : binding_detail::FastErrorResult rv;
628 0 : auto result(StrongOrRawPtr<mozilla::dom::MozSelfSupport>(mozilla::dom::MozSelfSupport::Constructor(global, cx, rv)));
629 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
630 0 : return false;
631 : }
632 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
633 : static_assert(!IsPointer<decltype(result)>::value,
634 : "NewObject implies that we need to keep the object alive with a strong reference.");
635 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
636 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
637 0 : return false;
638 : }
639 0 : return true;
640 : }
641 :
642 : static const js::ClassOps sInterfaceObjectClassOps = {
643 : nullptr, /* addProperty */
644 : nullptr, /* delProperty */
645 : nullptr, /* getProperty */
646 : nullptr, /* setProperty */
647 : nullptr, /* enumerate */
648 : nullptr, /* newEnumerate */
649 : nullptr, /* resolve */
650 : nullptr, /* mayResolve */
651 : nullptr, /* finalize */
652 : _constructor, /* call */
653 : nullptr, /* hasInstance */
654 : _constructor, /* construct */
655 : nullptr, /* trace */
656 : };
657 :
658 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
659 : {
660 : "Function",
661 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
662 : &sInterfaceObjectClassOps,
663 : JS_NULL_CLASS_SPEC,
664 : JS_NULL_CLASS_EXT,
665 : &sInterfaceObjectClassObjectOps
666 : },
667 : eInterface,
668 : true,
669 : prototypes::id::MozSelfSupport,
670 : PrototypeTraits<prototypes::id::MozSelfSupport>::Depth,
671 : sNativePropertyHooks,
672 : "function MozSelfSupport() {\n [native code]\n}",
673 : JS::GetRealmFunctionPrototype
674 : };
675 :
676 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
677 : {
678 : "MozSelfSupportPrototype",
679 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
680 : JS_NULL_CLASS_OPS,
681 : JS_NULL_CLASS_SPEC,
682 : JS_NULL_CLASS_EXT,
683 : JS_NULL_OBJECT_OPS
684 : },
685 : eInterfacePrototype,
686 : false,
687 : prototypes::id::MozSelfSupport,
688 : PrototypeTraits<prototypes::id::MozSelfSupport>::Depth,
689 : sNativePropertyHooks,
690 : "[object MozSelfSupportPrototype]",
691 : JS::GetRealmObjectPrototype
692 : };
693 :
694 : bool
695 3 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
696 : {
697 3 : return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
698 : }
699 :
700 : JSObject*
701 3 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
702 : {
703 3 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
704 : }
705 :
706 : static const js::ClassOps sClassOps = {
707 : _addProperty, /* addProperty */
708 : nullptr, /* delProperty */
709 : nullptr, /* getProperty */
710 : nullptr, /* setProperty */
711 : nullptr, /* enumerate */
712 : nullptr, /* newEnumerate */
713 : nullptr, /* resolve */
714 : nullptr, /* mayResolve */
715 : _finalize, /* finalize */
716 : nullptr, /* call */
717 : nullptr, /* hasInstance */
718 : nullptr, /* construct */
719 : nullptr, /* trace */
720 : };
721 :
722 : static const js::ClassExtension sClassExtension = {
723 : nullptr, /* weakmapKeyDelegateOp */
724 : _objectMoved /* objectMovedOp */
725 : };
726 :
727 : static const DOMJSClass sClass = {
728 : { "MozSelfSupport",
729 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
730 : &sClassOps,
731 : JS_NULL_CLASS_SPEC,
732 : &sClassExtension,
733 : JS_NULL_OBJECT_OPS
734 : },
735 : { prototypes::id::MozSelfSupport, 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 },
736 : IsBaseOf<nsISupports, mozilla::dom::MozSelfSupport >::value,
737 : sNativePropertyHooks,
738 : FindAssociatedGlobalForNative<mozilla::dom::MozSelfSupport>::Get,
739 : GetProtoObjectHandle,
740 : GetCCParticipant<mozilla::dom::MozSelfSupport>::Get()
741 : };
742 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
743 : "Must have the right minimal number of reserved slots.");
744 : static_assert(1 >= 1,
745 : "Must have enough reserved slots.");
746 :
747 : const JSClass*
748 0 : GetJSClass()
749 : {
750 0 : return sClass.ToJSClass();
751 : }
752 :
753 : bool
754 0 : Wrap(JSContext* aCx, mozilla::dom::MozSelfSupport* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
755 : {
756 : MOZ_ASSERT(static_cast<mozilla::dom::MozSelfSupport*>(aObject) ==
757 : reinterpret_cast<mozilla::dom::MozSelfSupport*>(aObject),
758 : "Multiple inheritance for mozilla::dom::MozSelfSupport is broken.");
759 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
760 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
761 0 : MOZ_ASSERT(!aCache->GetWrapper(),
762 : "You should probably not be using Wrap() directly; use "
763 : "GetOrCreateDOMReflector instead");
764 :
765 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
766 : "nsISupports must be on our primary inheritance chain");
767 :
768 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
769 0 : if (!global) {
770 0 : return false;
771 : }
772 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
773 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
774 :
775 : // That might have ended up wrapping us already, due to the wonders
776 : // of XBL. Check for that, and bail out as needed.
777 0 : aReflector.set(aCache->GetWrapper());
778 0 : if (aReflector) {
779 : #ifdef DEBUG
780 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
781 : #endif // DEBUG
782 0 : return true;
783 : }
784 :
785 0 : JSAutoCompartment ac(aCx, global);
786 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
787 0 : if (!canonicalProto) {
788 0 : return false;
789 : }
790 0 : JS::Rooted<JSObject*> proto(aCx);
791 0 : if (aGivenProto) {
792 0 : proto = aGivenProto;
793 : // Unfortunately, while aGivenProto was in the compartment of aCx
794 : // coming in, we changed compartments to that of "parent" so may need
795 : // to wrap the proto here.
796 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
797 0 : if (!JS_WrapObject(aCx, &proto)) {
798 0 : return false;
799 : }
800 : }
801 : } else {
802 0 : proto = canonicalProto;
803 : }
804 :
805 0 : BindingJSObjectCreator<mozilla::dom::MozSelfSupport> creator(aCx);
806 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
807 0 : if (!aReflector) {
808 0 : return false;
809 : }
810 :
811 0 : aCache->SetWrapper(aReflector);
812 0 : creator.InitializationSucceeded();
813 :
814 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
815 : aCache->GetWrapperPreserveColor() == aReflector);
816 : // If proto != canonicalProto, we have to preserve our wrapper;
817 : // otherwise we won't be able to properly recreate it later, since
818 : // we won't know what proto to use. Note that we don't check
819 : // aGivenProto here, since it's entirely possible (and even
820 : // somewhat common) to have a non-null aGivenProto which is the
821 : // same as canonicalProto.
822 0 : if (proto != canonicalProto) {
823 0 : PreserveWrapper(aObject);
824 : }
825 :
826 0 : return true;
827 : }
828 :
829 : const NativePropertyHooks sNativePropertyHooks[] = { {
830 : nullptr,
831 : nullptr,
832 : nullptr,
833 : { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
834 : prototypes::id::MozSelfSupport,
835 : constructors::id::MozSelfSupport,
836 : nullptr,
837 : &DefaultXrayExpandoObjectClass
838 : } };
839 :
840 : void
841 3 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
842 : {
843 6 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
844 3 : if (!parentProto) {
845 0 : return;
846 : }
847 :
848 6 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
849 3 : if (!constructorProto) {
850 0 : return;
851 : }
852 :
853 : static bool sIdsInited = false;
854 3 : if (!sIdsInited && NS_IsMainThread()) {
855 1 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
856 0 : return;
857 : }
858 1 : if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
859 0 : return;
860 : }
861 1 : sIdsInited = true;
862 : }
863 :
864 3 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MozSelfSupport);
865 3 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MozSelfSupport);
866 9 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
867 : &sPrototypeClass.mBase, protoCache,
868 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
869 : interfaceCache,
870 : sNativeProperties.Upcast(),
871 3 : nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
872 : "MozSelfSupport", aDefineOnGlobal,
873 : nullptr,
874 3 : false);
875 : }
876 :
877 : JS::Handle<JSObject*>
878 0 : GetProtoObjectHandle(JSContext* aCx)
879 : {
880 : /* Get the interface prototype object for this class. This will create the
881 : object as needed. */
882 0 : bool aDefineOnGlobal = true;
883 :
884 : /* Make sure our global is sane. Hopefully we can remove this sometime */
885 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
886 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
887 0 : return nullptr;
888 : }
889 :
890 : /* Check to see whether the interface objects are already installed */
891 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
892 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::MozSelfSupport)) {
893 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
894 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
895 : }
896 :
897 : /*
898 : * The object might _still_ be null, but that's OK.
899 : *
900 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
901 : * traced by TraceProtoAndIfaceCache() and its contents are never
902 : * changed after they have been set.
903 : *
904 : * Calling address() avoids the read read barrier that does gray
905 : * unmarking, but it's not possible for the object to be gray here.
906 : */
907 :
908 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::MozSelfSupport);
909 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
910 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
911 : }
912 :
913 : JS::Handle<JSObject*>
914 3 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
915 : {
916 : /* Get the interface object for this class. This will create the object as
917 : needed. */
918 :
919 : /* Make sure our global is sane. Hopefully we can remove this sometime */
920 3 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
921 3 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
922 0 : return nullptr;
923 : }
924 :
925 : /* Check to see whether the interface objects are already installed */
926 3 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
927 3 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::MozSelfSupport)) {
928 6 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
929 3 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
930 : }
931 :
932 : /*
933 : * The object might _still_ be null, but that's OK.
934 : *
935 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
936 : * traced by TraceProtoAndIfaceCache() and its contents are never
937 : * changed after they have been set.
938 : *
939 : * Calling address() avoids the read read barrier that does gray
940 : * unmarking, but it's not possible for the object to be gray here.
941 : */
942 :
943 3 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::MozSelfSupport);
944 3 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
945 3 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
946 : }
947 :
948 : JSObject*
949 0 : GetConstructorObject(JSContext* aCx)
950 : {
951 0 : return GetConstructorObjectHandle(aCx);
952 : }
953 :
954 : } // namespace MozSelfSupportBinding
955 :
956 :
957 :
958 : already_AddRefed<Promise>
959 0 : MozSelfSupportJSImpl::GetTelemetryPingList(ErrorResult& aRv, JSCompartment* aCompartment)
960 : {
961 0 : CallSetup s(this, aRv, "MozSelfSupport.getTelemetryPingList", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
962 0 : JSContext* cx = s.GetContext();
963 0 : if (!cx) {
964 0 : MOZ_ASSERT(aRv.Failed());
965 0 : return nullptr;
966 : }
967 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
968 :
969 0 : JS::Rooted<JS::Value> callable(cx);
970 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
971 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
972 0 : !GetCallableProperty(cx, atomsCache->getTelemetryPingList_id, &callable)) {
973 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
974 0 : return nullptr;
975 : }
976 0 : JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
977 0 : if (!JS::Call(cx, thisValue, callable,
978 0 : JS::HandleValueArray::empty(), &rval)) {
979 0 : aRv.NoteJSContextException(cx);
980 0 : return nullptr;
981 : }
982 0 : RefPtr<Promise> rvalDecl;
983 : { // Scope for our GlobalObject, FastErrorResult, JSAutoCompartment,
984 : // etc.
985 :
986 0 : JS::Rooted<JSObject*> globalObj(cx, JS::CurrentGlobalOrNull(cx));
987 0 : if (!rval.isObject()) {
988 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getTelemetryPingList"));
989 0 : return nullptr;
990 : }
991 0 : JSObject* unwrappedVal = js::CheckedUnwrap(&rval.toObject());
992 0 : if (!unwrappedVal) {
993 : // A slight lie, but not much of one, for a dead object wrapper.
994 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getTelemetryPingList"));
995 0 : return nullptr;
996 : }
997 0 : globalObj = js::GetGlobalForObjectCrossCompartment(unwrappedVal);
998 0 : JSAutoCompartment ac(cx, globalObj);
999 0 : GlobalObject promiseGlobal(cx, globalObj);
1000 0 : if (promiseGlobal.Failed()) {
1001 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1002 0 : return nullptr;
1003 : }
1004 :
1005 0 : JS::Rooted<JS::Value> valueToResolve(cx, rval);
1006 0 : if (!JS_WrapValue(cx, &valueToResolve)) {
1007 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1008 0 : return nullptr;
1009 : }
1010 0 : binding_detail::FastErrorResult promiseRv;
1011 : nsCOMPtr<nsIGlobalObject> global =
1012 0 : do_QueryInterface(promiseGlobal.GetAsSupports());
1013 0 : if (!global) {
1014 0 : promiseRv.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
1015 0 : MOZ_ALWAYS_TRUE(promiseRv.MaybeSetPendingException(cx));
1016 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1017 0 : return nullptr;
1018 : }
1019 0 : rvalDecl = Promise::Resolve(global, cx, valueToResolve,
1020 0 : promiseRv);
1021 0 : if (promiseRv.MaybeSetPendingException(cx)) {
1022 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1023 0 : return nullptr;
1024 : }
1025 : }
1026 0 : return rvalDecl.forget();
1027 : }
1028 :
1029 : already_AddRefed<Promise>
1030 0 : MozSelfSupportJSImpl::GetTelemetryPing(const nsAString& pingID, ErrorResult& aRv, JSCompartment* aCompartment)
1031 : {
1032 0 : CallSetup s(this, aRv, "MozSelfSupport.getTelemetryPing", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1033 0 : JSContext* cx = s.GetContext();
1034 0 : if (!cx) {
1035 0 : MOZ_ASSERT(aRv.Failed());
1036 0 : return nullptr;
1037 : }
1038 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1039 0 : JS::AutoValueVector argv(cx);
1040 0 : if (!argv.resize(1)) {
1041 0 : aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
1042 0 : return nullptr;
1043 : }
1044 0 : unsigned argc = 1;
1045 :
1046 : do {
1047 0 : nsString mutableStr(pingID);
1048 0 : if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) {
1049 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1050 0 : return nullptr;
1051 : }
1052 0 : break;
1053 : } while (0);
1054 :
1055 0 : JS::Rooted<JS::Value> callable(cx);
1056 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1057 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1058 0 : !GetCallableProperty(cx, atomsCache->getTelemetryPing_id, &callable)) {
1059 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1060 0 : return nullptr;
1061 : }
1062 0 : JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1063 0 : if (!JS::Call(cx, thisValue, callable,
1064 0 : JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
1065 0 : aRv.NoteJSContextException(cx);
1066 0 : return nullptr;
1067 : }
1068 0 : RefPtr<Promise> rvalDecl;
1069 : { // Scope for our GlobalObject, FastErrorResult, JSAutoCompartment,
1070 : // etc.
1071 :
1072 0 : JS::Rooted<JSObject*> globalObj(cx, JS::CurrentGlobalOrNull(cx));
1073 0 : if (!rval.isObject()) {
1074 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getTelemetryPing"));
1075 0 : return nullptr;
1076 : }
1077 0 : JSObject* unwrappedVal = js::CheckedUnwrap(&rval.toObject());
1078 0 : if (!unwrappedVal) {
1079 : // A slight lie, but not much of one, for a dead object wrapper.
1080 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getTelemetryPing"));
1081 0 : return nullptr;
1082 : }
1083 0 : globalObj = js::GetGlobalForObjectCrossCompartment(unwrappedVal);
1084 0 : JSAutoCompartment ac(cx, globalObj);
1085 0 : GlobalObject promiseGlobal(cx, globalObj);
1086 0 : if (promiseGlobal.Failed()) {
1087 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1088 0 : return nullptr;
1089 : }
1090 :
1091 0 : JS::Rooted<JS::Value> valueToResolve(cx, rval);
1092 0 : if (!JS_WrapValue(cx, &valueToResolve)) {
1093 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1094 0 : return nullptr;
1095 : }
1096 0 : binding_detail::FastErrorResult promiseRv;
1097 : nsCOMPtr<nsIGlobalObject> global =
1098 0 : do_QueryInterface(promiseGlobal.GetAsSupports());
1099 0 : if (!global) {
1100 0 : promiseRv.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
1101 0 : MOZ_ALWAYS_TRUE(promiseRv.MaybeSetPendingException(cx));
1102 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1103 0 : return nullptr;
1104 : }
1105 0 : rvalDecl = Promise::Resolve(global, cx, valueToResolve,
1106 0 : promiseRv);
1107 0 : if (promiseRv.MaybeSetPendingException(cx)) {
1108 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1109 0 : return nullptr;
1110 : }
1111 : }
1112 0 : return rvalDecl.forget();
1113 : }
1114 :
1115 : already_AddRefed<Promise>
1116 0 : MozSelfSupportJSImpl::GetCurrentTelemetryEnvironment(ErrorResult& aRv, JSCompartment* aCompartment)
1117 : {
1118 0 : CallSetup s(this, aRv, "MozSelfSupport.getCurrentTelemetryEnvironment", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1119 0 : JSContext* cx = s.GetContext();
1120 0 : if (!cx) {
1121 0 : MOZ_ASSERT(aRv.Failed());
1122 0 : return nullptr;
1123 : }
1124 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1125 :
1126 0 : JS::Rooted<JS::Value> callable(cx);
1127 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1128 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1129 0 : !GetCallableProperty(cx, atomsCache->getCurrentTelemetryEnvironment_id, &callable)) {
1130 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1131 0 : return nullptr;
1132 : }
1133 0 : JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1134 0 : if (!JS::Call(cx, thisValue, callable,
1135 0 : JS::HandleValueArray::empty(), &rval)) {
1136 0 : aRv.NoteJSContextException(cx);
1137 0 : return nullptr;
1138 : }
1139 0 : RefPtr<Promise> rvalDecl;
1140 : { // Scope for our GlobalObject, FastErrorResult, JSAutoCompartment,
1141 : // etc.
1142 :
1143 0 : JS::Rooted<JSObject*> globalObj(cx, JS::CurrentGlobalOrNull(cx));
1144 0 : if (!rval.isObject()) {
1145 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getCurrentTelemetryEnvironment"));
1146 0 : return nullptr;
1147 : }
1148 0 : JSObject* unwrappedVal = js::CheckedUnwrap(&rval.toObject());
1149 0 : if (!unwrappedVal) {
1150 : // A slight lie, but not much of one, for a dead object wrapper.
1151 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getCurrentTelemetryEnvironment"));
1152 0 : return nullptr;
1153 : }
1154 0 : globalObj = js::GetGlobalForObjectCrossCompartment(unwrappedVal);
1155 0 : JSAutoCompartment ac(cx, globalObj);
1156 0 : GlobalObject promiseGlobal(cx, globalObj);
1157 0 : if (promiseGlobal.Failed()) {
1158 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1159 0 : return nullptr;
1160 : }
1161 :
1162 0 : JS::Rooted<JS::Value> valueToResolve(cx, rval);
1163 0 : if (!JS_WrapValue(cx, &valueToResolve)) {
1164 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1165 0 : return nullptr;
1166 : }
1167 0 : binding_detail::FastErrorResult promiseRv;
1168 : nsCOMPtr<nsIGlobalObject> global =
1169 0 : do_QueryInterface(promiseGlobal.GetAsSupports());
1170 0 : if (!global) {
1171 0 : promiseRv.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
1172 0 : MOZ_ALWAYS_TRUE(promiseRv.MaybeSetPendingException(cx));
1173 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1174 0 : return nullptr;
1175 : }
1176 0 : rvalDecl = Promise::Resolve(global, cx, valueToResolve,
1177 0 : promiseRv);
1178 0 : if (promiseRv.MaybeSetPendingException(cx)) {
1179 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1180 0 : return nullptr;
1181 : }
1182 : }
1183 0 : return rvalDecl.forget();
1184 : }
1185 :
1186 : already_AddRefed<Promise>
1187 0 : MozSelfSupportJSImpl::GetCurrentTelemetrySubsessionPing(ErrorResult& aRv, JSCompartment* aCompartment)
1188 : {
1189 0 : CallSetup s(this, aRv, "MozSelfSupport.getCurrentTelemetrySubsessionPing", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1190 0 : JSContext* cx = s.GetContext();
1191 0 : if (!cx) {
1192 0 : MOZ_ASSERT(aRv.Failed());
1193 0 : return nullptr;
1194 : }
1195 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1196 :
1197 0 : JS::Rooted<JS::Value> callable(cx);
1198 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1199 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1200 0 : !GetCallableProperty(cx, atomsCache->getCurrentTelemetrySubsessionPing_id, &callable)) {
1201 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1202 0 : return nullptr;
1203 : }
1204 0 : JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1205 0 : if (!JS::Call(cx, thisValue, callable,
1206 0 : JS::HandleValueArray::empty(), &rval)) {
1207 0 : aRv.NoteJSContextException(cx);
1208 0 : return nullptr;
1209 : }
1210 0 : RefPtr<Promise> rvalDecl;
1211 : { // Scope for our GlobalObject, FastErrorResult, JSAutoCompartment,
1212 : // etc.
1213 :
1214 0 : JS::Rooted<JSObject*> globalObj(cx, JS::CurrentGlobalOrNull(cx));
1215 0 : if (!rval.isObject()) {
1216 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getCurrentTelemetrySubsessionPing"));
1217 0 : return nullptr;
1218 : }
1219 0 : JSObject* unwrappedVal = js::CheckedUnwrap(&rval.toObject());
1220 0 : if (!unwrappedVal) {
1221 : // A slight lie, but not much of one, for a dead object wrapper.
1222 0 : aRv.ThrowTypeError<MSG_NOT_OBJECT>(NS_LITERAL_STRING("return value of MozSelfSupport.getCurrentTelemetrySubsessionPing"));
1223 0 : return nullptr;
1224 : }
1225 0 : globalObj = js::GetGlobalForObjectCrossCompartment(unwrappedVal);
1226 0 : JSAutoCompartment ac(cx, globalObj);
1227 0 : GlobalObject promiseGlobal(cx, globalObj);
1228 0 : if (promiseGlobal.Failed()) {
1229 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1230 0 : return nullptr;
1231 : }
1232 :
1233 0 : JS::Rooted<JS::Value> valueToResolve(cx, rval);
1234 0 : if (!JS_WrapValue(cx, &valueToResolve)) {
1235 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1236 0 : return nullptr;
1237 : }
1238 0 : binding_detail::FastErrorResult promiseRv;
1239 : nsCOMPtr<nsIGlobalObject> global =
1240 0 : do_QueryInterface(promiseGlobal.GetAsSupports());
1241 0 : if (!global) {
1242 0 : promiseRv.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
1243 0 : MOZ_ALWAYS_TRUE(promiseRv.MaybeSetPendingException(cx));
1244 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1245 0 : return nullptr;
1246 : }
1247 0 : rvalDecl = Promise::Resolve(global, cx, valueToResolve,
1248 0 : promiseRv);
1249 0 : if (promiseRv.MaybeSetPendingException(cx)) {
1250 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1251 0 : return nullptr;
1252 : }
1253 : }
1254 0 : return rvalDecl.forget();
1255 : }
1256 :
1257 : void
1258 0 : MozSelfSupportJSImpl::ResetPref(const nsAString& name, ErrorResult& aRv, JSCompartment* aCompartment)
1259 : {
1260 0 : CallSetup s(this, aRv, "MozSelfSupport.resetPref", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1261 0 : JSContext* cx = s.GetContext();
1262 0 : if (!cx) {
1263 0 : MOZ_ASSERT(aRv.Failed());
1264 0 : return;
1265 : }
1266 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1267 0 : JS::AutoValueVector argv(cx);
1268 0 : if (!argv.resize(1)) {
1269 0 : aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
1270 0 : return;
1271 : }
1272 0 : unsigned argc = 1;
1273 :
1274 : do {
1275 0 : nsString mutableStr(name);
1276 0 : if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) {
1277 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1278 0 : return;
1279 : }
1280 0 : break;
1281 : } while (0);
1282 :
1283 0 : JS::Rooted<JS::Value> callable(cx);
1284 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1285 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1286 0 : !GetCallableProperty(cx, atomsCache->resetPref_id, &callable)) {
1287 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1288 0 : return;
1289 : }
1290 0 : JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1291 0 : if (!JS::Call(cx, thisValue, callable,
1292 0 : JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
1293 0 : aRv.NoteJSContextException(cx);
1294 0 : return;
1295 : }
1296 : }
1297 :
1298 : void
1299 0 : MozSelfSupportJSImpl::ResetSearchEngines(ErrorResult& aRv, JSCompartment* aCompartment)
1300 : {
1301 0 : CallSetup s(this, aRv, "MozSelfSupport.resetSearchEngines", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1302 0 : JSContext* cx = s.GetContext();
1303 0 : if (!cx) {
1304 0 : MOZ_ASSERT(aRv.Failed());
1305 0 : return;
1306 : }
1307 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1308 :
1309 0 : JS::Rooted<JS::Value> callable(cx);
1310 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1311 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1312 0 : !GetCallableProperty(cx, atomsCache->resetSearchEngines_id, &callable)) {
1313 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1314 0 : return;
1315 : }
1316 0 : JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1317 0 : if (!JS::Call(cx, thisValue, callable,
1318 0 : JS::HandleValueArray::empty(), &rval)) {
1319 0 : aRv.NoteJSContextException(cx);
1320 0 : return;
1321 : }
1322 : }
1323 :
1324 : void
1325 0 : MozSelfSupportJSImpl::__Init(ErrorResult& aRv, JSCompartment* aCompartment)
1326 : {
1327 0 : CallSetup s(this, aRv, "__init", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1328 0 : JSContext* cx = s.GetContext();
1329 0 : if (!cx) {
1330 0 : MOZ_ASSERT(aRv.Failed());
1331 0 : return;
1332 : }
1333 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1334 :
1335 0 : JS::Rooted<JS::Value> callable(cx);
1336 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1337 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1338 0 : !GetCallableProperty(cx, atomsCache->__init_id, &callable)) {
1339 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1340 0 : return;
1341 : }
1342 0 : JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
1343 0 : if (!JS::Call(cx, thisValue, callable,
1344 0 : JS::HandleValueArray::empty(), &rval)) {
1345 0 : aRv.NoteJSContextException(cx);
1346 0 : return;
1347 : }
1348 : }
1349 :
1350 : bool
1351 0 : MozSelfSupportJSImpl::InitIds(JSContext* cx, MozSelfSupportAtoms* atomsCache)
1352 : {
1353 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1354 :
1355 : // Initialize these in reverse order so that any failure leaves the first one
1356 : // uninitialized.
1357 0 : if (!atomsCache->__init_id.init(cx, "__init") ||
1358 0 : !atomsCache->resetSearchEngines_id.init(cx, "resetSearchEngines") ||
1359 0 : !atomsCache->resetPref_id.init(cx, "resetPref") ||
1360 0 : !atomsCache->getCurrentTelemetrySubsessionPing_id.init(cx, "getCurrentTelemetrySubsessionPing") ||
1361 0 : !atomsCache->getCurrentTelemetryEnvironment_id.init(cx, "getCurrentTelemetryEnvironment") ||
1362 0 : !atomsCache->getTelemetryPing_id.init(cx, "getTelemetryPing") ||
1363 0 : !atomsCache->getTelemetryPingList_id.init(cx, "getTelemetryPingList") ||
1364 0 : !atomsCache->healthReportDataSubmissionEnabled_id.init(cx, "healthReportDataSubmissionEnabled")) {
1365 0 : return false;
1366 : }
1367 0 : return true;
1368 : }
1369 :
1370 :
1371 : bool
1372 0 : MozSelfSupportJSImpl::GetHealthReportDataSubmissionEnabled(ErrorResult& aRv, JSCompartment* aCompartment)
1373 : {
1374 0 : CallSetup s(this, aRv, "MozSelfSupport.healthReportDataSubmissionEnabled", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1375 0 : JSContext* cx = s.GetContext();
1376 0 : if (!cx) {
1377 0 : MOZ_ASSERT(aRv.Failed());
1378 0 : return bool(0);
1379 : }
1380 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
1381 :
1382 0 : JS::Rooted<JSObject *> callback(cx, mCallback);
1383 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1384 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1385 0 : !JS_GetPropertyById(cx, callback, atomsCache->healthReportDataSubmissionEnabled_id, &rval)) {
1386 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1387 0 : return bool(0);
1388 : }
1389 : bool rvalDecl;
1390 0 : if (!ValueToPrimitive<bool, eDefault>(cx, rval, &rvalDecl)) {
1391 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1392 0 : return bool(0);
1393 : }
1394 0 : return rvalDecl;
1395 : }
1396 :
1397 : void
1398 0 : MozSelfSupportJSImpl::SetHealthReportDataSubmissionEnabled(bool arg, ErrorResult& aRv, JSCompartment* aCompartment)
1399 : {
1400 0 : CallSetup s(this, aRv, "MozSelfSupport.healthReportDataSubmissionEnabled", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ true);
1401 0 : JSContext* cx = s.GetContext();
1402 0 : if (!cx) {
1403 0 : MOZ_ASSERT(aRv.Failed());
1404 0 : return;
1405 : }
1406 0 : JS::AutoValueVector argv(cx);
1407 0 : if (!argv.resize(1)) {
1408 0 : aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
1409 0 : return;
1410 : }
1411 : do {
1412 0 : argv[0].setBoolean(arg);
1413 0 : break;
1414 : } while (0);
1415 :
1416 0 : MOZ_ASSERT(argv.length() == 1);
1417 0 : MozSelfSupportAtoms* atomsCache = GetAtomCache<MozSelfSupportAtoms>(cx);
1418 0 : if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
1419 0 : !JS_SetPropertyById(cx, CallbackKnownNotGray(), atomsCache->healthReportDataSubmissionEnabled_id, argv[0])) {
1420 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
1421 0 : return;
1422 : }
1423 : }
1424 :
1425 :
1426 : NS_IMPL_CYCLE_COLLECTION_CLASS(MozSelfSupport)
1427 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MozSelfSupport)
1428 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK(mImpl)
1429 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
1430 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
1431 0 : tmp->ClearWeakReferences();
1432 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
1433 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MozSelfSupport)
1434 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl)
1435 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
1436 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
1437 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(MozSelfSupport)
1438 0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(MozSelfSupport)
1439 0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(MozSelfSupport)
1440 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MozSelfSupport)
1441 0 : NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
1442 0 : NS_INTERFACE_MAP_ENTRY(nsISupports)
1443 0 : NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
1444 0 : NS_INTERFACE_MAP_END
1445 :
1446 0 : MozSelfSupport::MozSelfSupport(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent)
1447 0 : : mImpl(new MozSelfSupportJSImpl(nullptr, aJSImplObject, /* aIncumbentGlobal = */ nullptr)),
1448 0 : mParent(aParent)
1449 : {
1450 0 : }
1451 :
1452 :
1453 0 : MozSelfSupport::~MozSelfSupport()
1454 : {
1455 0 : }
1456 :
1457 : nsISupports*
1458 0 : MozSelfSupport::GetParentObject() const
1459 : {
1460 0 : return mParent;
1461 : }
1462 :
1463 : JSObject*
1464 0 : MozSelfSupport::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
1465 : {
1466 0 : JS::Rooted<JSObject*> obj(aCx, MozSelfSupportBinding::Wrap(aCx, this, aGivenProto));
1467 0 : if (!obj) {
1468 0 : return nullptr;
1469 : }
1470 :
1471 : // Now define it on our chrome object
1472 0 : JSAutoCompartment ac(aCx, mImpl->CallbackOrNull());
1473 0 : if (!JS_WrapObject(aCx, &obj)) {
1474 0 : return nullptr;
1475 : }
1476 0 : if (!JS_DefineProperty(aCx, mImpl->CallbackOrNull(), "__DOM_IMPL__", obj, 0)) {
1477 0 : return nullptr;
1478 : }
1479 0 : return obj;
1480 : }
1481 :
1482 : already_AddRefed<MozSelfSupport>
1483 0 : MozSelfSupport::Constructor(const GlobalObject& global, JSContext* cx, ErrorResult& aRv)
1484 : {
1485 0 : JS::Rooted<JSObject*> jsImplObj(cx);
1486 : nsCOMPtr<nsIGlobalObject> globalHolder =
1487 0 : ConstructJSImplementation("@mozilla.org/mozselfsupport;1", global, &jsImplObj, aRv);
1488 0 : if (aRv.Failed()) {
1489 0 : return nullptr;
1490 : }
1491 : // Build the C++ implementation.
1492 0 : RefPtr<MozSelfSupport> impl = new MozSelfSupport(jsImplObj, globalHolder);
1493 0 : return impl.forget();
1494 : }
1495 :
1496 : bool
1497 0 : MozSelfSupport::GetHealthReportDataSubmissionEnabled(ErrorResult& aRv, JSCompartment* aCompartment) const
1498 : {
1499 0 : return mImpl->GetHealthReportDataSubmissionEnabled(aRv, aCompartment);
1500 : }
1501 :
1502 : void
1503 0 : MozSelfSupport::SetHealthReportDataSubmissionEnabled(bool arg, ErrorResult& aRv, JSCompartment* aCompartment)
1504 : {
1505 0 : mImpl->SetHealthReportDataSubmissionEnabled(arg, aRv, aCompartment);
1506 0 : }
1507 :
1508 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
1509 : already_AddRefed<Promise>
1510 0 : MozSelfSupport::GetTelemetryPingList(ErrorResult& aRv, JSCompartment* aCompartment)
1511 : {
1512 0 : return mImpl->GetTelemetryPingList(aRv, aCompartment);
1513 : }
1514 :
1515 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
1516 : already_AddRefed<Promise>
1517 0 : MozSelfSupport::GetTelemetryPing(const nsAString& pingID, ErrorResult& aRv, JSCompartment* aCompartment)
1518 : {
1519 0 : return mImpl->GetTelemetryPing(pingID, aRv, aCompartment);
1520 : }
1521 :
1522 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
1523 : already_AddRefed<Promise>
1524 0 : MozSelfSupport::GetCurrentTelemetryEnvironment(ErrorResult& aRv, JSCompartment* aCompartment)
1525 : {
1526 0 : return mImpl->GetCurrentTelemetryEnvironment(aRv, aCompartment);
1527 : }
1528 :
1529 : // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee).
1530 : already_AddRefed<Promise>
1531 0 : MozSelfSupport::GetCurrentTelemetrySubsessionPing(ErrorResult& aRv, JSCompartment* aCompartment)
1532 : {
1533 0 : return mImpl->GetCurrentTelemetrySubsessionPing(aRv, aCompartment);
1534 : }
1535 :
1536 : void
1537 0 : MozSelfSupport::ResetPref(const nsAString& name, ErrorResult& aRv, JSCompartment* aCompartment)
1538 : {
1539 0 : return mImpl->ResetPref(name, aRv, aCompartment);
1540 : }
1541 :
1542 : void
1543 0 : MozSelfSupport::ResetSearchEngines(ErrorResult& aRv, JSCompartment* aCompartment)
1544 : {
1545 0 : return mImpl->ResetSearchEngines(aRv, aCompartment);
1546 : }
1547 :
1548 : bool
1549 0 : MozSelfSupport::_Create(JSContext* cx, unsigned argc, JS::Value* vp)
1550 : {
1551 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1552 0 : if (args.length() < 2) {
1553 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MozSelfSupport._create");
1554 : }
1555 0 : if (!args[0].isObject()) {
1556 0 : return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of MozSelfSupport._create");
1557 : }
1558 0 : if (!args[1].isObject()) {
1559 0 : return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of MozSelfSupport._create");
1560 : }
1561 :
1562 : // GlobalObject will go through wrappers as needed for us, and
1563 : // is simpler than the right UnwrapArg incantation.
1564 0 : GlobalObject global(cx, &args[0].toObject());
1565 0 : if (global.Failed()) {
1566 0 : return false;
1567 : }
1568 0 : nsCOMPtr<nsIGlobalObject> globalHolder = do_QueryInterface(global.GetAsSupports());
1569 0 : MOZ_ASSERT(globalHolder);
1570 0 : JS::Rooted<JSObject*> arg(cx, &args[1].toObject());
1571 0 : RefPtr<MozSelfSupport> impl = new MozSelfSupport(arg, globalHolder);
1572 0 : MOZ_ASSERT(js::IsObjectInContextCompartment(arg, cx));
1573 0 : return GetOrCreateDOMReflector(cx, impl, args.rval());
1574 : }
1575 :
1576 :
1577 : } // namespace dom
1578 : } // namespace mozilla
|