/work/obj-fuzz/dom/bindings/ParentSHistoryBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM ParentSHistory.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "ParentSHistoryBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/DOMJSClass.h" |
8 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
9 | | #include "mozilla/dom/ParentSHistory.h" |
10 | | #include "mozilla/dom/PrimitiveConversions.h" |
11 | | #include "mozilla/dom/XrayExpandoClass.h" |
12 | | #include "nsContentUtils.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 ParentSHistory_Binding { |
22 | | |
23 | | MOZ_CAN_RUN_SCRIPT static bool |
24 | | get_count(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ParentSHistory* self, JSJitGetterCallArgs args) |
25 | 0 | { |
26 | 0 | AUTO_PROFILER_LABEL_FAST("get ParentSHistory.count", DOM, cx); |
27 | 0 |
|
28 | 0 | int32_t result(self->Count()); |
29 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
30 | 0 | args.rval().setInt32(int32_t(result)); |
31 | 0 | return true; |
32 | 0 | } |
33 | | |
34 | | static const JSJitInfo count_getterinfo = { |
35 | | { (JSJitGetterOp)get_count }, |
36 | | { prototypes::id::ParentSHistory }, |
37 | | { PrototypeTraits<prototypes::id::ParentSHistory>::Depth }, |
38 | | JSJitInfo::Getter, |
39 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
40 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
41 | | true, /* isInfallible. False in setters. */ |
42 | | true, /* isMovable. Not relevant for setters. */ |
43 | | true, /* isEliminatable. Not relevant for setters. */ |
44 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
45 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
46 | | false, /* isTypedMethod. Only relevant for methods. */ |
47 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
48 | | }; |
49 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
50 | | static_assert(0 < 1, "There is no slot for us"); |
51 | | |
52 | | MOZ_CAN_RUN_SCRIPT static bool |
53 | | get_index(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ParentSHistory* self, JSJitGetterCallArgs args) |
54 | 0 | { |
55 | 0 | AUTO_PROFILER_LABEL_FAST("get ParentSHistory.index", DOM, cx); |
56 | 0 |
|
57 | 0 | int32_t result(self->Index()); |
58 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
59 | 0 | args.rval().setInt32(int32_t(result)); |
60 | 0 | return true; |
61 | 0 | } |
62 | | |
63 | | static const JSJitInfo index_getterinfo = { |
64 | | { (JSJitGetterOp)get_index }, |
65 | | { prototypes::id::ParentSHistory }, |
66 | | { PrototypeTraits<prototypes::id::ParentSHistory>::Depth }, |
67 | | JSJitInfo::Getter, |
68 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
69 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
70 | | true, /* isInfallible. False in setters. */ |
71 | | true, /* isMovable. Not relevant for setters. */ |
72 | | true, /* isEliminatable. Not relevant for setters. */ |
73 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
74 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
75 | | false, /* isTypedMethod. Only relevant for methods. */ |
76 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
77 | | }; |
78 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
79 | | static_assert(0 < 1, "There is no slot for us"); |
80 | | |
81 | | static bool |
82 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
83 | 0 | { |
84 | 0 | mozilla::dom::ParentSHistory* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ParentSHistory>(obj); |
85 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
86 | 0 | // obviously can't preserve if we're not initialized. |
87 | 0 | if (self && self->GetWrapperPreserveColor()) { |
88 | 0 | PreserveWrapper(self); |
89 | 0 | } |
90 | 0 | return true; |
91 | 0 | } |
92 | | |
93 | | static void |
94 | | _finalize(js::FreeOp* fop, JSObject* obj) |
95 | 0 | { |
96 | 0 | mozilla::dom::ParentSHistory* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ParentSHistory>(obj); |
97 | 0 | if (self) { |
98 | 0 | ClearWrapper(self, self, obj); |
99 | 0 | AddForDeferredFinalization<mozilla::dom::ParentSHistory>(self); |
100 | 0 | } |
101 | 0 | } |
102 | | |
103 | | static size_t |
104 | | _objectMoved(JSObject* obj, JSObject* old) |
105 | 0 | { |
106 | 0 | mozilla::dom::ParentSHistory* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ParentSHistory>(obj); |
107 | 0 | if (self) { |
108 | 0 | UpdateWrapper(self, self, obj, old); |
109 | 0 | } |
110 | 0 |
|
111 | 0 | return 0; |
112 | 0 | } |
113 | | |
114 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
115 | | #if defined(__clang__) |
116 | | #pragma clang diagnostic push |
117 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
118 | | #endif |
119 | | static const JSPropertySpec sAttributes_specs[] = { |
120 | | { "count", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &count_getterinfo, nullptr, nullptr }, |
121 | | { "index", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &index_getterinfo, nullptr, nullptr }, |
122 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
123 | | }; |
124 | | #if defined(__clang__) |
125 | | #pragma clang diagnostic pop |
126 | | #endif |
127 | | |
128 | | |
129 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
130 | | { nullptr, &sAttributes_specs[0] }, |
131 | | { nullptr, nullptr } |
132 | | }; |
133 | | |
134 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
135 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
136 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
137 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
138 | | |
139 | | |
140 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
141 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
142 | | |
143 | | static const NativePropertiesN<1> sNativeProperties = { |
144 | | false, 0, |
145 | | false, 0, |
146 | | false, 0, |
147 | | true, 0 /* sAttributes */, |
148 | | false, 0, |
149 | | false, 0, |
150 | | false, 0, |
151 | | -1, |
152 | | 2, |
153 | | sNativeProperties_sortedPropertyIndices, |
154 | | { |
155 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
156 | | } |
157 | | }; |
158 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
159 | | "We have a property info count that is oversized"); |
160 | | |
161 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
162 | | { |
163 | | "Function", |
164 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
165 | | &sBoringInterfaceObjectClassClassOps, |
166 | | JS_NULL_CLASS_SPEC, |
167 | | JS_NULL_CLASS_EXT, |
168 | | &sInterfaceObjectClassObjectOps |
169 | | }, |
170 | | eInterface, |
171 | | true, |
172 | | prototypes::id::ParentSHistory, |
173 | | PrototypeTraits<prototypes::id::ParentSHistory>::Depth, |
174 | | sNativePropertyHooks, |
175 | | "function ParentSHistory() {\n [native code]\n}", |
176 | | JS::GetRealmFunctionPrototype |
177 | | }; |
178 | | |
179 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
180 | | { |
181 | | "ParentSHistoryPrototype", |
182 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
183 | | JS_NULL_CLASS_OPS, |
184 | | JS_NULL_CLASS_SPEC, |
185 | | JS_NULL_CLASS_EXT, |
186 | | JS_NULL_OBJECT_OPS |
187 | | }, |
188 | | eInterfacePrototype, |
189 | | false, |
190 | | prototypes::id::ParentSHistory, |
191 | | PrototypeTraits<prototypes::id::ParentSHistory>::Depth, |
192 | | sNativePropertyHooks, |
193 | | "[object ParentSHistoryPrototype]", |
194 | | JS::GetRealmObjectPrototype |
195 | | }; |
196 | | |
197 | | bool |
198 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
199 | 0 | { |
200 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
201 | 0 | } |
202 | | |
203 | | static const js::ClassOps sClassOps = { |
204 | | _addProperty, /* addProperty */ |
205 | | nullptr, /* delProperty */ |
206 | | nullptr, /* enumerate */ |
207 | | nullptr, /* newEnumerate */ |
208 | | nullptr, /* resolve */ |
209 | | nullptr, /* mayResolve */ |
210 | | _finalize, /* finalize */ |
211 | | nullptr, /* call */ |
212 | | nullptr, /* hasInstance */ |
213 | | nullptr, /* construct */ |
214 | | nullptr, /* trace */ |
215 | | }; |
216 | | |
217 | | static const js::ClassExtension sClassExtension = { |
218 | | nullptr, /* weakmapKeyDelegateOp */ |
219 | | _objectMoved /* objectMovedOp */ |
220 | | }; |
221 | | |
222 | | static const DOMJSClass sClass = { |
223 | | { "ParentSHistory", |
224 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
225 | | &sClassOps, |
226 | | JS_NULL_CLASS_SPEC, |
227 | | &sClassExtension, |
228 | | JS_NULL_OBJECT_OPS |
229 | | }, |
230 | | { prototypes::id::ParentSHistory, 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 }, |
231 | | IsBaseOf<nsISupports, mozilla::dom::ParentSHistory >::value, |
232 | | sNativePropertyHooks, |
233 | | FindAssociatedGlobalForNative<mozilla::dom::ParentSHistory>::Get, |
234 | | GetProtoObjectHandle, |
235 | | GetCCParticipant<mozilla::dom::ParentSHistory>::Get() |
236 | | }; |
237 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
238 | | "Must have the right minimal number of reserved slots."); |
239 | | static_assert(1 >= 1, |
240 | | "Must have enough reserved slots."); |
241 | | |
242 | | const JSClass* |
243 | | GetJSClass() |
244 | 0 | { |
245 | 0 | return sClass.ToJSClass(); |
246 | 0 | } |
247 | | |
248 | | bool |
249 | | Wrap(JSContext* aCx, mozilla::dom::ParentSHistory* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
250 | 0 | { |
251 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ParentSHistory>::value, |
252 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
253 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::ParentSHistory*>(aObject) == |
254 | 0 | reinterpret_cast<mozilla::dom::ParentSHistory*>(aObject), |
255 | 0 | "Multiple inheritance for mozilla::dom::ParentSHistory is broken."); |
256 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
257 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
258 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
259 | 0 | "You should probably not be using Wrap() directly; use " |
260 | 0 | "GetOrCreateDOMReflector instead"); |
261 | 0 |
|
262 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
263 | 0 | "nsISupports must be on our primary inheritance chain"); |
264 | 0 |
|
265 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
266 | 0 | if (!global) { |
267 | 0 | return false; |
268 | 0 | } |
269 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
270 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
271 | 0 |
|
272 | 0 | // That might have ended up wrapping us already, due to the wonders |
273 | 0 | // of XBL. Check for that, and bail out as needed. |
274 | 0 | aReflector.set(aCache->GetWrapper()); |
275 | 0 | if (aReflector) { |
276 | | #ifdef DEBUG |
277 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
278 | | #endif // DEBUG |
279 | | return true; |
280 | 0 | } |
281 | 0 |
|
282 | 0 | JSAutoRealm ar(aCx, global); |
283 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
284 | 0 | if (!canonicalProto) { |
285 | 0 | return false; |
286 | 0 | } |
287 | 0 | JS::Rooted<JSObject*> proto(aCx); |
288 | 0 | if (aGivenProto) { |
289 | 0 | proto = aGivenProto; |
290 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
291 | 0 | // coming in, we changed compartments to that of "parent" so may need |
292 | 0 | // to wrap the proto here. |
293 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
294 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
295 | 0 | return false; |
296 | 0 | } |
297 | 0 | } |
298 | 0 | } else { |
299 | 0 | proto = canonicalProto; |
300 | 0 | } |
301 | 0 |
|
302 | 0 | BindingJSObjectCreator<mozilla::dom::ParentSHistory> creator(aCx); |
303 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
304 | 0 | if (!aReflector) { |
305 | 0 | return false; |
306 | 0 | } |
307 | 0 | |
308 | 0 | aCache->SetWrapper(aReflector); |
309 | 0 | creator.InitializationSucceeded(); |
310 | 0 |
|
311 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
312 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
313 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
314 | 0 | // otherwise we won't be able to properly recreate it later, since |
315 | 0 | // we won't know what proto to use. Note that we don't check |
316 | 0 | // aGivenProto here, since it's entirely possible (and even |
317 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
318 | 0 | // same as canonicalProto. |
319 | 0 | if (proto != canonicalProto) { |
320 | 0 | PreserveWrapper(aObject); |
321 | 0 | } |
322 | 0 |
|
323 | 0 | return true; |
324 | 0 | } |
325 | | |
326 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
327 | | nullptr, |
328 | | nullptr, |
329 | | nullptr, |
330 | | { sNativeProperties.Upcast(), nullptr }, |
331 | | prototypes::id::ParentSHistory, |
332 | | constructors::id::ParentSHistory, |
333 | | nullptr, |
334 | | &DefaultXrayExpandoObjectClass |
335 | | } }; |
336 | | |
337 | | void |
338 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
339 | 0 | { |
340 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
341 | 0 | if (!parentProto) { |
342 | 0 | return; |
343 | 0 | } |
344 | 0 | |
345 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
346 | 0 | if (!constructorProto) { |
347 | 0 | return; |
348 | 0 | } |
349 | 0 | |
350 | 0 | static bool sIdsInited = false; |
351 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
352 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
353 | 0 | return; |
354 | 0 | } |
355 | 0 | sIdsInited = true; |
356 | 0 | } |
357 | 0 |
|
358 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ParentSHistory); |
359 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ParentSHistory); |
360 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
361 | 0 | &sPrototypeClass.mBase, protoCache, |
362 | 0 | nullptr, |
363 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
364 | 0 | interfaceCache, |
365 | 0 | sNativeProperties.Upcast(), |
366 | 0 | nullptr, |
367 | 0 | "ParentSHistory", aDefineOnGlobal, |
368 | 0 | nullptr, |
369 | 0 | false); |
370 | 0 | } |
371 | | |
372 | | JSObject* |
373 | | GetConstructorObject(JSContext* aCx) |
374 | 0 | { |
375 | 0 | return GetConstructorObjectHandle(aCx); |
376 | 0 | } |
377 | | |
378 | | } // namespace ParentSHistory_Binding |
379 | | |
380 | | |
381 | | |
382 | | } // namespace dom |
383 | | } // namespace mozilla |