Coverage Report

Created: 2018-09-25 14:53

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