Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/EventTargetBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM EventTarget.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "EventHandlerBinding.h"
5
#include "EventListenerBinding.h"
6
#include "EventTargetBinding.h"
7
#include "WrapperFactory.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/Event.h"
12
#include "mozilla/dom/EventTarget.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/ScriptSettings.h"
17
#include "mozilla/dom/SimpleGlobalObject.h"
18
#include "mozilla/dom/UnionConversions.h"
19
#include "mozilla/dom/XrayExpandoClass.h"
20
#include "nsContentUtils.h"
21
#include "nsPIDOMWindow.h"
22
#include "xpcprivate.h"
23
24
namespace mozilla {
25
namespace dom {
26
27
namespace binding_detail {}; // Just to make sure it's known as a namespace
28
using namespace mozilla::dom::binding_detail;
29
30
31
32
EventListenerOptions::EventListenerOptions()
33
0
{
34
0
  // Safe to pass a null context if we pass a null value
35
0
  Init(nullptr, JS::NullHandleValue);
36
0
}
37
38
39
40
bool
41
EventListenerOptions::InitIds(JSContext* cx, EventListenerOptionsAtoms* atomsCache)
42
0
{
43
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
44
0
45
0
  // Initialize these in reverse order so that any failure leaves the first one
46
0
  // uninitialized.
47
0
  if (!atomsCache->mozSystemGroup_id.init(cx, "mozSystemGroup") ||
48
0
      !atomsCache->capture_id.init(cx, "capture")) {
49
0
    return false;
50
0
  }
51
0
  return true;
52
0
}
53
54
bool
55
EventListenerOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
56
0
{
57
0
  // Passing a null JSContext is OK only if we're initing from null,
58
0
  // Since in that case we will not have to do any property gets
59
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
60
0
  // checkers by static analysis tools
61
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
62
0
  EventListenerOptionsAtoms* atomsCache = nullptr;
63
0
  if (cx) {
64
0
    atomsCache = GetAtomCache<EventListenerOptionsAtoms>(cx);
65
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
66
0
      return false;
67
0
    }
68
0
  }
69
0
70
0
  if (!IsConvertibleToDictionary(val)) {
71
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
72
0
  }
73
0
74
0
  bool isNull = val.isNullOrUndefined();
75
0
  // We only need these if !isNull, in which case we have |cx|.
76
0
  Maybe<JS::Rooted<JSObject *> > object;
77
0
  Maybe<JS::Rooted<JS::Value> > temp;
78
0
  if (!isNull) {
79
0
    MOZ_ASSERT(cx);
80
0
    object.emplace(cx, &val.toObject());
81
0
    temp.emplace(cx);
82
0
  }
83
0
  if (!isNull) {
84
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->capture_id, temp.ptr())) {
85
0
      return false;
86
0
    }
87
0
  }
88
0
  if (!isNull && !temp->isUndefined()) {
89
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mCapture)) {
90
0
      return false;
91
0
    }
92
0
  } else {
93
0
    mCapture = false;
94
0
  }
95
0
  mIsAnyMemberPresent = true;
96
0
97
0
  if (!isNull) {
98
0
    if (ThreadSafeIsChromeOrXBLOrUAWidget(cx, *object)) {
99
0
      if (!JS_GetPropertyById(cx, *object, atomsCache->mozSystemGroup_id, temp.ptr())) {
100
0
        return false;
101
0
      }
102
0
    } else {
103
0
      temp->setUndefined();
104
0
    }
105
0
  }
106
0
  if (!isNull && !temp->isUndefined()) {
107
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMozSystemGroup)) {
108
0
      return false;
109
0
    }
110
0
  } else {
111
0
    mMozSystemGroup = false;
112
0
  }
113
0
  mIsAnyMemberPresent = true;
114
0
  return true;
115
0
}
116
117
bool
118
EventListenerOptions::Init(const nsAString& aJSON)
119
0
{
120
0
  AutoJSAPI jsapi;
121
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
122
0
  if (!cleanGlobal) {
123
0
    return false;
124
0
  }
125
0
  if (!jsapi.Init(cleanGlobal)) {
126
0
    return false;
127
0
  }
128
0
  JSContext* cx = jsapi.cx();
129
0
  JS::Rooted<JS::Value> json(cx);
130
0
  bool ok = ParseJSON(cx, aJSON, &json);
131
0
  NS_ENSURE_TRUE(ok, false);
132
0
  return Init(cx, json);
133
0
}
134
135
bool
136
EventListenerOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
137
0
{
138
0
  EventListenerOptionsAtoms* atomsCache = GetAtomCache<EventListenerOptionsAtoms>(cx);
139
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
140
0
    return false;
141
0
  }
142
0
143
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
144
0
  if (!obj) {
145
0
    return false;
146
0
  }
147
0
  rval.set(JS::ObjectValue(*obj));
148
0
149
0
  do {
150
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
151
0
    JS::Rooted<JS::Value> temp(cx);
152
0
    bool const & currentValue = mCapture;
153
0
    temp.setBoolean(currentValue);
154
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->capture_id, temp, JSPROP_ENUMERATE)) {
155
0
      return false;
156
0
    }
157
0
    break;
158
0
  } while(false);
159
0
160
0
  if (ThreadSafeIsChromeOrXBLOrUAWidget(cx, obj)) {
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
      bool const & currentValue = mMozSystemGroup;
165
0
      temp.setBoolean(currentValue);
166
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->mozSystemGroup_id, temp, JSPROP_ENUMERATE)) {
167
0
        return false;
168
0
      }
169
0
      break;
170
0
    } while(false);
171
0
  }
172
0
173
0
  return true;
174
0
}
175
176
bool
177
EventListenerOptions::ToJSON(nsAString& aJSON) const
178
0
{
179
0
  AutoJSAPI jsapi;
180
0
  jsapi.Init();
181
0
  JSContext *cx = jsapi.cx();
182
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
183
0
  // because we'll only be creating objects, in ways that have no
184
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
185
0
  // which likewise guarantees no side-effects for the sorts of
186
0
  // things we will pass it.
187
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
188
0
  JS::Rooted<JS::Value> val(cx);
189
0
  if (!ToObjectInternal(cx, &val)) {
190
0
    return false;
191
0
  }
192
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
193
0
  return StringifyToJSON(cx, obj, aJSON);
194
0
}
195
196
void
197
EventListenerOptions::TraceDictionary(JSTracer* trc)
198
0
{
199
0
}
200
201
EventListenerOptions&
202
EventListenerOptions::operator=(const EventListenerOptions& aOther)
203
0
{
204
0
  DictionaryBase::operator=(aOther);
205
0
  mCapture = aOther.mCapture;
206
0
  mMozSystemGroup = aOther.mMozSystemGroup;
207
0
  return *this;
208
0
}
209
210
namespace binding_detail {
211
} // namespace binding_detail
212
213
214
215
AddEventListenerOptions::AddEventListenerOptions()
216
  : EventListenerOptions(FastDictionaryInitializer())
217
0
{
218
0
  // Safe to pass a null context if we pass a null value
219
0
  Init(nullptr, JS::NullHandleValue);
220
0
}
221
222
223
224
bool
225
AddEventListenerOptions::InitIds(JSContext* cx, AddEventListenerOptionsAtoms* atomsCache)
226
0
{
227
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
228
0
229
0
  // Initialize these in reverse order so that any failure leaves the first one
230
0
  // uninitialized.
231
0
  if (!atomsCache->wantUntrusted_id.init(cx, "wantUntrusted") ||
232
0
      !atomsCache->passive_id.init(cx, "passive") ||
233
0
      !atomsCache->once_id.init(cx, "once")) {
234
0
    return false;
235
0
  }
236
0
  return true;
237
0
}
238
239
bool
240
AddEventListenerOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
241
0
{
242
0
  // Passing a null JSContext is OK only if we're initing from null,
243
0
  // Since in that case we will not have to do any property gets
244
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
245
0
  // checkers by static analysis tools
246
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
247
0
  AddEventListenerOptionsAtoms* atomsCache = nullptr;
248
0
  if (cx) {
249
0
    atomsCache = GetAtomCache<AddEventListenerOptionsAtoms>(cx);
250
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
251
0
      return false;
252
0
    }
253
0
  }
254
0
255
0
  // Per spec, we init the parent's members first
256
0
  if (!EventListenerOptions::Init(cx, val)) {
257
0
    return false;
258
0
  }
259
0
260
0
  bool isNull = val.isNullOrUndefined();
261
0
  // We only need these if !isNull, in which case we have |cx|.
262
0
  Maybe<JS::Rooted<JSObject *> > object;
263
0
  Maybe<JS::Rooted<JS::Value> > temp;
264
0
  if (!isNull) {
265
0
    MOZ_ASSERT(cx);
266
0
    object.emplace(cx, &val.toObject());
267
0
    temp.emplace(cx);
268
0
  }
269
0
  if (!isNull) {
270
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->once_id, temp.ptr())) {
271
0
      return false;
272
0
    }
273
0
  }
274
0
  if (!isNull && !temp->isUndefined()) {
275
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mOnce)) {
276
0
      return false;
277
0
    }
278
0
  } else {
279
0
    mOnce = false;
280
0
  }
281
0
  mIsAnyMemberPresent = true;
282
0
283
0
  if (!isNull) {
284
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->passive_id, temp.ptr())) {
285
0
      return false;
286
0
    }
287
0
  }
288
0
  if (!isNull && !temp->isUndefined()) {
289
0
    mPassive.Construct();
290
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mPassive.Value()))) {
291
0
      return false;
292
0
    }
293
0
    mIsAnyMemberPresent = true;
294
0
  }
295
0
296
0
  if (!isNull) {
297
0
    if (nsContentUtils::ThreadsafeIsSystemCaller(cx)) {
298
0
      if (!JS_GetPropertyById(cx, *object, atomsCache->wantUntrusted_id, temp.ptr())) {
299
0
        return false;
300
0
      }
301
0
    } else {
302
0
      temp->setUndefined();
303
0
    }
304
0
  }
305
0
  if (!isNull && !temp->isUndefined()) {
306
0
    mWantUntrusted.Construct();
307
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mWantUntrusted.Value()))) {
308
0
      return false;
309
0
    }
310
0
    mIsAnyMemberPresent = true;
311
0
  }
312
0
  return true;
313
0
}
314
315
bool
316
AddEventListenerOptions::Init(const nsAString& aJSON)
317
0
{
318
0
  AutoJSAPI jsapi;
319
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
320
0
  if (!cleanGlobal) {
321
0
    return false;
322
0
  }
323
0
  if (!jsapi.Init(cleanGlobal)) {
324
0
    return false;
325
0
  }
326
0
  JSContext* cx = jsapi.cx();
327
0
  JS::Rooted<JS::Value> json(cx);
328
0
  bool ok = ParseJSON(cx, aJSON, &json);
329
0
  NS_ENSURE_TRUE(ok, false);
330
0
  return Init(cx, json);
331
0
}
332
333
bool
334
AddEventListenerOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
335
0
{
336
0
  AddEventListenerOptionsAtoms* atomsCache = GetAtomCache<AddEventListenerOptionsAtoms>(cx);
337
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
338
0
    return false;
339
0
  }
340
0
341
0
  // Per spec, we define the parent's members first
342
0
  if (!EventListenerOptions::ToObjectInternal(cx, rval)) {
343
0
    return false;
344
0
  }
345
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
346
0
347
0
  do {
348
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
349
0
    JS::Rooted<JS::Value> temp(cx);
350
0
    bool const & currentValue = mOnce;
351
0
    temp.setBoolean(currentValue);
352
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->once_id, temp, JSPROP_ENUMERATE)) {
353
0
      return false;
354
0
    }
355
0
    break;
356
0
  } while(false);
357
0
358
0
  if (mPassive.WasPassed()) {
359
0
    do {
360
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
361
0
      JS::Rooted<JS::Value> temp(cx);
362
0
      bool const & currentValue = mPassive.InternalValue();
363
0
      temp.setBoolean(currentValue);
364
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->passive_id, temp, JSPROP_ENUMERATE)) {
365
0
        return false;
366
0
      }
367
0
      break;
368
0
    } while(false);
369
0
  }
370
0
371
0
  if (nsContentUtils::ThreadsafeIsSystemCaller(cx)) {
372
0
    if (mWantUntrusted.WasPassed()) {
373
0
      do {
374
0
        // block for our 'break' successCode and scope for 'temp' and 'currentValue'
375
0
        JS::Rooted<JS::Value> temp(cx);
376
0
        bool const & currentValue = mWantUntrusted.InternalValue();
377
0
        temp.setBoolean(currentValue);
378
0
        if (!JS_DefinePropertyById(cx, obj, atomsCache->wantUntrusted_id, temp, JSPROP_ENUMERATE)) {
379
0
          return false;
380
0
        }
381
0
        break;
382
0
      } while(false);
383
0
    }
384
0
  }
385
0
386
0
  return true;
387
0
}
388
389
bool
390
AddEventListenerOptions::ToJSON(nsAString& aJSON) const
391
0
{
392
0
  AutoJSAPI jsapi;
393
0
  jsapi.Init();
394
0
  JSContext *cx = jsapi.cx();
395
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
396
0
  // because we'll only be creating objects, in ways that have no
397
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
398
0
  // which likewise guarantees no side-effects for the sorts of
399
0
  // things we will pass it.
400
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
401
0
  JS::Rooted<JS::Value> val(cx);
402
0
  if (!ToObjectInternal(cx, &val)) {
403
0
    return false;
404
0
  }
405
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
406
0
  return StringifyToJSON(cx, obj, aJSON);
407
0
}
408
409
void
410
AddEventListenerOptions::TraceDictionary(JSTracer* trc)
411
0
{
412
0
  EventListenerOptions::TraceDictionary(trc);
413
0
}
414
415
AddEventListenerOptions&
416
AddEventListenerOptions::operator=(const AddEventListenerOptions& aOther)
417
0
{
418
0
  EventListenerOptions::operator=(aOther);
419
0
  mOnce = aOther.mOnce;
420
0
  mPassive.Reset();
421
0
  if (aOther.mPassive.WasPassed()) {
422
0
    mPassive.Construct(aOther.mPassive.Value());
423
0
  }
424
0
  mWantUntrusted.Reset();
425
0
  if (aOther.mWantUntrusted.WasPassed()) {
426
0
    mWantUntrusted.Construct(aOther.mWantUntrusted.Value());
427
0
  }
428
0
  return *this;
429
0
}
430
431
namespace binding_detail {
432
} // namespace binding_detail
433
434
435
bool
436
EventListenerOptionsOrBoolean::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
437
0
{
438
0
  switch (mType) {
439
0
    case eUninitialized: {
440
0
      return false;
441
0
      break;
442
0
    }
443
0
    case eEventListenerOptions: {
444
0
      if (!mValue.mEventListenerOptions.Value().ToObjectInternal(cx, rval)) {
445
0
        return false;
446
0
      }
447
0
      return true;
448
0
      break;
449
0
    }
450
0
    case eBoolean: {
451
0
      rval.setBoolean(mValue.mBoolean.Value());
452
0
      return true;
453
0
      break;
454
0
    }
455
0
    default: {
456
0
      return false;
457
0
      break;
458
0
    }
459
0
  }
460
0
461
0
  return false;
462
0
}
463
464
465
EventListenerOptions&
466
OwningEventListenerOptionsOrBoolean::RawSetAsEventListenerOptions()
467
0
{
468
0
  if (mType == eEventListenerOptions) {
469
0
    return mValue.mEventListenerOptions.Value();
470
0
  }
471
0
  MOZ_ASSERT(mType == eUninitialized);
472
0
  mType = eEventListenerOptions;
473
0
  return mValue.mEventListenerOptions.SetValue();
474
0
}
475
476
EventListenerOptions&
477
OwningEventListenerOptionsOrBoolean::SetAsEventListenerOptions()
478
0
{
479
0
  if (mType == eEventListenerOptions) {
480
0
    return mValue.mEventListenerOptions.Value();
481
0
  }
482
0
  Uninit();
483
0
  mType = eEventListenerOptions;
484
0
  return mValue.mEventListenerOptions.SetValue();
485
0
}
486
487
bool
488
OwningEventListenerOptionsOrBoolean::TrySetToEventListenerOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
489
0
{
490
0
  tryNext = false;
491
0
  { // scope for memberSlot
492
0
    EventListenerOptions& memberSlot = RawSetAsEventListenerOptions();
493
0
    if (!IsConvertibleToDictionary(value)) {
494
0
      DestroyEventListenerOptions();
495
0
      tryNext = true;
496
0
      return true;
497
0
    }
498
0
    if (!memberSlot.Init(cx, value,  "Member of EventListenerOptionsOrBoolean", passedToJSImpl)) {
499
0
      return false;
500
0
    }
501
0
  }
502
0
  return true;
503
0
}
504
505
void
506
OwningEventListenerOptionsOrBoolean::DestroyEventListenerOptions()
507
0
{
508
0
  MOZ_ASSERT(IsEventListenerOptions(), "Wrong type!");
509
0
  mValue.mEventListenerOptions.Destroy();
510
0
  mType = eUninitialized;
511
0
}
512
513
514
515
516
bool&
517
OwningEventListenerOptionsOrBoolean::RawSetAsBoolean()
518
0
{
519
0
  if (mType == eBoolean) {
520
0
    return mValue.mBoolean.Value();
521
0
  }
522
0
  MOZ_ASSERT(mType == eUninitialized);
523
0
  mType = eBoolean;
524
0
  return mValue.mBoolean.SetValue();
525
0
}
526
527
bool&
528
OwningEventListenerOptionsOrBoolean::SetAsBoolean()
529
0
{
530
0
  if (mType == eBoolean) {
531
0
    return mValue.mBoolean.Value();
532
0
  }
533
0
  Uninit();
534
0
  mType = eBoolean;
535
0
  return mValue.mBoolean.SetValue();
536
0
}
537
538
bool
539
OwningEventListenerOptionsOrBoolean::TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
540
0
{
541
0
  tryNext = false;
542
0
  { // scope for memberSlot
543
0
    bool& memberSlot = RawSetAsBoolean();
544
0
    if (!ValueToPrimitive<bool, eDefault>(cx, value, &memberSlot)) {
545
0
      return false;
546
0
    }
547
0
  }
548
0
  return true;
549
0
}
550
551
void
552
OwningEventListenerOptionsOrBoolean::DestroyBoolean()
553
0
{
554
0
  MOZ_ASSERT(IsBoolean(), "Wrong type!");
555
0
  mValue.mBoolean.Destroy();
556
0
  mType = eUninitialized;
557
0
}
558
559
560
561
562
void
563
OwningEventListenerOptionsOrBoolean::Uninit()
564
{
565
  switch (mType) {
566
    case eUninitialized: {
567
      break;
568
    }
569
    case eEventListenerOptions: {
570
      DestroyEventListenerOptions();
571
      break;
572
    }
573
    case eBoolean: {
574
      DestroyBoolean();
575
      break;
576
    }
577
  }
578
}
579
580
bool
581
OwningEventListenerOptionsOrBoolean::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
582
0
{
583
0
  switch (mType) {
584
0
    case eUninitialized: {
585
0
      return false;
586
0
      break;
587
0
    }
588
0
    case eEventListenerOptions: {
589
0
      if (!mValue.mEventListenerOptions.Value().ToObjectInternal(cx, rval)) {
590
0
        return false;
591
0
      }
592
0
      return true;
593
0
      break;
594
0
    }
595
0
    case eBoolean: {
596
0
      rval.setBoolean(mValue.mBoolean.Value());
597
0
      return true;
598
0
      break;
599
0
    }
600
0
    default: {
601
0
      return false;
602
0
      break;
603
0
    }
604
0
  }
605
0
606
0
  return false;
607
0
}
608
609
void
610
OwningEventListenerOptionsOrBoolean::TraceUnion(JSTracer* trc)
611
0
{
612
0
}
613
614
OwningEventListenerOptionsOrBoolean&
615
OwningEventListenerOptionsOrBoolean::operator=(const OwningEventListenerOptionsOrBoolean& aOther)
616
0
{
617
0
  switch (aOther.mType) {
618
0
    case eUninitialized: {
619
0
      MOZ_ASSERT(mType == eUninitialized,
620
0
                 "We need to destroy ourselves?");
621
0
      break;
622
0
    }
623
0
    case eEventListenerOptions: {
624
0
      SetAsEventListenerOptions() = aOther.GetAsEventListenerOptions();
625
0
      break;
626
0
    }
627
0
    case eBoolean: {
628
0
      SetAsBoolean() = aOther.GetAsBoolean();
629
0
      break;
630
0
    }
631
0
  }
632
0
  return *this;
633
0
}
634
635
636
bool
637
AddEventListenerOptionsOrBoolean::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
638
0
{
639
0
  switch (mType) {
640
0
    case eUninitialized: {
641
0
      return false;
642
0
      break;
643
0
    }
644
0
    case eAddEventListenerOptions: {
645
0
      if (!mValue.mAddEventListenerOptions.Value().ToObjectInternal(cx, rval)) {
646
0
        return false;
647
0
      }
648
0
      return true;
649
0
      break;
650
0
    }
651
0
    case eBoolean: {
652
0
      rval.setBoolean(mValue.mBoolean.Value());
653
0
      return true;
654
0
      break;
655
0
    }
656
0
    default: {
657
0
      return false;
658
0
      break;
659
0
    }
660
0
  }
661
0
662
0
  return false;
663
0
}
664
665
666
AddEventListenerOptions&
667
OwningAddEventListenerOptionsOrBoolean::RawSetAsAddEventListenerOptions()
668
0
{
669
0
  if (mType == eAddEventListenerOptions) {
670
0
    return mValue.mAddEventListenerOptions.Value();
671
0
  }
672
0
  MOZ_ASSERT(mType == eUninitialized);
673
0
  mType = eAddEventListenerOptions;
674
0
  return mValue.mAddEventListenerOptions.SetValue();
675
0
}
676
677
AddEventListenerOptions&
678
OwningAddEventListenerOptionsOrBoolean::SetAsAddEventListenerOptions()
679
0
{
680
0
  if (mType == eAddEventListenerOptions) {
681
0
    return mValue.mAddEventListenerOptions.Value();
682
0
  }
683
0
  Uninit();
684
0
  mType = eAddEventListenerOptions;
685
0
  return mValue.mAddEventListenerOptions.SetValue();
686
0
}
687
688
bool
689
OwningAddEventListenerOptionsOrBoolean::TrySetToAddEventListenerOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
690
0
{
691
0
  tryNext = false;
692
0
  { // scope for memberSlot
693
0
    AddEventListenerOptions& memberSlot = RawSetAsAddEventListenerOptions();
694
0
    if (!IsConvertibleToDictionary(value)) {
695
0
      DestroyAddEventListenerOptions();
696
0
      tryNext = true;
697
0
      return true;
698
0
    }
699
0
    if (!memberSlot.Init(cx, value,  "Member of AddEventListenerOptionsOrBoolean", passedToJSImpl)) {
700
0
      return false;
701
0
    }
702
0
  }
703
0
  return true;
704
0
}
705
706
void
707
OwningAddEventListenerOptionsOrBoolean::DestroyAddEventListenerOptions()
708
0
{
709
0
  MOZ_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
710
0
  mValue.mAddEventListenerOptions.Destroy();
711
0
  mType = eUninitialized;
712
0
}
713
714
715
716
717
bool&
718
OwningAddEventListenerOptionsOrBoolean::RawSetAsBoolean()
719
0
{
720
0
  if (mType == eBoolean) {
721
0
    return mValue.mBoolean.Value();
722
0
  }
723
0
  MOZ_ASSERT(mType == eUninitialized);
724
0
  mType = eBoolean;
725
0
  return mValue.mBoolean.SetValue();
726
0
}
727
728
bool&
729
OwningAddEventListenerOptionsOrBoolean::SetAsBoolean()
730
0
{
731
0
  if (mType == eBoolean) {
732
0
    return mValue.mBoolean.Value();
733
0
  }
734
0
  Uninit();
735
0
  mType = eBoolean;
736
0
  return mValue.mBoolean.SetValue();
737
0
}
738
739
bool
740
OwningAddEventListenerOptionsOrBoolean::TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
741
0
{
742
0
  tryNext = false;
743
0
  { // scope for memberSlot
744
0
    bool& memberSlot = RawSetAsBoolean();
745
0
    if (!ValueToPrimitive<bool, eDefault>(cx, value, &memberSlot)) {
746
0
      return false;
747
0
    }
748
0
  }
749
0
  return true;
750
0
}
751
752
void
753
OwningAddEventListenerOptionsOrBoolean::DestroyBoolean()
754
0
{
755
0
  MOZ_ASSERT(IsBoolean(), "Wrong type!");
756
0
  mValue.mBoolean.Destroy();
757
0
  mType = eUninitialized;
758
0
}
759
760
761
762
763
void
764
OwningAddEventListenerOptionsOrBoolean::Uninit()
765
{
766
  switch (mType) {
767
    case eUninitialized: {
768
      break;
769
    }
770
    case eAddEventListenerOptions: {
771
      DestroyAddEventListenerOptions();
772
      break;
773
    }
774
    case eBoolean: {
775
      DestroyBoolean();
776
      break;
777
    }
778
  }
779
}
780
781
bool
782
OwningAddEventListenerOptionsOrBoolean::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
783
0
{
784
0
  switch (mType) {
785
0
    case eUninitialized: {
786
0
      return false;
787
0
      break;
788
0
    }
789
0
    case eAddEventListenerOptions: {
790
0
      if (!mValue.mAddEventListenerOptions.Value().ToObjectInternal(cx, rval)) {
791
0
        return false;
792
0
      }
793
0
      return true;
794
0
      break;
795
0
    }
796
0
    case eBoolean: {
797
0
      rval.setBoolean(mValue.mBoolean.Value());
798
0
      return true;
799
0
      break;
800
0
    }
801
0
    default: {
802
0
      return false;
803
0
      break;
804
0
    }
805
0
  }
806
0
807
0
  return false;
808
0
}
809
810
void
811
OwningAddEventListenerOptionsOrBoolean::TraceUnion(JSTracer* trc)
812
0
{
813
0
}
814
815
OwningAddEventListenerOptionsOrBoolean&
816
OwningAddEventListenerOptionsOrBoolean::operator=(const OwningAddEventListenerOptionsOrBoolean& aOther)
817
0
{
818
0
  switch (aOther.mType) {
819
0
    case eUninitialized: {
820
0
      MOZ_ASSERT(mType == eUninitialized,
821
0
                 "We need to destroy ourselves?");
822
0
      break;
823
0
    }
824
0
    case eAddEventListenerOptions: {
825
0
      SetAsAddEventListenerOptions() = aOther.GetAsAddEventListenerOptions();
826
0
      break;
827
0
    }
828
0
    case eBoolean: {
829
0
      SetAsBoolean() = aOther.GetAsBoolean();
830
0
      break;
831
0
    }
832
0
  }
833
0
  return *this;
834
0
}
835
836
837
namespace EventTarget_Binding {
838
839
MOZ_CAN_RUN_SCRIPT static bool
840
addEventListener(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::EventTarget* self, const JSJitMethodCallArgs& args)
841
0
{
842
0
  AUTO_PROFILER_LABEL_FAST("EventTarget.addEventListener", DOM, cx);
843
0
844
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
845
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EventTarget.addEventListener");
846
0
  }
847
0
  binding_detail::FakeString arg0;
848
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
849
0
    return false;
850
0
  }
851
0
  RootedCallback<RefPtr<binding_detail::FastEventListener>> arg1(cx);
852
0
  if (args[1].isObject()) {
853
0
    { // scope for tempRoot and tempGlobalRoot if needed
854
0
      arg1 = new binding_detail::FastEventListener(&args[1].toObject(), JS::CurrentGlobalOrNull(cx));
855
0
    }
856
0
  } else if (args[1].isNullOrUndefined()) {
857
0
    arg1 = nullptr;
858
0
  } else {
859
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of EventTarget.addEventListener");
860
0
    return false;
861
0
  }
862
0
  AddEventListenerOptionsOrBoolean arg2;
863
0
  AddEventListenerOptionsOrBooleanArgument arg2_holder(arg2);
864
0
  if (!(args.hasDefined(2))) {
865
0
    if (!arg2.RawSetAsAddEventListenerOptions().Init(cx, JS::NullHandleValue, "Member of AddEventListenerOptionsOrBoolean")) {
866
0
      return false;
867
0
    }
868
0
  } else {
869
0
    {
870
0
      bool done = false, failed = false, tryNext;
871
0
      if (!done) {
872
0
        done = (failed = !arg2_holder.TrySetToAddEventListenerOptions(cx, args[2], tryNext, false)) || !tryNext;
873
0
      }
874
0
      if (!done) {
875
0
        do {
876
0
          done = (failed = !arg2_holder.TrySetToBoolean(cx, args[2], tryNext)) || !tryNext;
877
0
          break;
878
0
        } while (false);
879
0
      }
880
0
      if (failed) {
881
0
        return false;
882
0
      }
883
0
      if (!done) {
884
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of EventTarget.addEventListener", "AddEventListenerOptions");
885
0
        return false;
886
0
      }
887
0
    }
888
0
  }
889
0
  Nullable<bool> arg3;
890
0
  if (!(args.hasDefined(3)) || args[3].isNullOrUndefined()) {
891
0
    arg3.SetNull();
892
0
  } else if (!ValueToPrimitive<bool, eDefault>(cx, args[3], &arg3.SetValue())) {
893
0
    return false;
894
0
  }
895
0
  FastErrorResult rv;
896
0
  self->AddEventListener(NonNullHelper(Constify(arg0)), MOZ_KnownLive(Constify(arg1)), Constify(arg2), Constify(arg3), rv);
897
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
898
0
    return false;
899
0
  }
900
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
901
0
  args.rval().setUndefined();
902
0
  return true;
903
0
}
904
905
static const JSJitInfo addEventListener_methodinfo = {
906
  { (JSJitGetterOp)addEventListener },
907
  { prototypes::id::EventTarget },
908
  { PrototypeTraits<prototypes::id::EventTarget>::Depth },
909
  JSJitInfo::Method,
910
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
911
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
912
  false,  /* isInfallible. False in setters. */
913
  false,  /* isMovable.  Not relevant for setters. */
914
  false, /* isEliminatable.  Not relevant for setters. */
915
  false, /* isAlwaysInSlot.  Only relevant for getters. */
916
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
917
  false,  /* isTypedMethod.  Only relevant for methods. */
918
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
919
};
920
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
921
static_assert(0 < 1, "There is no slot for us");
922
923
MOZ_CAN_RUN_SCRIPT static bool
924
removeEventListener(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::EventTarget* self, const JSJitMethodCallArgs& args)
925
0
{
926
0
  AUTO_PROFILER_LABEL_FAST("EventTarget.removeEventListener", DOM, cx);
927
0
928
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
929
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EventTarget.removeEventListener");
930
0
  }
931
0
  binding_detail::FakeString arg0;
932
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
933
0
    return false;
934
0
  }
935
0
  RootedCallback<RefPtr<binding_detail::FastEventListener>> arg1(cx);
936
0
  if (args[1].isObject()) {
937
0
    { // scope for tempRoot and tempGlobalRoot if needed
938
0
      arg1 = new binding_detail::FastEventListener(&args[1].toObject(), JS::CurrentGlobalOrNull(cx));
939
0
    }
940
0
  } else if (args[1].isNullOrUndefined()) {
941
0
    arg1 = nullptr;
942
0
  } else {
943
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of EventTarget.removeEventListener");
944
0
    return false;
945
0
  }
946
0
  EventListenerOptionsOrBoolean arg2;
947
0
  EventListenerOptionsOrBooleanArgument arg2_holder(arg2);
948
0
  if (!(args.hasDefined(2))) {
949
0
    if (!arg2.RawSetAsEventListenerOptions().Init(cx, JS::NullHandleValue, "Member of EventListenerOptionsOrBoolean")) {
950
0
      return false;
951
0
    }
952
0
  } else {
953
0
    {
954
0
      bool done = false, failed = false, tryNext;
955
0
      if (!done) {
956
0
        done = (failed = !arg2_holder.TrySetToEventListenerOptions(cx, args[2], tryNext, false)) || !tryNext;
957
0
      }
958
0
      if (!done) {
959
0
        do {
960
0
          done = (failed = !arg2_holder.TrySetToBoolean(cx, args[2], tryNext)) || !tryNext;
961
0
          break;
962
0
        } while (false);
963
0
      }
964
0
      if (failed) {
965
0
        return false;
966
0
      }
967
0
      if (!done) {
968
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of EventTarget.removeEventListener", "EventListenerOptions");
969
0
        return false;
970
0
      }
971
0
    }
972
0
  }
973
0
  FastErrorResult rv;
974
0
  self->RemoveEventListener(NonNullHelper(Constify(arg0)), MOZ_KnownLive(Constify(arg1)), Constify(arg2), rv);
975
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
976
0
    return false;
977
0
  }
978
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
979
0
  args.rval().setUndefined();
980
0
  return true;
981
0
}
982
983
static const JSJitInfo removeEventListener_methodinfo = {
984
  { (JSJitGetterOp)removeEventListener },
985
  { prototypes::id::EventTarget },
986
  { PrototypeTraits<prototypes::id::EventTarget>::Depth },
987
  JSJitInfo::Method,
988
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
989
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
990
  false,  /* isInfallible. False in setters. */
991
  false,  /* isMovable.  Not relevant for setters. */
992
  false, /* isEliminatable.  Not relevant for setters. */
993
  false, /* isAlwaysInSlot.  Only relevant for getters. */
994
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
995
  false,  /* isTypedMethod.  Only relevant for methods. */
996
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
997
};
998
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
999
static_assert(0 < 1, "There is no slot for us");
1000
1001
MOZ_CAN_RUN_SCRIPT static bool
1002
dispatchEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::EventTarget* self, const JSJitMethodCallArgs& args)
1003
0
{
1004
0
  AUTO_PROFILER_LABEL_FAST("EventTarget.dispatchEvent", DOM, cx);
1005
0
1006
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1007
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EventTarget.dispatchEvent");
1008
0
  }
1009
0
  NonNull<mozilla::dom::Event> arg0;
1010
0
  if (args[0].isObject()) {
1011
0
    {
1012
0
      nsresult rv = UnwrapObject<prototypes::id::Event, mozilla::dom::Event>(args[0], arg0);
1013
0
      if (NS_FAILED(rv)) {
1014
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of EventTarget.dispatchEvent", "Event");
1015
0
        return false;
1016
0
      }
1017
0
    }
1018
0
  } else {
1019
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of EventTarget.dispatchEvent");
1020
0
    return false;
1021
0
  }
1022
0
  FastErrorResult rv;
1023
0
  bool result(self->DispatchEvent(MOZ_KnownLive(NonNullHelper(arg0)), nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv));
1024
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1025
0
    return false;
1026
0
  }
1027
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1028
0
  args.rval().setBoolean(result);
1029
0
  return true;
1030
0
}
1031
1032
static const JSJitInfo dispatchEvent_methodinfo = {
1033
  { (JSJitGetterOp)dispatchEvent },
1034
  { prototypes::id::EventTarget },
1035
  { PrototypeTraits<prototypes::id::EventTarget>::Depth },
1036
  JSJitInfo::Method,
1037
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1038
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1039
  false,  /* isInfallible. False in setters. */
1040
  false,  /* isMovable.  Not relevant for setters. */
1041
  false, /* isEliminatable.  Not relevant for setters. */
1042
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1043
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1044
  false,  /* isTypedMethod.  Only relevant for methods. */
1045
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1046
};
1047
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1048
static_assert(0 < 1, "There is no slot for us");
1049
1050
MOZ_CAN_RUN_SCRIPT static bool
1051
setEventHandler(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::EventTarget* self, const JSJitMethodCallArgs& args)
1052
0
{
1053
0
  AUTO_PROFILER_LABEL_FAST("EventTarget.setEventHandler", DOM, cx);
1054
0
1055
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
1056
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EventTarget.setEventHandler");
1057
0
  }
1058
0
  binding_detail::FakeString arg0;
1059
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1060
0
    return false;
1061
0
  }
1062
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg1(cx);
1063
0
  if (args[1].isObject()) {
1064
0
    { // scope for tempRoot and tempGlobalRoot if needed
1065
0
      arg1 = new binding_detail::FastEventHandlerNonNull(&args[1].toObject(), JS::CurrentGlobalOrNull(cx));
1066
0
    }
1067
0
  } else {
1068
0
    arg1 = nullptr;
1069
0
  }
1070
0
  FastErrorResult rv;
1071
0
  self->SetEventHandler(NonNullHelper(Constify(arg0)), Constify(arg1), rv);
1072
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1073
0
    return false;
1074
0
  }
1075
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1076
0
  args.rval().setUndefined();
1077
0
  return true;
1078
0
}
1079
1080
static const JSJitInfo setEventHandler_methodinfo = {
1081
  { (JSJitGetterOp)setEventHandler },
1082
  { prototypes::id::EventTarget },
1083
  { PrototypeTraits<prototypes::id::EventTarget>::Depth },
1084
  JSJitInfo::Method,
1085
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1086
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1087
  false,  /* isInfallible. False in setters. */
1088
  false,  /* isMovable.  Not relevant for setters. */
1089
  false, /* isEliminatable.  Not relevant for setters. */
1090
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1091
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1092
  false,  /* isTypedMethod.  Only relevant for methods. */
1093
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1094
};
1095
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1096
static_assert(0 < 1, "There is no slot for us");
1097
1098
MOZ_CAN_RUN_SCRIPT static bool
1099
getEventHandler(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::EventTarget* self, const JSJitMethodCallArgs& args)
1100
0
{
1101
0
  AUTO_PROFILER_LABEL_FAST("EventTarget.getEventHandler", DOM, cx);
1102
0
1103
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1104
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EventTarget.getEventHandler");
1105
0
  }
1106
0
  binding_detail::FakeString arg0;
1107
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1108
0
    return false;
1109
0
  }
1110
0
  RefPtr<EventHandlerNonNull> result(self->GetEventHandler(NonNullHelper(Constify(arg0))));
1111
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1112
0
  if (result) {
1113
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
1114
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
1115
0
      return false;
1116
0
    }
1117
0
    return true;
1118
0
  } else {
1119
0
    args.rval().setNull();
1120
0
    return true;
1121
0
  }
1122
0
}
1123
1124
static const JSJitInfo getEventHandler_methodinfo = {
1125
  { (JSJitGetterOp)getEventHandler },
1126
  { prototypes::id::EventTarget },
1127
  { PrototypeTraits<prototypes::id::EventTarget>::Depth },
1128
  JSJitInfo::Method,
1129
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1130
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1131
  false,  /* isInfallible. False in setters. */
1132
  false,  /* isMovable.  Not relevant for setters. */
1133
  false, /* isEliminatable.  Not relevant for setters. */
1134
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1135
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1136
  false,  /* isTypedMethod.  Only relevant for methods. */
1137
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1138
};
1139
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1140
static_assert(0 < 1, "There is no slot for us");
1141
1142
MOZ_CAN_RUN_SCRIPT static bool
1143
get_ownerGlobal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::EventTarget* self, JSJitGetterCallArgs args)
1144
0
{
1145
0
  AUTO_PROFILER_LABEL_FAST("get EventTarget.ownerGlobal", DOM, cx);
1146
0
1147
0
  auto result(StrongOrRawPtr<nsPIDOMWindowOuter>(self->GetOwnerGlobalForBindings()));
1148
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1149
0
  if (!result) {
1150
0
    args.rval().setNull();
1151
0
    return true;
1152
0
  }
1153
0
  if (!WrapObject(cx, result, args.rval())) {
1154
0
    return false;
1155
0
  }
1156
0
  return true;
1157
0
}
1158
1159
static const JSJitInfo ownerGlobal_getterinfo = {
1160
  { (JSJitGetterOp)get_ownerGlobal },
1161
  { prototypes::id::EventTarget },
1162
  { PrototypeTraits<prototypes::id::EventTarget>::Depth },
1163
  JSJitInfo::Getter,
1164
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1165
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1166
  false,  /* isInfallible. False in setters. */
1167
  false,  /* isMovable.  Not relevant for setters. */
1168
  false, /* isEliminatable.  Not relevant for setters. */
1169
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1170
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1171
  false,  /* isTypedMethod.  Only relevant for methods. */
1172
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1173
};
1174
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1175
static_assert(0 < 1, "There is no slot for us");
1176
1177
static bool
1178
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1179
0
{
1180
0
  mozilla::dom::EventTarget* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::EventTarget>(obj);
1181
0
  // We don't want to preserve if we don't have a wrapper, and we
1182
0
  // obviously can't preserve if we're not initialized.
1183
0
  if (self && self->GetWrapperPreserveColor()) {
1184
0
    PreserveWrapper(self);
1185
0
  }
1186
0
  return true;
1187
0
}
1188
1189
static void
1190
_finalize(js::FreeOp* fop, JSObject* obj)
1191
0
{
1192
0
  mozilla::dom::EventTarget* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::EventTarget>(obj);
1193
0
  if (self) {
1194
0
    ClearWrapper(self, self, obj);
1195
0
    AddForDeferredFinalization<mozilla::dom::EventTarget>(self);
1196
0
  }
1197
0
}
1198
1199
static size_t
1200
_objectMoved(JSObject* obj, JSObject* old)
1201
0
{
1202
0
  mozilla::dom::EventTarget* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::EventTarget>(obj);
1203
0
  if (self) {
1204
0
    UpdateWrapper(self, self, obj, old);
1205
0
  }
1206
0
1207
0
  return 0;
1208
0
}
1209
1210
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1211
#if defined(__clang__)
1212
#pragma clang diagnostic push
1213
#pragma clang diagnostic ignored "-Wmissing-braces"
1214
#endif
1215
static const JSFunctionSpec sMethods_specs[] = {
1216
  JS_FNSPEC("addEventListener", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addEventListener_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1217
  JS_FNSPEC("removeEventListener", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeEventListener_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1218
  JS_FNSPEC("dispatchEvent", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&dispatchEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1219
  JS_FS_END
1220
};
1221
#if defined(__clang__)
1222
#pragma clang diagnostic pop
1223
#endif
1224
1225
1226
static const Prefable<const JSFunctionSpec> sMethods[] = {
1227
  { nullptr, &sMethods_specs[0] },
1228
  { nullptr, nullptr }
1229
};
1230
1231
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1232
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1233
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1234
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1235
1236
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1237
#if defined(__clang__)
1238
#pragma clang diagnostic push
1239
#pragma clang diagnostic ignored "-Wmissing-braces"
1240
#endif
1241
static const JSFunctionSpec sChromeMethods_specs[] = {
1242
  JS_FNSPEC("setEventHandler", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setEventHandler_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1243
  JS_FNSPEC("getEventHandler", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getEventHandler_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1244
  JS_FS_END
1245
};
1246
#if defined(__clang__)
1247
#pragma clang diagnostic pop
1248
#endif
1249
1250
1251
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
1252
  { nullptr, &sChromeMethods_specs[0] },
1253
  { nullptr, nullptr }
1254
};
1255
1256
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1257
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1258
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1259
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1260
1261
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1262
#if defined(__clang__)
1263
#pragma clang diagnostic push
1264
#pragma clang diagnostic ignored "-Wmissing-braces"
1265
#endif
1266
static const JSPropertySpec sChromeAttributes_specs[] = {
1267
  { "ownerGlobal", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &ownerGlobal_getterinfo, nullptr, nullptr },
1268
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1269
};
1270
#if defined(__clang__)
1271
#pragma clang diagnostic pop
1272
#endif
1273
1274
// Can't be const because the pref-enabled boolean needs to be writable
1275
static PrefableDisablers sChromeAttributes_disablers0 = {
1276
  true, false, GlobalNames::AudioWorkletGlobalScope | GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::WorkerDebuggerGlobalScope, nullptr
1277
};
1278
1279
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
1280
  { &sChromeAttributes_disablers0, &sChromeAttributes_specs[0] },
1281
  { nullptr, nullptr }
1282
};
1283
1284
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1285
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1286
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1287
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1288
1289
1290
static uint16_t sNativeProperties_sortedPropertyIndices[3];
1291
static PropertyInfo sNativeProperties_propertyInfos[3];
1292
1293
static const NativePropertiesN<1> sNativeProperties = {
1294
  false, 0,
1295
  false, 0,
1296
  true,  0 /* sMethods */,
1297
  false, 0,
1298
  false, 0,
1299
  false, 0,
1300
  false, 0,
1301
  -1,
1302
  3,
1303
  sNativeProperties_sortedPropertyIndices,
1304
  {
1305
    { sMethods, &sNativeProperties_propertyInfos[0] }
1306
  }
1307
};
1308
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1309
    "We have a property info count that is oversized");
1310
1311
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[3];
1312
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[3];
1313
1314
static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
1315
  false, 0,
1316
  false, 0,
1317
  true,  0 /* sChromeMethods */,
1318
  true,  1 /* sChromeAttributes */,
1319
  false, 0,
1320
  false, 0,
1321
  false, 0,
1322
  -1,
1323
  3,
1324
  sChromeOnlyNativeProperties_sortedPropertyIndices,
1325
  {
1326
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
1327
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[2] }
1328
  }
1329
};
1330
static_assert(3 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1331
    "We have a property info count that is oversized");
1332
1333
static bool
1334
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1335
0
{
1336
0
  AUTO_PROFILER_LABEL_FAST("EventTarget constructor", DOM, cx);
1337
0
1338
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1339
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1340
0
  if (!args.isConstructing()) {
1341
0
    // XXXbz wish I could get the name from the callee instead of
1342
0
    // Adding more relocations
1343
0
    return ThrowConstructorWithoutNew(cx, "EventTarget");
1344
0
  }
1345
0
1346
0
  JS::Rooted<JSObject*> desiredProto(cx);
1347
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
1348
0
    return false;
1349
0
  }
1350
0
1351
0
  GlobalObject global(cx, obj);
1352
0
  if (global.Failed()) {
1353
0
    return false;
1354
0
  }
1355
0
1356
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1357
0
  Maybe<JSAutoRealm> ar;
1358
0
  if (objIsXray) {
1359
0
    obj = js::CheckedUnwrap(obj);
1360
0
    if (!obj) {
1361
0
      return false;
1362
0
    }
1363
0
    ar.emplace(cx, obj);
1364
0
    if (!JS_WrapObject(cx, &desiredProto)) {
1365
0
      return false;
1366
0
    }
1367
0
  }
1368
0
  FastErrorResult rv;
1369
0
  auto result(StrongOrRawPtr<mozilla::dom::EventTarget>(mozilla::dom::EventTarget::Constructor(global, rv)));
1370
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1371
0
    return false;
1372
0
  }
1373
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1374
0
  static_assert(!IsPointer<decltype(result)>::value,
1375
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1376
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1377
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1378
0
    return false;
1379
0
  }
1380
0
  return true;
1381
0
}
1382
1383
static const js::ClassOps sInterfaceObjectClassOps = {
1384
    nullptr,               /* addProperty */
1385
    nullptr,               /* delProperty */
1386
    nullptr,               /* enumerate */
1387
    nullptr,               /* newEnumerate */
1388
    nullptr,               /* resolve */
1389
    nullptr,               /* mayResolve */
1390
    nullptr,               /* finalize */
1391
    _constructor, /* call */
1392
    nullptr,               /* hasInstance */
1393
    _constructor, /* construct */
1394
    nullptr,               /* trace */
1395
};
1396
1397
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1398
  {
1399
    "Function",
1400
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1401
    &sInterfaceObjectClassOps,
1402
    JS_NULL_CLASS_SPEC,
1403
    JS_NULL_CLASS_EXT,
1404
    &sInterfaceObjectClassObjectOps
1405
  },
1406
  eInterface,
1407
  true,
1408
  prototypes::id::EventTarget,
1409
  PrototypeTraits<prototypes::id::EventTarget>::Depth,
1410
  sNativePropertyHooks,
1411
  "function EventTarget() {\n    [native code]\n}",
1412
  JS::GetRealmFunctionPrototype
1413
};
1414
1415
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1416
  {
1417
    "EventTargetPrototype",
1418
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1419
    JS_NULL_CLASS_OPS,
1420
    JS_NULL_CLASS_SPEC,
1421
    JS_NULL_CLASS_EXT,
1422
    JS_NULL_OBJECT_OPS
1423
  },
1424
  eInterfacePrototype,
1425
  false,
1426
  prototypes::id::EventTarget,
1427
  PrototypeTraits<prototypes::id::EventTarget>::Depth,
1428
  sNativePropertyHooks,
1429
  "[object EventTargetPrototype]",
1430
  JS::GetRealmObjectPrototype
1431
};
1432
1433
static const js::ClassOps sClassOps = {
1434
  _addProperty, /* addProperty */
1435
  nullptr,               /* delProperty */
1436
  nullptr,               /* enumerate */
1437
  nullptr, /* newEnumerate */
1438
  nullptr, /* resolve */
1439
  nullptr, /* mayResolve */
1440
  _finalize, /* finalize */
1441
  nullptr, /* call */
1442
  nullptr,               /* hasInstance */
1443
  nullptr,               /* construct */
1444
  nullptr, /* trace */
1445
};
1446
1447
static const js::ClassExtension sClassExtension = {
1448
  nullptr, /* weakmapKeyDelegateOp */
1449
  _objectMoved /* objectMovedOp */
1450
};
1451
1452
static const DOMJSClass sClass = {
1453
  { "EventTarget",
1454
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1455
    &sClassOps,
1456
    JS_NULL_CLASS_SPEC,
1457
    &sClassExtension,
1458
    JS_NULL_OBJECT_OPS
1459
  },
1460
  { prototypes::id::EventTarget, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1461
  IsBaseOf<nsISupports, mozilla::dom::EventTarget >::value,
1462
  sNativePropertyHooks,
1463
  FindAssociatedGlobalForNative<mozilla::dom::EventTarget>::Get,
1464
  GetProtoObjectHandle,
1465
  GetCCParticipant<mozilla::dom::EventTarget>::Get()
1466
};
1467
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1468
              "Must have the right minimal number of reserved slots.");
1469
static_assert(1 >= 1,
1470
              "Must have enough reserved slots.");
1471
1472
const JSClass*
1473
GetJSClass()
1474
0
{
1475
0
  return sClass.ToJSClass();
1476
0
}
1477
1478
bool
1479
Wrap(JSContext* aCx, mozilla::dom::EventTarget* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1480
0
{
1481
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::EventTarget>::value,
1482
0
                "Shouldn't have wrappercached things that are not refcounted.");
1483
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1484
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1485
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1486
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1487
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1488
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1489
0
             "You should probably not be using Wrap() directly; use "
1490
0
             "GetOrCreateDOMReflector instead");
1491
0
1492
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1493
0
             "nsISupports must be on our primary inheritance chain");
1494
0
1495
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1496
0
  if (!global) {
1497
0
    return false;
1498
0
  }
1499
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1500
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1501
0
1502
0
  // That might have ended up wrapping us already, due to the wonders
1503
0
  // of XBL.  Check for that, and bail out as needed.
1504
0
  aReflector.set(aCache->GetWrapper());
1505
0
  if (aReflector) {
1506
#ifdef DEBUG
1507
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1508
#endif // DEBUG
1509
    return true;
1510
0
  }
1511
0
1512
0
  JSAutoRealm ar(aCx, global);
1513
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1514
0
  if (!canonicalProto) {
1515
0
    return false;
1516
0
  }
1517
0
  JS::Rooted<JSObject*> proto(aCx);
1518
0
  if (aGivenProto) {
1519
0
    proto = aGivenProto;
1520
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1521
0
    // coming in, we changed compartments to that of "parent" so may need
1522
0
    // to wrap the proto here.
1523
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1524
0
      if (!JS_WrapObject(aCx, &proto)) {
1525
0
        return false;
1526
0
      }
1527
0
    }
1528
0
  } else {
1529
0
    proto = canonicalProto;
1530
0
  }
1531
0
1532
0
  BindingJSObjectCreator<mozilla::dom::EventTarget> creator(aCx);
1533
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1534
0
  if (!aReflector) {
1535
0
    return false;
1536
0
  }
1537
0
1538
0
  aCache->SetWrapper(aReflector);
1539
0
  creator.InitializationSucceeded();
1540
0
1541
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1542
0
             aCache->GetWrapperPreserveColor() == aReflector);
1543
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1544
0
  // otherwise we won't be able to properly recreate it later, since
1545
0
  // we won't know what proto to use.  Note that we don't check
1546
0
  // aGivenProto here, since it's entirely possible (and even
1547
0
  // somewhat common) to have a non-null aGivenProto which is the
1548
0
  // same as canonicalProto.
1549
0
  if (proto != canonicalProto) {
1550
0
    PreserveWrapper(aObject);
1551
0
  }
1552
0
1553
0
  return true;
1554
0
}
1555
1556
const NativePropertyHooks sNativePropertyHooks[] = { {
1557
  nullptr,
1558
  nullptr,
1559
  nullptr,
1560
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1561
  prototypes::id::EventTarget,
1562
  constructors::id::EventTarget,
1563
  nullptr,
1564
  &DefaultXrayExpandoObjectClass
1565
} };
1566
1567
void
1568
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1569
0
{
1570
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1571
0
  if (!parentProto) {
1572
0
    return;
1573
0
  }
1574
0
1575
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1576
0
  if (!constructorProto) {
1577
0
    return;
1578
0
  }
1579
0
1580
0
  static bool sIdsInited = false;
1581
0
  if (!sIdsInited && NS_IsMainThread()) {
1582
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1583
0
      return;
1584
0
    }
1585
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1586
0
      return;
1587
0
    }
1588
0
    sIdsInited = true;
1589
0
  }
1590
0
1591
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EventTarget);
1592
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::EventTarget);
1593
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1594
0
                              &sPrototypeClass.mBase, protoCache,
1595
0
                              nullptr,
1596
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1597
0
                              interfaceCache,
1598
0
                              sNativeProperties.Upcast(),
1599
0
                              sChromeOnlyNativeProperties.Upcast(),
1600
0
                              "EventTarget", aDefineOnGlobal,
1601
0
                              nullptr,
1602
0
                              false);
1603
0
1604
0
  if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EventTarget)) {
1605
0
    bool succeeded;
1606
0
    JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx);
1607
0
    if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) {
1608
0
      *protoCache = nullptr;
1609
0
      if (interfaceCache) {
1610
0
        *interfaceCache = nullptr;
1611
0
      }
1612
0
      return;
1613
0
    }
1614
0
1615
0
    MOZ_ASSERT(succeeded,
1616
0
               "making a fresh prototype object's [[Prototype]] "
1617
0
               "immutable can internally fail, but it should "
1618
0
               "never be unsuccessful");
1619
0
  }
1620
0
}
1621
1622
JSObject*
1623
GetProtoObject(JSContext* aCx)
1624
0
{
1625
0
  return GetProtoObjectHandle(aCx);
1626
0
}
1627
1628
JSObject*
1629
GetConstructorObject(JSContext* aCx)
1630
0
{
1631
0
  return GetConstructorObjectHandle(aCx);
1632
0
}
1633
1634
} // namespace EventTarget_Binding
1635
1636
1637
1638
} // namespace dom
1639
} // namespace mozilla