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