/work/obj-fuzz/dom/bindings/PluginCrashedEventBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PluginCrashedEvent.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "EventBinding.h" |
5 | | #include "PluginCrashedEventBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/Nullable.h" |
12 | | #include "mozilla/dom/PluginCrashedEvent.h" |
13 | | #include "mozilla/dom/PrimitiveConversions.h" |
14 | | #include "mozilla/dom/ScriptSettings.h" |
15 | | #include "mozilla/dom/SimpleGlobalObject.h" |
16 | | #include "mozilla/dom/XrayExpandoClass.h" |
17 | | #include "nsContentUtils.h" |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | |
22 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
23 | | using namespace mozilla::dom::binding_detail; |
24 | | |
25 | | |
26 | | |
27 | | PluginCrashedEventInit::PluginCrashedEventInit() |
28 | | : EventInit(FastDictionaryInitializer()) |
29 | 0 | { |
30 | 0 | // Safe to pass a null context if we pass a null value |
31 | 0 | Init(nullptr, JS::NullHandleValue); |
32 | 0 | } |
33 | | |
34 | | |
35 | | |
36 | | bool |
37 | | PluginCrashedEventInit::InitIds(JSContext* cx, PluginCrashedEventInitAtoms* atomsCache) |
38 | 0 | { |
39 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
40 | 0 |
|
41 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
42 | 0 | // uninitialized. |
43 | 0 | if (!atomsCache->submittedCrashReport_id.init(cx, "submittedCrashReport") || |
44 | 0 | !atomsCache->pluginName_id.init(cx, "pluginName") || |
45 | 0 | !atomsCache->pluginID_id.init(cx, "pluginID") || |
46 | 0 | !atomsCache->pluginFilename_id.init(cx, "pluginFilename") || |
47 | 0 | !atomsCache->pluginDumpID_id.init(cx, "pluginDumpID") || |
48 | 0 | !atomsCache->gmpPlugin_id.init(cx, "gmpPlugin") || |
49 | 0 | !atomsCache->browserDumpID_id.init(cx, "browserDumpID")) { |
50 | 0 | return false; |
51 | 0 | } |
52 | 0 | return true; |
53 | 0 | } |
54 | | |
55 | | bool |
56 | | PluginCrashedEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
57 | 0 | { |
58 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
59 | 0 | // Since in that case we will not have to do any property gets |
60 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
61 | 0 | // checkers by static analysis tools |
62 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
63 | 0 | PluginCrashedEventInitAtoms* atomsCache = nullptr; |
64 | 0 | if (cx) { |
65 | 0 | atomsCache = GetAtomCache<PluginCrashedEventInitAtoms>(cx); |
66 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
67 | 0 | return false; |
68 | 0 | } |
69 | 0 | } |
70 | 0 | |
71 | 0 | // Per spec, we init the parent's members first |
72 | 0 | if (!EventInit::Init(cx, val)) { |
73 | 0 | return false; |
74 | 0 | } |
75 | 0 | |
76 | 0 | bool isNull = val.isNullOrUndefined(); |
77 | 0 | // We only need these if !isNull, in which case we have |cx|. |
78 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
79 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
80 | 0 | if (!isNull) { |
81 | 0 | MOZ_ASSERT(cx); |
82 | 0 | object.emplace(cx, &val.toObject()); |
83 | 0 | temp.emplace(cx); |
84 | 0 | } |
85 | 0 | if (!isNull) { |
86 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->browserDumpID_id, temp.ptr())) { |
87 | 0 | return false; |
88 | 0 | } |
89 | 0 | } |
90 | 0 | if (!isNull && !temp->isUndefined()) { |
91 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, mBrowserDumpID)) { |
92 | 0 | return false; |
93 | 0 | } |
94 | 0 | } else { |
95 | 0 | mBrowserDumpID.SetIsVoid(true); |
96 | 0 | } |
97 | 0 | mIsAnyMemberPresent = true; |
98 | 0 |
|
99 | 0 | if (!isNull) { |
100 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->gmpPlugin_id, temp.ptr())) { |
101 | 0 | return false; |
102 | 0 | } |
103 | 0 | } |
104 | 0 | if (!isNull && !temp->isUndefined()) { |
105 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mGmpPlugin)) { |
106 | 0 | return false; |
107 | 0 | } |
108 | 0 | } else { |
109 | 0 | mGmpPlugin = false; |
110 | 0 | } |
111 | 0 | mIsAnyMemberPresent = true; |
112 | 0 |
|
113 | 0 | if (!isNull) { |
114 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->pluginDumpID_id, temp.ptr())) { |
115 | 0 | return false; |
116 | 0 | } |
117 | 0 | } |
118 | 0 | if (!isNull && !temp->isUndefined()) { |
119 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPluginDumpID)) { |
120 | 0 | return false; |
121 | 0 | } |
122 | 0 | } else { |
123 | 0 | static const char16_t data[] = { 0 }; |
124 | 0 | mPluginDumpID.Rebind(data, ArrayLength(data) - 1); |
125 | 0 | } |
126 | 0 | mIsAnyMemberPresent = true; |
127 | 0 |
|
128 | 0 | if (!isNull) { |
129 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->pluginFilename_id, temp.ptr())) { |
130 | 0 | return false; |
131 | 0 | } |
132 | 0 | } |
133 | 0 | if (!isNull && !temp->isUndefined()) { |
134 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, mPluginFilename)) { |
135 | 0 | return false; |
136 | 0 | } |
137 | 0 | } else { |
138 | 0 | mPluginFilename.SetIsVoid(true); |
139 | 0 | } |
140 | 0 | mIsAnyMemberPresent = true; |
141 | 0 |
|
142 | 0 | if (!isNull) { |
143 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->pluginID_id, temp.ptr())) { |
144 | 0 | return false; |
145 | 0 | } |
146 | 0 | } |
147 | 0 | if (!isNull && !temp->isUndefined()) { |
148 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mPluginID)) { |
149 | 0 | return false; |
150 | 0 | } |
151 | 0 | } else { |
152 | 0 | mPluginID = 0U; |
153 | 0 | } |
154 | 0 | mIsAnyMemberPresent = true; |
155 | 0 |
|
156 | 0 | if (!isNull) { |
157 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->pluginName_id, temp.ptr())) { |
158 | 0 | return false; |
159 | 0 | } |
160 | 0 | } |
161 | 0 | if (!isNull && !temp->isUndefined()) { |
162 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPluginName)) { |
163 | 0 | return false; |
164 | 0 | } |
165 | 0 | } else { |
166 | 0 | static const char16_t data[] = { 0 }; |
167 | 0 | mPluginName.Rebind(data, ArrayLength(data) - 1); |
168 | 0 | } |
169 | 0 | mIsAnyMemberPresent = true; |
170 | 0 |
|
171 | 0 | if (!isNull) { |
172 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->submittedCrashReport_id, temp.ptr())) { |
173 | 0 | return false; |
174 | 0 | } |
175 | 0 | } |
176 | 0 | if (!isNull && !temp->isUndefined()) { |
177 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mSubmittedCrashReport)) { |
178 | 0 | return false; |
179 | 0 | } |
180 | 0 | } else { |
181 | 0 | mSubmittedCrashReport = false; |
182 | 0 | } |
183 | 0 | mIsAnyMemberPresent = true; |
184 | 0 | return true; |
185 | 0 | } |
186 | | |
187 | | bool |
188 | | PluginCrashedEventInit::Init(const nsAString& aJSON) |
189 | 0 | { |
190 | 0 | AutoJSAPI jsapi; |
191 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
192 | 0 | if (!cleanGlobal) { |
193 | 0 | return false; |
194 | 0 | } |
195 | 0 | if (!jsapi.Init(cleanGlobal)) { |
196 | 0 | return false; |
197 | 0 | } |
198 | 0 | JSContext* cx = jsapi.cx(); |
199 | 0 | JS::Rooted<JS::Value> json(cx); |
200 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
201 | 0 | NS_ENSURE_TRUE(ok, false); |
202 | 0 | return Init(cx, json); |
203 | 0 | } |
204 | | |
205 | | bool |
206 | | PluginCrashedEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
207 | 0 | { |
208 | 0 | PluginCrashedEventInitAtoms* atomsCache = GetAtomCache<PluginCrashedEventInitAtoms>(cx); |
209 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
210 | 0 | return false; |
211 | 0 | } |
212 | 0 | |
213 | 0 | // Per spec, we define the parent's members first |
214 | 0 | if (!EventInit::ToObjectInternal(cx, rval)) { |
215 | 0 | return false; |
216 | 0 | } |
217 | 0 | JS::Rooted<JSObject*> obj(cx, &rval.toObject()); |
218 | 0 |
|
219 | 0 | do { |
220 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
221 | 0 | JS::Rooted<JS::Value> temp(cx); |
222 | 0 | nsString const & currentValue = mBrowserDumpID; |
223 | 0 | if (!xpc::StringToJsval(cx, currentValue, &temp)) { |
224 | 0 | return false; |
225 | 0 | } |
226 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->browserDumpID_id, temp, JSPROP_ENUMERATE)) { |
227 | 0 | return false; |
228 | 0 | } |
229 | 0 | break; |
230 | 0 | } while(false); |
231 | 0 |
|
232 | 0 | do { |
233 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
234 | 0 | JS::Rooted<JS::Value> temp(cx); |
235 | 0 | bool const & currentValue = mGmpPlugin; |
236 | 0 | temp.setBoolean(currentValue); |
237 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->gmpPlugin_id, temp, JSPROP_ENUMERATE)) { |
238 | 0 | return false; |
239 | 0 | } |
240 | 0 | break; |
241 | 0 | } while(false); |
242 | 0 |
|
243 | 0 | do { |
244 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
245 | 0 | JS::Rooted<JS::Value> temp(cx); |
246 | 0 | nsString const & currentValue = mPluginDumpID; |
247 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
248 | 0 | return false; |
249 | 0 | } |
250 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->pluginDumpID_id, temp, JSPROP_ENUMERATE)) { |
251 | 0 | return false; |
252 | 0 | } |
253 | 0 | break; |
254 | 0 | } while(false); |
255 | 0 |
|
256 | 0 | do { |
257 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
258 | 0 | JS::Rooted<JS::Value> temp(cx); |
259 | 0 | nsString const & currentValue = mPluginFilename; |
260 | 0 | if (!xpc::StringToJsval(cx, currentValue, &temp)) { |
261 | 0 | return false; |
262 | 0 | } |
263 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->pluginFilename_id, temp, JSPROP_ENUMERATE)) { |
264 | 0 | return false; |
265 | 0 | } |
266 | 0 | break; |
267 | 0 | } while(false); |
268 | 0 |
|
269 | 0 | do { |
270 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
271 | 0 | JS::Rooted<JS::Value> temp(cx); |
272 | 0 | uint32_t const & currentValue = mPluginID; |
273 | 0 | temp.setNumber(currentValue); |
274 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->pluginID_id, temp, JSPROP_ENUMERATE)) { |
275 | 0 | return false; |
276 | 0 | } |
277 | 0 | break; |
278 | 0 | } while(false); |
279 | 0 |
|
280 | 0 | do { |
281 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
282 | 0 | JS::Rooted<JS::Value> temp(cx); |
283 | 0 | nsString const & currentValue = mPluginName; |
284 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
285 | 0 | return false; |
286 | 0 | } |
287 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->pluginName_id, temp, JSPROP_ENUMERATE)) { |
288 | 0 | return false; |
289 | 0 | } |
290 | 0 | break; |
291 | 0 | } while(false); |
292 | 0 |
|
293 | 0 | do { |
294 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
295 | 0 | JS::Rooted<JS::Value> temp(cx); |
296 | 0 | bool const & currentValue = mSubmittedCrashReport; |
297 | 0 | temp.setBoolean(currentValue); |
298 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->submittedCrashReport_id, temp, JSPROP_ENUMERATE)) { |
299 | 0 | return false; |
300 | 0 | } |
301 | 0 | break; |
302 | 0 | } while(false); |
303 | 0 |
|
304 | 0 | return true; |
305 | 0 | } |
306 | | |
307 | | bool |
308 | | PluginCrashedEventInit::ToJSON(nsAString& aJSON) const |
309 | 0 | { |
310 | 0 | AutoJSAPI jsapi; |
311 | 0 | jsapi.Init(); |
312 | 0 | JSContext *cx = jsapi.cx(); |
313 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
314 | 0 | // because we'll only be creating objects, in ways that have no |
315 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
316 | 0 | // which likewise guarantees no side-effects for the sorts of |
317 | 0 | // things we will pass it. |
318 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
319 | 0 | JS::Rooted<JS::Value> val(cx); |
320 | 0 | if (!ToObjectInternal(cx, &val)) { |
321 | 0 | return false; |
322 | 0 | } |
323 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
324 | 0 | return StringifyToJSON(cx, obj, aJSON); |
325 | 0 | } |
326 | | |
327 | | void |
328 | | PluginCrashedEventInit::TraceDictionary(JSTracer* trc) |
329 | 0 | { |
330 | 0 | EventInit::TraceDictionary(trc); |
331 | 0 | } |
332 | | |
333 | | PluginCrashedEventInit& |
334 | | PluginCrashedEventInit::operator=(const PluginCrashedEventInit& aOther) |
335 | 0 | { |
336 | 0 | EventInit::operator=(aOther); |
337 | 0 | mBrowserDumpID = aOther.mBrowserDumpID; |
338 | 0 | mGmpPlugin = aOther.mGmpPlugin; |
339 | 0 | mPluginDumpID = aOther.mPluginDumpID; |
340 | 0 | mPluginFilename = aOther.mPluginFilename; |
341 | 0 | mPluginID = aOther.mPluginID; |
342 | 0 | mPluginName = aOther.mPluginName; |
343 | 0 | mSubmittedCrashReport = aOther.mSubmittedCrashReport; |
344 | 0 | return *this; |
345 | 0 | } |
346 | | |
347 | | namespace binding_detail { |
348 | | } // namespace binding_detail |
349 | | |
350 | | |
351 | | namespace PluginCrashedEvent_Binding { |
352 | | |
353 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value, |
354 | | "Can't inherit from an interface with a different ownership model."); |
355 | | |
356 | | MOZ_CAN_RUN_SCRIPT static bool |
357 | | get_pluginID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
358 | 0 | { |
359 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.pluginID", DOM, cx); |
360 | 0 |
|
361 | 0 | uint32_t result(self->PluginID()); |
362 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
363 | 0 | args.rval().setNumber(result); |
364 | 0 | return true; |
365 | 0 | } |
366 | | |
367 | | static const JSJitInfo pluginID_getterinfo = { |
368 | | { (JSJitGetterOp)get_pluginID }, |
369 | | { prototypes::id::PluginCrashedEvent }, |
370 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
371 | | JSJitInfo::Getter, |
372 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
373 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
374 | | true, /* isInfallible. False in setters. */ |
375 | | false, /* isMovable. Not relevant for setters. */ |
376 | | false, /* isEliminatable. Not relevant for setters. */ |
377 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
378 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
379 | | false, /* isTypedMethod. Only relevant for methods. */ |
380 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
381 | | }; |
382 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
383 | | static_assert(0 < 1, "There is no slot for us"); |
384 | | |
385 | | MOZ_CAN_RUN_SCRIPT static bool |
386 | | get_pluginDumpID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
387 | 0 | { |
388 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.pluginDumpID", DOM, cx); |
389 | 0 |
|
390 | 0 | DOMString result; |
391 | 0 | self->GetPluginDumpID(result); |
392 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
393 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
394 | 0 | return false; |
395 | 0 | } |
396 | 0 | return true; |
397 | 0 | } |
398 | | |
399 | | static const JSJitInfo pluginDumpID_getterinfo = { |
400 | | { (JSJitGetterOp)get_pluginDumpID }, |
401 | | { prototypes::id::PluginCrashedEvent }, |
402 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
403 | | JSJitInfo::Getter, |
404 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
405 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
406 | | false, /* isInfallible. False in setters. */ |
407 | | false, /* isMovable. Not relevant for setters. */ |
408 | | false, /* isEliminatable. Not relevant for setters. */ |
409 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
410 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
411 | | false, /* isTypedMethod. Only relevant for methods. */ |
412 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
413 | | }; |
414 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
415 | | static_assert(0 < 1, "There is no slot for us"); |
416 | | |
417 | | MOZ_CAN_RUN_SCRIPT static bool |
418 | | get_pluginName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
419 | 0 | { |
420 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.pluginName", DOM, cx); |
421 | 0 |
|
422 | 0 | DOMString result; |
423 | 0 | self->GetPluginName(result); |
424 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
425 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
426 | 0 | return false; |
427 | 0 | } |
428 | 0 | return true; |
429 | 0 | } |
430 | | |
431 | | static const JSJitInfo pluginName_getterinfo = { |
432 | | { (JSJitGetterOp)get_pluginName }, |
433 | | { prototypes::id::PluginCrashedEvent }, |
434 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
435 | | JSJitInfo::Getter, |
436 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
437 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
438 | | false, /* isInfallible. False in setters. */ |
439 | | false, /* isMovable. Not relevant for setters. */ |
440 | | false, /* isEliminatable. Not relevant for setters. */ |
441 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
442 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
443 | | false, /* isTypedMethod. Only relevant for methods. */ |
444 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
445 | | }; |
446 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
447 | | static_assert(0 < 1, "There is no slot for us"); |
448 | | |
449 | | MOZ_CAN_RUN_SCRIPT static bool |
450 | | get_browserDumpID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
451 | 0 | { |
452 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.browserDumpID", DOM, cx); |
453 | 0 |
|
454 | 0 | DOMString result; |
455 | 0 | self->GetBrowserDumpID(result); |
456 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
457 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
458 | 0 | return false; |
459 | 0 | } |
460 | 0 | return true; |
461 | 0 | } |
462 | | |
463 | | static const JSJitInfo browserDumpID_getterinfo = { |
464 | | { (JSJitGetterOp)get_browserDumpID }, |
465 | | { prototypes::id::PluginCrashedEvent }, |
466 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
467 | | JSJitInfo::Getter, |
468 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
469 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
470 | | false, /* isInfallible. False in setters. */ |
471 | | false, /* isMovable. Not relevant for setters. */ |
472 | | false, /* isEliminatable. Not relevant for setters. */ |
473 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
474 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
475 | | false, /* isTypedMethod. Only relevant for methods. */ |
476 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
477 | | }; |
478 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
479 | | static_assert(0 < 1, "There is no slot for us"); |
480 | | |
481 | | MOZ_CAN_RUN_SCRIPT static bool |
482 | | get_pluginFilename(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
483 | 0 | { |
484 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.pluginFilename", DOM, cx); |
485 | 0 |
|
486 | 0 | DOMString result; |
487 | 0 | self->GetPluginFilename(result); |
488 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
489 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
490 | 0 | return false; |
491 | 0 | } |
492 | 0 | return true; |
493 | 0 | } |
494 | | |
495 | | static const JSJitInfo pluginFilename_getterinfo = { |
496 | | { (JSJitGetterOp)get_pluginFilename }, |
497 | | { prototypes::id::PluginCrashedEvent }, |
498 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
499 | | JSJitInfo::Getter, |
500 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
501 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
502 | | false, /* isInfallible. False in setters. */ |
503 | | false, /* isMovable. Not relevant for setters. */ |
504 | | false, /* isEliminatable. Not relevant for setters. */ |
505 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
506 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
507 | | false, /* isTypedMethod. Only relevant for methods. */ |
508 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
509 | | }; |
510 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
511 | | static_assert(0 < 1, "There is no slot for us"); |
512 | | |
513 | | MOZ_CAN_RUN_SCRIPT static bool |
514 | | get_submittedCrashReport(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
515 | 0 | { |
516 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.submittedCrashReport", DOM, cx); |
517 | 0 |
|
518 | 0 | bool result(self->SubmittedCrashReport()); |
519 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
520 | 0 | args.rval().setBoolean(result); |
521 | 0 | return true; |
522 | 0 | } |
523 | | |
524 | | static const JSJitInfo submittedCrashReport_getterinfo = { |
525 | | { (JSJitGetterOp)get_submittedCrashReport }, |
526 | | { prototypes::id::PluginCrashedEvent }, |
527 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
528 | | JSJitInfo::Getter, |
529 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
530 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
531 | | true, /* isInfallible. False in setters. */ |
532 | | false, /* isMovable. Not relevant for setters. */ |
533 | | false, /* isEliminatable. Not relevant for setters. */ |
534 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
535 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
536 | | false, /* isTypedMethod. Only relevant for methods. */ |
537 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
538 | | }; |
539 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
540 | | static_assert(0 < 1, "There is no slot for us"); |
541 | | |
542 | | MOZ_CAN_RUN_SCRIPT static bool |
543 | | get_gmpPlugin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
544 | 0 | { |
545 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.gmpPlugin", DOM, cx); |
546 | 0 |
|
547 | 0 | bool result(self->GmpPlugin()); |
548 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
549 | 0 | args.rval().setBoolean(result); |
550 | 0 | return true; |
551 | 0 | } |
552 | | |
553 | | static const JSJitInfo gmpPlugin_getterinfo = { |
554 | | { (JSJitGetterOp)get_gmpPlugin }, |
555 | | { prototypes::id::PluginCrashedEvent }, |
556 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
557 | | JSJitInfo::Getter, |
558 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
559 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
560 | | true, /* isInfallible. False in setters. */ |
561 | | false, /* isMovable. Not relevant for setters. */ |
562 | | false, /* isEliminatable. Not relevant for setters. */ |
563 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
564 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
565 | | false, /* isTypedMethod. Only relevant for methods. */ |
566 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
567 | | }; |
568 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
569 | | static_assert(0 < 1, "There is no slot for us"); |
570 | | |
571 | | MOZ_CAN_RUN_SCRIPT static bool |
572 | | get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PluginCrashedEvent* self, JSJitGetterCallArgs args) |
573 | 0 | { |
574 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginCrashedEvent.isTrusted", DOM, cx); |
575 | 0 |
|
576 | 0 | bool result(self->IsTrusted()); |
577 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
578 | 0 | args.rval().setBoolean(result); |
579 | 0 | return true; |
580 | 0 | } |
581 | | |
582 | | static const JSJitInfo isTrusted_getterinfo = { |
583 | | { (JSJitGetterOp)get_isTrusted }, |
584 | | { prototypes::id::PluginCrashedEvent }, |
585 | | { PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth }, |
586 | | JSJitInfo::Getter, |
587 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
588 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
589 | | true, /* isInfallible. False in setters. */ |
590 | | true, /* isMovable. Not relevant for setters. */ |
591 | | true, /* isEliminatable. Not relevant for setters. */ |
592 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
593 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
594 | | false, /* isTypedMethod. Only relevant for methods. */ |
595 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
596 | | }; |
597 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
598 | | static_assert(0 < 1, "There is no slot for us"); |
599 | | |
600 | | static bool |
601 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
602 | 0 | { |
603 | 0 | mozilla::dom::PluginCrashedEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PluginCrashedEvent>(obj); |
604 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
605 | 0 | // obviously can't preserve if we're not initialized. |
606 | 0 | if (self && self->GetWrapperPreserveColor()) { |
607 | 0 | PreserveWrapper(self); |
608 | 0 | } |
609 | 0 | return true; |
610 | 0 | } |
611 | | |
612 | | static void |
613 | | _finalize(js::FreeOp* fop, JSObject* obj) |
614 | 0 | { |
615 | 0 | mozilla::dom::PluginCrashedEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PluginCrashedEvent>(obj); |
616 | 0 | if (self) { |
617 | 0 | ClearWrapper(self, self, obj); |
618 | 0 | AddForDeferredFinalization<mozilla::dom::PluginCrashedEvent>(self); |
619 | 0 | } |
620 | 0 | } |
621 | | |
622 | | static size_t |
623 | | _objectMoved(JSObject* obj, JSObject* old) |
624 | 0 | { |
625 | 0 | mozilla::dom::PluginCrashedEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PluginCrashedEvent>(obj); |
626 | 0 | if (self) { |
627 | 0 | UpdateWrapper(self, self, obj, old); |
628 | 0 | } |
629 | 0 |
|
630 | 0 | return 0; |
631 | 0 | } |
632 | | |
633 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
634 | | #if defined(__clang__) |
635 | | #pragma clang diagnostic push |
636 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
637 | | #endif |
638 | | static const JSPropertySpec sAttributes_specs[] = { |
639 | | { "pluginID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pluginID_getterinfo, nullptr, nullptr }, |
640 | | { "pluginDumpID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pluginDumpID_getterinfo, nullptr, nullptr }, |
641 | | { "pluginName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pluginName_getterinfo, nullptr, nullptr }, |
642 | | { "browserDumpID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &browserDumpID_getterinfo, nullptr, nullptr }, |
643 | | { "pluginFilename", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pluginFilename_getterinfo, nullptr, nullptr }, |
644 | | { "submittedCrashReport", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &submittedCrashReport_getterinfo, nullptr, nullptr }, |
645 | | { "gmpPlugin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &gmpPlugin_getterinfo, nullptr, nullptr }, |
646 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
647 | | }; |
648 | | #if defined(__clang__) |
649 | | #pragma clang diagnostic pop |
650 | | #endif |
651 | | |
652 | | |
653 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
654 | | { nullptr, &sAttributes_specs[0] }, |
655 | | { nullptr, nullptr } |
656 | | }; |
657 | | |
658 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
659 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
660 | | static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
661 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
662 | | |
663 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
664 | | #if defined(__clang__) |
665 | | #pragma clang diagnostic push |
666 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
667 | | #endif |
668 | | static const JSPropertySpec sUnforgeableAttributes_specs[] = { |
669 | | { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr }, |
670 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
671 | | }; |
672 | | #if defined(__clang__) |
673 | | #pragma clang diagnostic pop |
674 | | #endif |
675 | | |
676 | | |
677 | | static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = { |
678 | | { nullptr, &sUnforgeableAttributes_specs[0] }, |
679 | | { nullptr, nullptr } |
680 | | }; |
681 | | |
682 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
683 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
684 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
685 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
686 | | |
687 | | |
688 | | static uint16_t sNativeProperties_sortedPropertyIndices[8]; |
689 | | static PropertyInfo sNativeProperties_propertyInfos[8]; |
690 | | |
691 | | static const NativePropertiesN<2> sNativeProperties = { |
692 | | false, 0, |
693 | | false, 0, |
694 | | false, 0, |
695 | | true, 0 /* sAttributes */, |
696 | | false, 0, |
697 | | true, 1 /* sUnforgeableAttributes */, |
698 | | false, 0, |
699 | | -1, |
700 | | 8, |
701 | | sNativeProperties_sortedPropertyIndices, |
702 | | { |
703 | | { sAttributes, &sNativeProperties_propertyInfos[0] }, |
704 | | { sUnforgeableAttributes, &sNativeProperties_propertyInfos[7] } |
705 | | } |
706 | | }; |
707 | | static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
708 | | "We have a property info count that is oversized"); |
709 | | |
710 | | static bool |
711 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
712 | 0 | { |
713 | 0 | AUTO_PROFILER_LABEL_FAST("PluginCrashedEvent constructor", DOM, cx); |
714 | 0 |
|
715 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
716 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
717 | 0 | if (!args.isConstructing()) { |
718 | 0 | // XXXbz wish I could get the name from the callee instead of |
719 | 0 | // Adding more relocations |
720 | 0 | return ThrowConstructorWithoutNew(cx, "PluginCrashedEvent"); |
721 | 0 | } |
722 | 0 | |
723 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
724 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
725 | 0 | return false; |
726 | 0 | } |
727 | 0 | |
728 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
729 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PluginCrashedEvent"); |
730 | 0 | } |
731 | 0 | GlobalObject global(cx, obj); |
732 | 0 | if (global.Failed()) { |
733 | 0 | return false; |
734 | 0 | } |
735 | 0 | |
736 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
737 | 0 | binding_detail::FakeString arg0; |
738 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
739 | 0 | return false; |
740 | 0 | } |
741 | 0 | binding_detail::FastPluginCrashedEventInit arg1; |
742 | 0 | if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of PluginCrashedEvent.constructor", false)) { |
743 | 0 | return false; |
744 | 0 | } |
745 | 0 | Maybe<JSAutoRealm> ar; |
746 | 0 | if (objIsXray) { |
747 | 0 | obj = js::CheckedUnwrap(obj); |
748 | 0 | if (!obj) { |
749 | 0 | return false; |
750 | 0 | } |
751 | 0 | ar.emplace(cx, obj); |
752 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
753 | 0 | return false; |
754 | 0 | } |
755 | 0 | } |
756 | 0 | FastErrorResult rv; |
757 | 0 | auto result(StrongOrRawPtr<mozilla::dom::PluginCrashedEvent>(mozilla::dom::PluginCrashedEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv))); |
758 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
759 | 0 | return false; |
760 | 0 | } |
761 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
762 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
763 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
764 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
765 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
766 | 0 | return false; |
767 | 0 | } |
768 | 0 | return true; |
769 | 0 | } |
770 | | |
771 | | static const js::ClassOps sInterfaceObjectClassOps = { |
772 | | nullptr, /* addProperty */ |
773 | | nullptr, /* delProperty */ |
774 | | nullptr, /* enumerate */ |
775 | | nullptr, /* newEnumerate */ |
776 | | nullptr, /* resolve */ |
777 | | nullptr, /* mayResolve */ |
778 | | nullptr, /* finalize */ |
779 | | _constructor, /* call */ |
780 | | nullptr, /* hasInstance */ |
781 | | _constructor, /* construct */ |
782 | | nullptr, /* trace */ |
783 | | }; |
784 | | |
785 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
786 | | { |
787 | | "Function", |
788 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
789 | | &sInterfaceObjectClassOps, |
790 | | JS_NULL_CLASS_SPEC, |
791 | | JS_NULL_CLASS_EXT, |
792 | | &sInterfaceObjectClassObjectOps |
793 | | }, |
794 | | eInterface, |
795 | | true, |
796 | | prototypes::id::PluginCrashedEvent, |
797 | | PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth, |
798 | | sNativePropertyHooks, |
799 | | "function PluginCrashedEvent() {\n [native code]\n}", |
800 | | Event_Binding::GetConstructorObject |
801 | | }; |
802 | | |
803 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
804 | | { |
805 | | "PluginCrashedEventPrototype", |
806 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */), |
807 | | JS_NULL_CLASS_OPS, |
808 | | JS_NULL_CLASS_SPEC, |
809 | | JS_NULL_CLASS_EXT, |
810 | | JS_NULL_OBJECT_OPS |
811 | | }, |
812 | | eInterfacePrototype, |
813 | | false, |
814 | | prototypes::id::PluginCrashedEvent, |
815 | | PrototypeTraits<prototypes::id::PluginCrashedEvent>::Depth, |
816 | | sNativePropertyHooks, |
817 | | "[object PluginCrashedEventPrototype]", |
818 | | Event_Binding::GetProtoObject |
819 | | }; |
820 | | |
821 | | bool |
822 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
823 | 0 | { |
824 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
825 | 0 | } |
826 | | |
827 | | static const js::ClassOps sClassOps = { |
828 | | _addProperty, /* addProperty */ |
829 | | nullptr, /* delProperty */ |
830 | | nullptr, /* enumerate */ |
831 | | nullptr, /* newEnumerate */ |
832 | | nullptr, /* resolve */ |
833 | | nullptr, /* mayResolve */ |
834 | | _finalize, /* finalize */ |
835 | | nullptr, /* call */ |
836 | | nullptr, /* hasInstance */ |
837 | | nullptr, /* construct */ |
838 | | nullptr, /* trace */ |
839 | | }; |
840 | | |
841 | | static const js::ClassExtension sClassExtension = { |
842 | | nullptr, /* weakmapKeyDelegateOp */ |
843 | | _objectMoved /* objectMovedOp */ |
844 | | }; |
845 | | |
846 | | static const DOMJSClass sClass = { |
847 | | { "PluginCrashedEvent", |
848 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE, |
849 | | &sClassOps, |
850 | | JS_NULL_CLASS_SPEC, |
851 | | &sClassExtension, |
852 | | JS_NULL_OBJECT_OPS |
853 | | }, |
854 | | { prototypes::id::Event, prototypes::id::PluginCrashedEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
855 | | IsBaseOf<nsISupports, mozilla::dom::PluginCrashedEvent >::value, |
856 | | sNativePropertyHooks, |
857 | | FindAssociatedGlobalForNative<mozilla::dom::PluginCrashedEvent>::Get, |
858 | | GetProtoObjectHandle, |
859 | | GetCCParticipant<mozilla::dom::PluginCrashedEvent>::Get() |
860 | | }; |
861 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
862 | | "Must have the right minimal number of reserved slots."); |
863 | | static_assert(1 >= 1, |
864 | | "Must have enough reserved slots."); |
865 | | |
866 | | const JSClass* |
867 | | GetJSClass() |
868 | 0 | { |
869 | 0 | return sClass.ToJSClass(); |
870 | 0 | } |
871 | | |
872 | | bool |
873 | | Wrap(JSContext* aCx, mozilla::dom::PluginCrashedEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
874 | 0 | { |
875 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::PluginCrashedEvent>::value, |
876 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
877 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::PluginCrashedEvent*>(aObject) == |
878 | 0 | reinterpret_cast<mozilla::dom::PluginCrashedEvent*>(aObject), |
879 | 0 | "Multiple inheritance for mozilla::dom::PluginCrashedEvent is broken."); |
880 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) == |
881 | 0 | reinterpret_cast<mozilla::dom::Event*>(aObject), |
882 | 0 | "Multiple inheritance for mozilla::dom::Event is broken."); |
883 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
884 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
885 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
886 | 0 | "You should probably not be using Wrap() directly; use " |
887 | 0 | "GetOrCreateDOMReflector instead"); |
888 | 0 |
|
889 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
890 | 0 | "nsISupports must be on our primary inheritance chain"); |
891 | 0 |
|
892 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
893 | 0 | if (!global) { |
894 | 0 | return false; |
895 | 0 | } |
896 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
897 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
898 | 0 |
|
899 | 0 | // That might have ended up wrapping us already, due to the wonders |
900 | 0 | // of XBL. Check for that, and bail out as needed. |
901 | 0 | aReflector.set(aCache->GetWrapper()); |
902 | 0 | if (aReflector) { |
903 | | #ifdef DEBUG |
904 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
905 | | #endif // DEBUG |
906 | | return true; |
907 | 0 | } |
908 | 0 |
|
909 | 0 | JSAutoRealm ar(aCx, global); |
910 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
911 | 0 | if (!canonicalProto) { |
912 | 0 | return false; |
913 | 0 | } |
914 | 0 | JS::Rooted<JSObject*> proto(aCx); |
915 | 0 | if (aGivenProto) { |
916 | 0 | proto = aGivenProto; |
917 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
918 | 0 | // coming in, we changed compartments to that of "parent" so may need |
919 | 0 | // to wrap the proto here. |
920 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
921 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
922 | 0 | return false; |
923 | 0 | } |
924 | 0 | } |
925 | 0 | } else { |
926 | 0 | proto = canonicalProto; |
927 | 0 | } |
928 | 0 |
|
929 | 0 | BindingJSObjectCreator<mozilla::dom::PluginCrashedEvent> creator(aCx); |
930 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
931 | 0 | if (!aReflector) { |
932 | 0 | return false; |
933 | 0 | } |
934 | 0 | |
935 | 0 | aCache->SetWrapper(aReflector); |
936 | 0 |
|
937 | 0 | // Important: do unforgeable property setup after we have handed |
938 | 0 | // over ownership of the C++ object to obj as needed, so that if |
939 | 0 | // we fail and it ends up GCed it won't have problems in the |
940 | 0 | // finalizer trying to drop its ownership of the C++ object. |
941 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx, |
942 | 0 | &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject()); |
943 | 0 | if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) { |
944 | 0 | aCache->ReleaseWrapper(aObject); |
945 | 0 | aCache->ClearWrapper(); |
946 | 0 | return false; |
947 | 0 | } |
948 | 0 | creator.InitializationSucceeded(); |
949 | 0 |
|
950 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
951 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
952 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
953 | 0 | // otherwise we won't be able to properly recreate it later, since |
954 | 0 | // we won't know what proto to use. Note that we don't check |
955 | 0 | // aGivenProto here, since it's entirely possible (and even |
956 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
957 | 0 | // same as canonicalProto. |
958 | 0 | if (proto != canonicalProto) { |
959 | 0 | PreserveWrapper(aObject); |
960 | 0 | } |
961 | 0 |
|
962 | 0 | return true; |
963 | 0 | } |
964 | | |
965 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
966 | | nullptr, |
967 | | nullptr, |
968 | | nullptr, |
969 | | { sNativeProperties.Upcast(), nullptr }, |
970 | | prototypes::id::PluginCrashedEvent, |
971 | | constructors::id::PluginCrashedEvent, |
972 | | Event_Binding::sNativePropertyHooks, |
973 | | &DefaultXrayExpandoObjectClass |
974 | | } }; |
975 | | |
976 | | void |
977 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
978 | 0 | { |
979 | 0 | JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx)); |
980 | 0 | if (!parentProto) { |
981 | 0 | return; |
982 | 0 | } |
983 | 0 | |
984 | 0 | JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx)); |
985 | 0 | if (!constructorProto) { |
986 | 0 | return; |
987 | 0 | } |
988 | 0 | |
989 | 0 | static bool sIdsInited = false; |
990 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
991 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
992 | 0 | return; |
993 | 0 | } |
994 | 0 | sIdsInited = true; |
995 | 0 | } |
996 | 0 |
|
997 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PluginCrashedEvent); |
998 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PluginCrashedEvent); |
999 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1000 | 0 | &sPrototypeClass.mBase, protoCache, |
1001 | 0 | nullptr, |
1002 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr, |
1003 | 0 | interfaceCache, |
1004 | 0 | sNativeProperties.Upcast(), |
1005 | 0 | nullptr, |
1006 | 0 | "PluginCrashedEvent", aDefineOnGlobal, |
1007 | 0 | nullptr, |
1008 | 0 | false); |
1009 | 0 |
|
1010 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx); |
1011 | 0 | { |
1012 | 0 | JS::Rooted<JSObject*> holderProto(aCx, *protoCache); |
1013 | 0 | unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto); |
1014 | 0 | if (!unforgeableHolder) { |
1015 | 0 | *protoCache = nullptr; |
1016 | 0 | if (interfaceCache) { |
1017 | 0 | *interfaceCache = nullptr; |
1018 | 0 | } |
1019 | 0 | return; |
1020 | 0 | } |
1021 | 0 | } |
1022 | 0 |
|
1023 | 0 | if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) { |
1024 | 0 | *protoCache = nullptr; |
1025 | 0 | if (interfaceCache) { |
1026 | 0 | *interfaceCache = nullptr; |
1027 | 0 | } |
1028 | 0 | return; |
1029 | 0 | } |
1030 | 0 |
|
1031 | 0 | if (*protoCache) { |
1032 | 0 | js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE, |
1033 | 0 | JS::ObjectValue(*unforgeableHolder)); |
1034 | 0 | } |
1035 | 0 | } |
1036 | | |
1037 | | JSObject* |
1038 | | GetConstructorObject(JSContext* aCx) |
1039 | 0 | { |
1040 | 0 | return GetConstructorObjectHandle(aCx); |
1041 | 0 | } |
1042 | | |
1043 | | } // namespace PluginCrashedEvent_Binding |
1044 | | |
1045 | | |
1046 | | |
1047 | | } // namespace dom |
1048 | | } // namespace mozilla |