/work/obj-fuzz/dom/bindings/RTCCertificateBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM RTCCertificate.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "RTCCertificateBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/Preferences.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/PrimitiveConversions.h" |
12 | | #include "mozilla/dom/RTCCertificate.h" |
13 | | #include "mozilla/dom/ScriptSettings.h" |
14 | | #include "mozilla/dom/SimpleGlobalObject.h" |
15 | | #include "mozilla/dom/XrayExpandoClass.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace dom { |
19 | | |
20 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
21 | | using namespace mozilla::dom::binding_detail; |
22 | | |
23 | | |
24 | | |
25 | | RTCCertificateExpiration::RTCCertificateExpiration() |
26 | 0 | { |
27 | 0 | // Safe to pass a null context if we pass a null value |
28 | 0 | Init(nullptr, JS::NullHandleValue); |
29 | 0 | } |
30 | | |
31 | | |
32 | | |
33 | | bool |
34 | | RTCCertificateExpiration::InitIds(JSContext* cx, RTCCertificateExpirationAtoms* atomsCache) |
35 | 0 | { |
36 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
37 | 0 |
|
38 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
39 | 0 | // uninitialized. |
40 | 0 | if (!atomsCache->expires_id.init(cx, "expires")) { |
41 | 0 | return false; |
42 | 0 | } |
43 | 0 | return true; |
44 | 0 | } |
45 | | |
46 | | bool |
47 | | RTCCertificateExpiration::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
48 | 0 | { |
49 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
50 | 0 | // Since in that case we will not have to do any property gets |
51 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
52 | 0 | // checkers by static analysis tools |
53 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
54 | 0 | RTCCertificateExpirationAtoms* atomsCache = nullptr; |
55 | 0 | if (cx) { |
56 | 0 | atomsCache = GetAtomCache<RTCCertificateExpirationAtoms>(cx); |
57 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
58 | 0 | return false; |
59 | 0 | } |
60 | 0 | } |
61 | 0 | |
62 | 0 | if (!IsConvertibleToDictionary(val)) { |
63 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
64 | 0 | } |
65 | 0 | |
66 | 0 | bool isNull = val.isNullOrUndefined(); |
67 | 0 | // We only need these if !isNull, in which case we have |cx|. |
68 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
69 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
70 | 0 | if (!isNull) { |
71 | 0 | MOZ_ASSERT(cx); |
72 | 0 | object.emplace(cx, &val.toObject()); |
73 | 0 | temp.emplace(cx); |
74 | 0 | } |
75 | 0 | if (!isNull) { |
76 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->expires_id, temp.ptr())) { |
77 | 0 | return false; |
78 | 0 | } |
79 | 0 | } |
80 | 0 | if (!isNull && !temp->isUndefined()) { |
81 | 0 | mExpires.Construct(); |
82 | 0 | if (!ValueToPrimitive<uint64_t, eEnforceRange>(cx, temp.ref(), &(mExpires.Value()))) { |
83 | 0 | return false; |
84 | 0 | } |
85 | 0 | mIsAnyMemberPresent = true; |
86 | 0 | } |
87 | 0 | return true; |
88 | 0 | } |
89 | | |
90 | | bool |
91 | | RTCCertificateExpiration::Init(const nsAString& aJSON) |
92 | 0 | { |
93 | 0 | AutoJSAPI jsapi; |
94 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
95 | 0 | if (!cleanGlobal) { |
96 | 0 | return false; |
97 | 0 | } |
98 | 0 | if (!jsapi.Init(cleanGlobal)) { |
99 | 0 | return false; |
100 | 0 | } |
101 | 0 | JSContext* cx = jsapi.cx(); |
102 | 0 | JS::Rooted<JS::Value> json(cx); |
103 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
104 | 0 | NS_ENSURE_TRUE(ok, false); |
105 | 0 | return Init(cx, json); |
106 | 0 | } |
107 | | |
108 | | bool |
109 | | RTCCertificateExpiration::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
110 | 0 | { |
111 | 0 | RTCCertificateExpirationAtoms* atomsCache = GetAtomCache<RTCCertificateExpirationAtoms>(cx); |
112 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
113 | 0 | return false; |
114 | 0 | } |
115 | 0 | |
116 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
117 | 0 | if (!obj) { |
118 | 0 | return false; |
119 | 0 | } |
120 | 0 | rval.set(JS::ObjectValue(*obj)); |
121 | 0 |
|
122 | 0 | if (mExpires.WasPassed()) { |
123 | 0 | do { |
124 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
125 | 0 | JS::Rooted<JS::Value> temp(cx); |
126 | 0 | uint64_t const & currentValue = mExpires.InternalValue(); |
127 | 0 | temp.set(JS_NumberValue(double(currentValue))); |
128 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->expires_id, temp, JSPROP_ENUMERATE)) { |
129 | 0 | return false; |
130 | 0 | } |
131 | 0 | break; |
132 | 0 | } while(false); |
133 | 0 | } |
134 | 0 |
|
135 | 0 | return true; |
136 | 0 | } |
137 | | |
138 | | bool |
139 | | RTCCertificateExpiration::ToJSON(nsAString& aJSON) const |
140 | 0 | { |
141 | 0 | AutoJSAPI jsapi; |
142 | 0 | jsapi.Init(); |
143 | 0 | JSContext *cx = jsapi.cx(); |
144 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
145 | 0 | // because we'll only be creating objects, in ways that have no |
146 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
147 | 0 | // which likewise guarantees no side-effects for the sorts of |
148 | 0 | // things we will pass it. |
149 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
150 | 0 | JS::Rooted<JS::Value> val(cx); |
151 | 0 | if (!ToObjectInternal(cx, &val)) { |
152 | 0 | return false; |
153 | 0 | } |
154 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
155 | 0 | return StringifyToJSON(cx, obj, aJSON); |
156 | 0 | } |
157 | | |
158 | | void |
159 | | RTCCertificateExpiration::TraceDictionary(JSTracer* trc) |
160 | 0 | { |
161 | 0 | } |
162 | | |
163 | | RTCCertificateExpiration& |
164 | | RTCCertificateExpiration::operator=(const RTCCertificateExpiration& aOther) |
165 | 0 | { |
166 | 0 | DictionaryBase::operator=(aOther); |
167 | 0 | mExpires.Reset(); |
168 | 0 | if (aOther.mExpires.WasPassed()) { |
169 | 0 | mExpires.Construct(aOther.mExpires.Value()); |
170 | 0 | } |
171 | 0 | return *this; |
172 | 0 | } |
173 | | |
174 | | namespace binding_detail { |
175 | | } // namespace binding_detail |
176 | | |
177 | | |
178 | | namespace RTCCertificate_Binding { |
179 | | |
180 | | MOZ_CAN_RUN_SCRIPT static bool |
181 | | get_expires(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCCertificate* self, JSJitGetterCallArgs args) |
182 | 0 | { |
183 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCCertificate.expires", DOM, cx); |
184 | 0 |
|
185 | 0 | uint64_t result(self->Expires()); |
186 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
187 | 0 | args.rval().set(JS_NumberValue(double(result))); |
188 | 0 | return true; |
189 | 0 | } |
190 | | |
191 | | static const JSJitInfo expires_getterinfo = { |
192 | | { (JSJitGetterOp)get_expires }, |
193 | | { prototypes::id::RTCCertificate }, |
194 | | { PrototypeTraits<prototypes::id::RTCCertificate>::Depth }, |
195 | | JSJitInfo::Getter, |
196 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
197 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
198 | | true, /* isInfallible. False in setters. */ |
199 | | false, /* isMovable. Not relevant for setters. */ |
200 | | false, /* isEliminatable. Not relevant for setters. */ |
201 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
202 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
203 | | false, /* isTypedMethod. Only relevant for methods. */ |
204 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
205 | | }; |
206 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
207 | | static_assert(0 < 1, "There is no slot for us"); |
208 | | |
209 | | static bool |
210 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
211 | 0 | { |
212 | 0 | mozilla::dom::RTCCertificate* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCCertificate>(obj); |
213 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
214 | 0 | // obviously can't preserve if we're not initialized. |
215 | 0 | if (self && self->GetWrapperPreserveColor()) { |
216 | 0 | PreserveWrapper(self); |
217 | 0 | } |
218 | 0 | return true; |
219 | 0 | } |
220 | | |
221 | | static void |
222 | | _finalize(js::FreeOp* fop, JSObject* obj) |
223 | 0 | { |
224 | 0 | mozilla::dom::RTCCertificate* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCCertificate>(obj); |
225 | 0 | if (self) { |
226 | 0 | ClearWrapper(self, self, obj); |
227 | 0 | AddForDeferredFinalization<mozilla::dom::RTCCertificate>(self); |
228 | 0 | } |
229 | 0 | } |
230 | | |
231 | | static size_t |
232 | | _objectMoved(JSObject* obj, JSObject* old) |
233 | 0 | { |
234 | 0 | mozilla::dom::RTCCertificate* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCCertificate>(obj); |
235 | 0 | if (self) { |
236 | 0 | UpdateWrapper(self, self, obj, old); |
237 | 0 | } |
238 | 0 |
|
239 | 0 | return 0; |
240 | 0 | } |
241 | | |
242 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
243 | | #if defined(__clang__) |
244 | | #pragma clang diagnostic push |
245 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
246 | | #endif |
247 | | static const JSPropertySpec sAttributes_specs[] = { |
248 | | { "expires", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &expires_getterinfo, nullptr, nullptr }, |
249 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
250 | | }; |
251 | | #if defined(__clang__) |
252 | | #pragma clang diagnostic pop |
253 | | #endif |
254 | | |
255 | | |
256 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
257 | | { nullptr, &sAttributes_specs[0] }, |
258 | | { nullptr, nullptr } |
259 | | }; |
260 | | |
261 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
262 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
263 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
264 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
265 | | |
266 | | |
267 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
268 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
269 | | |
270 | | static const NativePropertiesN<1> sNativeProperties = { |
271 | | false, 0, |
272 | | false, 0, |
273 | | false, 0, |
274 | | true, 0 /* sAttributes */, |
275 | | false, 0, |
276 | | false, 0, |
277 | | false, 0, |
278 | | -1, |
279 | | 1, |
280 | | sNativeProperties_sortedPropertyIndices, |
281 | | { |
282 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
283 | | } |
284 | | }; |
285 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
286 | | "We have a property info count that is oversized"); |
287 | | |
288 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
289 | | { |
290 | | "Function", |
291 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
292 | | &sBoringInterfaceObjectClassClassOps, |
293 | | JS_NULL_CLASS_SPEC, |
294 | | JS_NULL_CLASS_EXT, |
295 | | &sInterfaceObjectClassObjectOps |
296 | | }, |
297 | | eInterface, |
298 | | true, |
299 | | prototypes::id::RTCCertificate, |
300 | | PrototypeTraits<prototypes::id::RTCCertificate>::Depth, |
301 | | sNativePropertyHooks, |
302 | | "function RTCCertificate() {\n [native code]\n}", |
303 | | JS::GetRealmFunctionPrototype |
304 | | }; |
305 | | |
306 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
307 | | { |
308 | | "RTCCertificatePrototype", |
309 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
310 | | JS_NULL_CLASS_OPS, |
311 | | JS_NULL_CLASS_SPEC, |
312 | | JS_NULL_CLASS_EXT, |
313 | | JS_NULL_OBJECT_OPS |
314 | | }, |
315 | | eInterfacePrototype, |
316 | | false, |
317 | | prototypes::id::RTCCertificate, |
318 | | PrototypeTraits<prototypes::id::RTCCertificate>::Depth, |
319 | | sNativePropertyHooks, |
320 | | "[object RTCCertificatePrototype]", |
321 | | JS::GetRealmObjectPrototype |
322 | | }; |
323 | | |
324 | | bool |
325 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
326 | 0 | { |
327 | 0 | static bool sPrefValue; |
328 | 0 | static bool sPrefCacheSetUp = false; |
329 | 0 | if (!sPrefCacheSetUp) { |
330 | 0 | sPrefCacheSetUp = true; |
331 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "media.peerconnection.enabled"); |
332 | 0 | } |
333 | 0 |
|
334 | 0 | return sPrefValue; |
335 | 0 | } |
336 | | |
337 | | static const js::ClassOps sClassOps = { |
338 | | _addProperty, /* addProperty */ |
339 | | nullptr, /* delProperty */ |
340 | | nullptr, /* enumerate */ |
341 | | nullptr, /* newEnumerate */ |
342 | | nullptr, /* resolve */ |
343 | | nullptr, /* mayResolve */ |
344 | | _finalize, /* finalize */ |
345 | | nullptr, /* call */ |
346 | | nullptr, /* hasInstance */ |
347 | | nullptr, /* construct */ |
348 | | nullptr, /* trace */ |
349 | | }; |
350 | | |
351 | | static const js::ClassExtension sClassExtension = { |
352 | | nullptr, /* weakmapKeyDelegateOp */ |
353 | | _objectMoved /* objectMovedOp */ |
354 | | }; |
355 | | |
356 | | static const DOMJSClass sClass = { |
357 | | { "RTCCertificate", |
358 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
359 | | &sClassOps, |
360 | | JS_NULL_CLASS_SPEC, |
361 | | &sClassExtension, |
362 | | JS_NULL_OBJECT_OPS |
363 | | }, |
364 | | { prototypes::id::RTCCertificate, 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 }, |
365 | | IsBaseOf<nsISupports, mozilla::dom::RTCCertificate >::value, |
366 | | sNativePropertyHooks, |
367 | | FindAssociatedGlobalForNative<mozilla::dom::RTCCertificate>::Get, |
368 | | GetProtoObjectHandle, |
369 | | GetCCParticipant<mozilla::dom::RTCCertificate>::Get() |
370 | | }; |
371 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
372 | | "Must have the right minimal number of reserved slots."); |
373 | | static_assert(1 >= 1, |
374 | | "Must have enough reserved slots."); |
375 | | |
376 | | const JSClass* |
377 | | GetJSClass() |
378 | 0 | { |
379 | 0 | return sClass.ToJSClass(); |
380 | 0 | } |
381 | | |
382 | | bool |
383 | | Wrap(JSContext* aCx, mozilla::dom::RTCCertificate* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
384 | 0 | { |
385 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::RTCCertificate>::value, |
386 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
387 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::RTCCertificate*>(aObject) == |
388 | 0 | reinterpret_cast<mozilla::dom::RTCCertificate*>(aObject), |
389 | 0 | "Multiple inheritance for mozilla::dom::RTCCertificate is broken."); |
390 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
391 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
392 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
393 | 0 | "You should probably not be using Wrap() directly; use " |
394 | 0 | "GetOrCreateDOMReflector instead"); |
395 | 0 |
|
396 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
397 | 0 | "nsISupports must be on our primary inheritance chain"); |
398 | 0 |
|
399 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
400 | 0 | if (!global) { |
401 | 0 | return false; |
402 | 0 | } |
403 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
404 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
405 | 0 |
|
406 | 0 | // That might have ended up wrapping us already, due to the wonders |
407 | 0 | // of XBL. Check for that, and bail out as needed. |
408 | 0 | aReflector.set(aCache->GetWrapper()); |
409 | 0 | if (aReflector) { |
410 | | #ifdef DEBUG |
411 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
412 | | #endif // DEBUG |
413 | | return true; |
414 | 0 | } |
415 | 0 |
|
416 | 0 | JSAutoRealm ar(aCx, global); |
417 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
418 | 0 | if (!canonicalProto) { |
419 | 0 | return false; |
420 | 0 | } |
421 | 0 | JS::Rooted<JSObject*> proto(aCx); |
422 | 0 | if (aGivenProto) { |
423 | 0 | proto = aGivenProto; |
424 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
425 | 0 | // coming in, we changed compartments to that of "parent" so may need |
426 | 0 | // to wrap the proto here. |
427 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
428 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
429 | 0 | return false; |
430 | 0 | } |
431 | 0 | } |
432 | 0 | } else { |
433 | 0 | proto = canonicalProto; |
434 | 0 | } |
435 | 0 |
|
436 | 0 | BindingJSObjectCreator<mozilla::dom::RTCCertificate> creator(aCx); |
437 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
438 | 0 | if (!aReflector) { |
439 | 0 | return false; |
440 | 0 | } |
441 | 0 | |
442 | 0 | aCache->SetWrapper(aReflector); |
443 | 0 | creator.InitializationSucceeded(); |
444 | 0 |
|
445 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
446 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
447 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
448 | 0 | // otherwise we won't be able to properly recreate it later, since |
449 | 0 | // we won't know what proto to use. Note that we don't check |
450 | 0 | // aGivenProto here, since it's entirely possible (and even |
451 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
452 | 0 | // same as canonicalProto. |
453 | 0 | if (proto != canonicalProto) { |
454 | 0 | PreserveWrapper(aObject); |
455 | 0 | } |
456 | 0 |
|
457 | 0 | return true; |
458 | 0 | } |
459 | | |
460 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
461 | | nullptr, |
462 | | nullptr, |
463 | | nullptr, |
464 | | { sNativeProperties.Upcast(), nullptr }, |
465 | | prototypes::id::RTCCertificate, |
466 | | constructors::id::RTCCertificate, |
467 | | nullptr, |
468 | | &DefaultXrayExpandoObjectClass |
469 | | } }; |
470 | | |
471 | | void |
472 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
473 | 0 | { |
474 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
475 | 0 | if (!parentProto) { |
476 | 0 | return; |
477 | 0 | } |
478 | 0 | |
479 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
480 | 0 | if (!constructorProto) { |
481 | 0 | return; |
482 | 0 | } |
483 | 0 | |
484 | 0 | static bool sIdsInited = false; |
485 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
486 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
487 | 0 | return; |
488 | 0 | } |
489 | 0 | sIdsInited = true; |
490 | 0 | } |
491 | 0 |
|
492 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::RTCCertificate); |
493 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::RTCCertificate); |
494 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
495 | 0 | &sPrototypeClass.mBase, protoCache, |
496 | 0 | nullptr, |
497 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
498 | 0 | interfaceCache, |
499 | 0 | sNativeProperties.Upcast(), |
500 | 0 | nullptr, |
501 | 0 | "RTCCertificate", aDefineOnGlobal, |
502 | 0 | nullptr, |
503 | 0 | false); |
504 | 0 | } |
505 | | |
506 | | JSObject* |
507 | | GetConstructorObject(JSContext* aCx) |
508 | 0 | { |
509 | 0 | return GetConstructorObjectHandle(aCx); |
510 | 0 | } |
511 | | |
512 | | } // namespace RTCCertificate_Binding |
513 | | |
514 | | |
515 | | |
516 | | } // namespace dom |
517 | | } // namespace mozilla |