/work/obj-fuzz/dom/bindings/BeforeUnloadEventBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM BeforeUnloadEvent.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "BeforeUnloadEventBinding.h" |
4 | | #include "EventBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BeforeUnloadEvent.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/XrayExpandoClass.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
18 | | using namespace mozilla::dom::binding_detail; |
19 | | |
20 | | |
21 | | namespace BeforeUnloadEvent_Binding { |
22 | | |
23 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value, |
24 | | "Can't inherit from an interface with a different ownership model."); |
25 | | |
26 | | MOZ_CAN_RUN_SCRIPT static bool |
27 | | get_returnValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BeforeUnloadEvent* self, JSJitGetterCallArgs args) |
28 | 0 | { |
29 | 0 | AUTO_PROFILER_LABEL_FAST("get BeforeUnloadEvent.returnValue", DOM, cx); |
30 | 0 |
|
31 | 0 | DOMString result; |
32 | 0 | self->GetReturnValue(result); |
33 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
34 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
35 | 0 | return false; |
36 | 0 | } |
37 | 0 | return true; |
38 | 0 | } |
39 | | |
40 | | MOZ_CAN_RUN_SCRIPT static bool |
41 | | set_returnValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BeforeUnloadEvent* self, JSJitSetterCallArgs args) |
42 | 0 | { |
43 | 0 | AUTO_PROFILER_LABEL_FAST("set BeforeUnloadEvent.returnValue", DOM, cx); |
44 | 0 |
|
45 | 0 | binding_detail::FakeString arg0; |
46 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
47 | 0 | return false; |
48 | 0 | } |
49 | 0 | self->SetReturnValue(NonNullHelper(Constify(arg0))); |
50 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
51 | 0 |
|
52 | 0 | return true; |
53 | 0 | } |
54 | | |
55 | | static const JSJitInfo returnValue_getterinfo = { |
56 | | { (JSJitGetterOp)get_returnValue }, |
57 | | { prototypes::id::BeforeUnloadEvent }, |
58 | | { PrototypeTraits<prototypes::id::BeforeUnloadEvent>::Depth }, |
59 | | JSJitInfo::Getter, |
60 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
61 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
62 | | false, /* isInfallible. False in setters. */ |
63 | | false, /* isMovable. Not relevant for setters. */ |
64 | | false, /* isEliminatable. Not relevant for setters. */ |
65 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
66 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
67 | | false, /* isTypedMethod. Only relevant for methods. */ |
68 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
69 | | }; |
70 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
71 | | static_assert(0 < 1, "There is no slot for us"); |
72 | | static const JSJitInfo returnValue_setterinfo = { |
73 | | { (JSJitGetterOp)set_returnValue }, |
74 | | { prototypes::id::BeforeUnloadEvent }, |
75 | | { PrototypeTraits<prototypes::id::BeforeUnloadEvent>::Depth }, |
76 | | JSJitInfo::Setter, |
77 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
78 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
79 | | false, /* isInfallible. False in setters. */ |
80 | | false, /* isMovable. Not relevant for setters. */ |
81 | | false, /* isEliminatable. Not relevant for setters. */ |
82 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
83 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
84 | | false, /* isTypedMethod. Only relevant for methods. */ |
85 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
86 | | }; |
87 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
88 | | static_assert(0 < 1, "There is no slot for us"); |
89 | | |
90 | | MOZ_CAN_RUN_SCRIPT static bool |
91 | | get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BeforeUnloadEvent* self, JSJitGetterCallArgs args) |
92 | 0 | { |
93 | 0 | AUTO_PROFILER_LABEL_FAST("get BeforeUnloadEvent.isTrusted", DOM, cx); |
94 | 0 |
|
95 | 0 | bool result(self->IsTrusted()); |
96 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
97 | 0 | args.rval().setBoolean(result); |
98 | 0 | return true; |
99 | 0 | } |
100 | | |
101 | | static const JSJitInfo isTrusted_getterinfo = { |
102 | | { (JSJitGetterOp)get_isTrusted }, |
103 | | { prototypes::id::BeforeUnloadEvent }, |
104 | | { PrototypeTraits<prototypes::id::BeforeUnloadEvent>::Depth }, |
105 | | JSJitInfo::Getter, |
106 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
107 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
108 | | true, /* isInfallible. False in setters. */ |
109 | | true, /* isMovable. Not relevant for setters. */ |
110 | | true, /* isEliminatable. Not relevant for setters. */ |
111 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
112 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
113 | | false, /* isTypedMethod. Only relevant for methods. */ |
114 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
115 | | }; |
116 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
117 | | static_assert(0 < 1, "There is no slot for us"); |
118 | | |
119 | | static bool |
120 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
121 | 0 | { |
122 | 0 | mozilla::dom::BeforeUnloadEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::BeforeUnloadEvent>(obj); |
123 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
124 | 0 | // obviously can't preserve if we're not initialized. |
125 | 0 | if (self && self->GetWrapperPreserveColor()) { |
126 | 0 | PreserveWrapper(self); |
127 | 0 | } |
128 | 0 | return true; |
129 | 0 | } |
130 | | |
131 | | static void |
132 | | _finalize(js::FreeOp* fop, JSObject* obj) |
133 | 0 | { |
134 | 0 | mozilla::dom::BeforeUnloadEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::BeforeUnloadEvent>(obj); |
135 | 0 | if (self) { |
136 | 0 | ClearWrapper(self, self, obj); |
137 | 0 | AddForDeferredFinalization<mozilla::dom::BeforeUnloadEvent>(self); |
138 | 0 | } |
139 | 0 | } |
140 | | |
141 | | static size_t |
142 | | _objectMoved(JSObject* obj, JSObject* old) |
143 | 0 | { |
144 | 0 | mozilla::dom::BeforeUnloadEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::BeforeUnloadEvent>(obj); |
145 | 0 | if (self) { |
146 | 0 | UpdateWrapper(self, self, obj, old); |
147 | 0 | } |
148 | 0 |
|
149 | 0 | return 0; |
150 | 0 | } |
151 | | |
152 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
153 | | #if defined(__clang__) |
154 | | #pragma clang diagnostic push |
155 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
156 | | #endif |
157 | | static const JSPropertySpec sAttributes_specs[] = { |
158 | | { "returnValue", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &returnValue_getterinfo, GenericSetter<NormalThisPolicy>, &returnValue_setterinfo }, |
159 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
160 | | }; |
161 | | #if defined(__clang__) |
162 | | #pragma clang diagnostic pop |
163 | | #endif |
164 | | |
165 | | |
166 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
167 | | { nullptr, &sAttributes_specs[0] }, |
168 | | { nullptr, nullptr } |
169 | | }; |
170 | | |
171 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
172 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
173 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
174 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
175 | | |
176 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
177 | | #if defined(__clang__) |
178 | | #pragma clang diagnostic push |
179 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
180 | | #endif |
181 | | static const JSPropertySpec sUnforgeableAttributes_specs[] = { |
182 | | { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr }, |
183 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
184 | | }; |
185 | | #if defined(__clang__) |
186 | | #pragma clang diagnostic pop |
187 | | #endif |
188 | | |
189 | | |
190 | | static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = { |
191 | | { nullptr, &sUnforgeableAttributes_specs[0] }, |
192 | | { nullptr, nullptr } |
193 | | }; |
194 | | |
195 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
196 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
197 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
198 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
199 | | |
200 | | |
201 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
202 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
203 | | |
204 | | static const NativePropertiesN<2> sNativeProperties = { |
205 | | false, 0, |
206 | | false, 0, |
207 | | false, 0, |
208 | | true, 0 /* sAttributes */, |
209 | | false, 0, |
210 | | true, 1 /* sUnforgeableAttributes */, |
211 | | false, 0, |
212 | | -1, |
213 | | 2, |
214 | | sNativeProperties_sortedPropertyIndices, |
215 | | { |
216 | | { sAttributes, &sNativeProperties_propertyInfos[0] }, |
217 | | { sUnforgeableAttributes, &sNativeProperties_propertyInfos[1] } |
218 | | } |
219 | | }; |
220 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
221 | | "We have a property info count that is oversized"); |
222 | | |
223 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
224 | | { |
225 | | "Function", |
226 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
227 | | &sBoringInterfaceObjectClassClassOps, |
228 | | JS_NULL_CLASS_SPEC, |
229 | | JS_NULL_CLASS_EXT, |
230 | | &sInterfaceObjectClassObjectOps |
231 | | }, |
232 | | eInterface, |
233 | | true, |
234 | | prototypes::id::BeforeUnloadEvent, |
235 | | PrototypeTraits<prototypes::id::BeforeUnloadEvent>::Depth, |
236 | | sNativePropertyHooks, |
237 | | "function BeforeUnloadEvent() {\n [native code]\n}", |
238 | | Event_Binding::GetConstructorObject |
239 | | }; |
240 | | |
241 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
242 | | { |
243 | | "BeforeUnloadEventPrototype", |
244 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */), |
245 | | JS_NULL_CLASS_OPS, |
246 | | JS_NULL_CLASS_SPEC, |
247 | | JS_NULL_CLASS_EXT, |
248 | | JS_NULL_OBJECT_OPS |
249 | | }, |
250 | | eInterfacePrototype, |
251 | | false, |
252 | | prototypes::id::BeforeUnloadEvent, |
253 | | PrototypeTraits<prototypes::id::BeforeUnloadEvent>::Depth, |
254 | | sNativePropertyHooks, |
255 | | "[object BeforeUnloadEventPrototype]", |
256 | | Event_Binding::GetProtoObject |
257 | | }; |
258 | | |
259 | | static const js::ClassOps sClassOps = { |
260 | | _addProperty, /* addProperty */ |
261 | | nullptr, /* delProperty */ |
262 | | nullptr, /* enumerate */ |
263 | | nullptr, /* newEnumerate */ |
264 | | nullptr, /* resolve */ |
265 | | nullptr, /* mayResolve */ |
266 | | _finalize, /* finalize */ |
267 | | nullptr, /* call */ |
268 | | nullptr, /* hasInstance */ |
269 | | nullptr, /* construct */ |
270 | | nullptr, /* trace */ |
271 | | }; |
272 | | |
273 | | static const js::ClassExtension sClassExtension = { |
274 | | nullptr, /* weakmapKeyDelegateOp */ |
275 | | _objectMoved /* objectMovedOp */ |
276 | | }; |
277 | | |
278 | | static const DOMJSClass sClass = { |
279 | | { "BeforeUnloadEvent", |
280 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE, |
281 | | &sClassOps, |
282 | | JS_NULL_CLASS_SPEC, |
283 | | &sClassExtension, |
284 | | JS_NULL_OBJECT_OPS |
285 | | }, |
286 | | { prototypes::id::Event, prototypes::id::BeforeUnloadEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
287 | | IsBaseOf<nsISupports, mozilla::dom::BeforeUnloadEvent >::value, |
288 | | sNativePropertyHooks, |
289 | | FindAssociatedGlobalForNative<mozilla::dom::BeforeUnloadEvent>::Get, |
290 | | GetProtoObjectHandle, |
291 | | GetCCParticipant<mozilla::dom::BeforeUnloadEvent>::Get() |
292 | | }; |
293 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
294 | | "Must have the right minimal number of reserved slots."); |
295 | | static_assert(1 >= 1, |
296 | | "Must have enough reserved slots."); |
297 | | |
298 | | const JSClass* |
299 | | GetJSClass() |
300 | 0 | { |
301 | 0 | return sClass.ToJSClass(); |
302 | 0 | } |
303 | | |
304 | | bool |
305 | | Wrap(JSContext* aCx, mozilla::dom::BeforeUnloadEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
306 | 0 | { |
307 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::BeforeUnloadEvent>::value, |
308 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
309 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::BeforeUnloadEvent*>(aObject) == |
310 | 0 | reinterpret_cast<mozilla::dom::BeforeUnloadEvent*>(aObject), |
311 | 0 | "Multiple inheritance for mozilla::dom::BeforeUnloadEvent is broken."); |
312 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) == |
313 | 0 | reinterpret_cast<mozilla::dom::Event*>(aObject), |
314 | 0 | "Multiple inheritance for mozilla::dom::Event is broken."); |
315 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
316 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
317 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
318 | 0 | "You should probably not be using Wrap() directly; use " |
319 | 0 | "GetOrCreateDOMReflector instead"); |
320 | 0 |
|
321 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
322 | 0 | "nsISupports must be on our primary inheritance chain"); |
323 | 0 |
|
324 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
325 | 0 | if (!global) { |
326 | 0 | return false; |
327 | 0 | } |
328 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
329 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
330 | 0 |
|
331 | 0 | // That might have ended up wrapping us already, due to the wonders |
332 | 0 | // of XBL. Check for that, and bail out as needed. |
333 | 0 | aReflector.set(aCache->GetWrapper()); |
334 | 0 | if (aReflector) { |
335 | | #ifdef DEBUG |
336 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
337 | | #endif // DEBUG |
338 | | return true; |
339 | 0 | } |
340 | 0 |
|
341 | 0 | JSAutoRealm ar(aCx, global); |
342 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
343 | 0 | if (!canonicalProto) { |
344 | 0 | return false; |
345 | 0 | } |
346 | 0 | JS::Rooted<JSObject*> proto(aCx); |
347 | 0 | if (aGivenProto) { |
348 | 0 | proto = aGivenProto; |
349 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
350 | 0 | // coming in, we changed compartments to that of "parent" so may need |
351 | 0 | // to wrap the proto here. |
352 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
353 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
354 | 0 | return false; |
355 | 0 | } |
356 | 0 | } |
357 | 0 | } else { |
358 | 0 | proto = canonicalProto; |
359 | 0 | } |
360 | 0 |
|
361 | 0 | BindingJSObjectCreator<mozilla::dom::BeforeUnloadEvent> creator(aCx); |
362 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
363 | 0 | if (!aReflector) { |
364 | 0 | return false; |
365 | 0 | } |
366 | 0 | |
367 | 0 | aCache->SetWrapper(aReflector); |
368 | 0 |
|
369 | 0 | // Important: do unforgeable property setup after we have handed |
370 | 0 | // over ownership of the C++ object to obj as needed, so that if |
371 | 0 | // we fail and it ends up GCed it won't have problems in the |
372 | 0 | // finalizer trying to drop its ownership of the C++ object. |
373 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx, |
374 | 0 | &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject()); |
375 | 0 | if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) { |
376 | 0 | aCache->ReleaseWrapper(aObject); |
377 | 0 | aCache->ClearWrapper(); |
378 | 0 | return false; |
379 | 0 | } |
380 | 0 | creator.InitializationSucceeded(); |
381 | 0 |
|
382 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
383 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
384 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
385 | 0 | // otherwise we won't be able to properly recreate it later, since |
386 | 0 | // we won't know what proto to use. Note that we don't check |
387 | 0 | // aGivenProto here, since it's entirely possible (and even |
388 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
389 | 0 | // same as canonicalProto. |
390 | 0 | if (proto != canonicalProto) { |
391 | 0 | PreserveWrapper(aObject); |
392 | 0 | } |
393 | 0 |
|
394 | 0 | return true; |
395 | 0 | } |
396 | | |
397 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
398 | | nullptr, |
399 | | nullptr, |
400 | | nullptr, |
401 | | { sNativeProperties.Upcast(), nullptr }, |
402 | | prototypes::id::BeforeUnloadEvent, |
403 | | constructors::id::BeforeUnloadEvent, |
404 | | Event_Binding::sNativePropertyHooks, |
405 | | &DefaultXrayExpandoObjectClass |
406 | | } }; |
407 | | |
408 | | void |
409 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
410 | 0 | { |
411 | 0 | JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx)); |
412 | 0 | if (!parentProto) { |
413 | 0 | return; |
414 | 0 | } |
415 | 0 | |
416 | 0 | JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx)); |
417 | 0 | if (!constructorProto) { |
418 | 0 | return; |
419 | 0 | } |
420 | 0 | |
421 | 0 | static bool sIdsInited = false; |
422 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
423 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
424 | 0 | return; |
425 | 0 | } |
426 | 0 | sIdsInited = true; |
427 | 0 | } |
428 | 0 |
|
429 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::BeforeUnloadEvent); |
430 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::BeforeUnloadEvent); |
431 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
432 | 0 | &sPrototypeClass.mBase, protoCache, |
433 | 0 | nullptr, |
434 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
435 | 0 | interfaceCache, |
436 | 0 | sNativeProperties.Upcast(), |
437 | 0 | nullptr, |
438 | 0 | "BeforeUnloadEvent", aDefineOnGlobal, |
439 | 0 | nullptr, |
440 | 0 | false); |
441 | 0 |
|
442 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx); |
443 | 0 | { |
444 | 0 | JS::Rooted<JSObject*> holderProto(aCx, *protoCache); |
445 | 0 | unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto); |
446 | 0 | if (!unforgeableHolder) { |
447 | 0 | *protoCache = nullptr; |
448 | 0 | if (interfaceCache) { |
449 | 0 | *interfaceCache = nullptr; |
450 | 0 | } |
451 | 0 | return; |
452 | 0 | } |
453 | 0 | } |
454 | 0 |
|
455 | 0 | if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) { |
456 | 0 | *protoCache = nullptr; |
457 | 0 | if (interfaceCache) { |
458 | 0 | *interfaceCache = nullptr; |
459 | 0 | } |
460 | 0 | return; |
461 | 0 | } |
462 | 0 |
|
463 | 0 | if (*protoCache) { |
464 | 0 | js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE, |
465 | 0 | JS::ObjectValue(*unforgeableHolder)); |
466 | 0 | } |
467 | 0 | } |
468 | | |
469 | | JSObject* |
470 | | GetConstructorObject(JSContext* aCx) |
471 | 0 | { |
472 | 0 | return GetConstructorObjectHandle(aCx); |
473 | 0 | } |
474 | | |
475 | | } // namespace BeforeUnloadEvent_Binding |
476 | | |
477 | | |
478 | | |
479 | | } // namespace dom |
480 | | } // namespace mozilla |