Coverage Report

Created: 2018-09-25 14:53

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