Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/CreateOfferRequestBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM CreateOfferRequest.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "CreateOfferRequestBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/NonRefcountedDOMObject.h"
10
#include "mozilla/dom/PrimitiveConversions.h"
11
#include "mozilla/dom/XrayExpandoClass.h"
12
#include "nsContentUtils.h"
13
#include "nsIGlobalObject.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
namespace binding_detail {}; // Just to make sure it's known as a namespace
19
using namespace mozilla::dom::binding_detail;
20
21
22
namespace CreateOfferRequest_Binding {
23
24
MOZ_CAN_RUN_SCRIPT static bool
25
get_windowID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CreateOfferRequest* self, JSJitGetterCallArgs args)
26
0
{
27
0
  AUTO_PROFILER_LABEL_FAST("get CreateOfferRequest.windowID", DOM, cx);
28
0
29
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
30
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
31
0
  if (objIsXray) {
32
0
    unwrappedObj.emplace(cx, obj);
33
0
  }
34
0
  if (objIsXray) {
35
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
36
0
    if (!unwrappedObj.ref()) {
37
0
      return false;
38
0
    }
39
0
  }
40
0
  FastErrorResult rv;
41
0
  uint64_t result(self->GetWindowID(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))));
42
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
43
0
    return false;
44
0
  }
45
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
46
0
  args.rval().set(JS_NumberValue(double(result)));
47
0
  return true;
48
0
}
49
50
static const JSJitInfo windowID_getterinfo = {
51
  { (JSJitGetterOp)get_windowID },
52
  { prototypes::id::CreateOfferRequest },
53
  { PrototypeTraits<prototypes::id::CreateOfferRequest>::Depth },
54
  JSJitInfo::Getter,
55
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
56
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
57
  false,  /* isInfallible. False in setters. */
58
  false,  /* isMovable.  Not relevant for setters. */
59
  false, /* isEliminatable.  Not relevant for setters. */
60
  false, /* isAlwaysInSlot.  Only relevant for getters. */
61
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
62
  false,  /* isTypedMethod.  Only relevant for methods. */
63
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
64
};
65
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
66
static_assert(0 < 1, "There is no slot for us");
67
68
MOZ_CAN_RUN_SCRIPT static bool
69
get_innerWindowID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CreateOfferRequest* self, JSJitGetterCallArgs args)
70
0
{
71
0
  AUTO_PROFILER_LABEL_FAST("get CreateOfferRequest.innerWindowID", DOM, cx);
72
0
73
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
74
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
75
0
  if (objIsXray) {
76
0
    unwrappedObj.emplace(cx, obj);
77
0
  }
78
0
  if (objIsXray) {
79
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
80
0
    if (!unwrappedObj.ref()) {
81
0
      return false;
82
0
    }
83
0
  }
84
0
  FastErrorResult rv;
85
0
  uint64_t result(self->GetInnerWindowID(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))));
86
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
87
0
    return false;
88
0
  }
89
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
90
0
  args.rval().set(JS_NumberValue(double(result)));
91
0
  return true;
92
0
}
93
94
static const JSJitInfo innerWindowID_getterinfo = {
95
  { (JSJitGetterOp)get_innerWindowID },
96
  { prototypes::id::CreateOfferRequest },
97
  { PrototypeTraits<prototypes::id::CreateOfferRequest>::Depth },
98
  JSJitInfo::Getter,
99
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
100
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
101
  false,  /* isInfallible. False in setters. */
102
  false,  /* isMovable.  Not relevant for setters. */
103
  false, /* isEliminatable.  Not relevant for setters. */
104
  false, /* isAlwaysInSlot.  Only relevant for getters. */
105
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
106
  false,  /* isTypedMethod.  Only relevant for methods. */
107
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
108
};
109
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
110
static_assert(0 < 1, "There is no slot for us");
111
112
MOZ_CAN_RUN_SCRIPT static bool
113
get_callID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CreateOfferRequest* self, JSJitGetterCallArgs args)
114
0
{
115
0
  AUTO_PROFILER_LABEL_FAST("get CreateOfferRequest.callID", DOM, cx);
116
0
117
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
118
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
119
0
  if (objIsXray) {
120
0
    unwrappedObj.emplace(cx, obj);
121
0
  }
122
0
  if (objIsXray) {
123
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
124
0
    if (!unwrappedObj.ref()) {
125
0
      return false;
126
0
    }
127
0
  }
128
0
  FastErrorResult rv;
129
0
  DOMString result;
130
0
  self->GetCallID(result, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)));
131
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
132
0
    return false;
133
0
  }
134
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
135
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
136
0
    return false;
137
0
  }
138
0
  return true;
139
0
}
140
141
static const JSJitInfo callID_getterinfo = {
142
  { (JSJitGetterOp)get_callID },
143
  { prototypes::id::CreateOfferRequest },
144
  { PrototypeTraits<prototypes::id::CreateOfferRequest>::Depth },
145
  JSJitInfo::Getter,
146
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
147
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
148
  false,  /* isInfallible. False in setters. */
149
  false,  /* isMovable.  Not relevant for setters. */
150
  false, /* isEliminatable.  Not relevant for setters. */
151
  false, /* isAlwaysInSlot.  Only relevant for getters. */
152
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
153
  false,  /* isTypedMethod.  Only relevant for methods. */
154
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
155
};
156
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
157
static_assert(0 < 1, "There is no slot for us");
158
159
MOZ_CAN_RUN_SCRIPT static bool
160
get_isSecure(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CreateOfferRequest* self, JSJitGetterCallArgs args)
161
0
{
162
0
  AUTO_PROFILER_LABEL_FAST("get CreateOfferRequest.isSecure", DOM, cx);
163
0
164
0
  Maybe<JS::Rooted<JSObject*> > unwrappedObj;
165
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
166
0
  if (objIsXray) {
167
0
    unwrappedObj.emplace(cx, obj);
168
0
  }
169
0
  if (objIsXray) {
170
0
    unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref());
171
0
    if (!unwrappedObj.ref()) {
172
0
      return false;
173
0
    }
174
0
  }
175
0
  FastErrorResult rv;
176
0
  bool result(self->GetIsSecure(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))));
177
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
178
0
    return false;
179
0
  }
180
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
181
0
  args.rval().setBoolean(result);
182
0
  return true;
183
0
}
184
185
static const JSJitInfo isSecure_getterinfo = {
186
  { (JSJitGetterOp)get_isSecure },
187
  { prototypes::id::CreateOfferRequest },
188
  { PrototypeTraits<prototypes::id::CreateOfferRequest>::Depth },
189
  JSJitInfo::Getter,
190
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
191
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
192
  false,  /* isInfallible. False in setters. */
193
  false,  /* isMovable.  Not relevant for setters. */
194
  false, /* isEliminatable.  Not relevant for setters. */
195
  false, /* isAlwaysInSlot.  Only relevant for getters. */
196
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
197
  false,  /* isTypedMethod.  Only relevant for methods. */
198
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
199
};
200
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
201
static_assert(0 < 1, "There is no slot for us");
202
203
static bool
204
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
205
0
{
206
0
  mozilla::dom::CreateOfferRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CreateOfferRequest>(obj);
207
0
  // We don't want to preserve if we don't have a wrapper, and we
208
0
  // obviously can't preserve if we're not initialized.
209
0
  if (self && self->GetWrapperPreserveColor()) {
210
0
    PreserveWrapper(self);
211
0
  }
212
0
  return true;
213
0
}
214
215
static void
216
_finalize(js::FreeOp* fop, JSObject* obj)
217
0
{
218
0
  mozilla::dom::CreateOfferRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CreateOfferRequest>(obj);
219
0
  if (self) {
220
0
    ClearWrapper(self, self, obj);
221
0
    AddForDeferredFinalization<mozilla::dom::CreateOfferRequest>(self);
222
0
  }
223
0
}
224
225
static size_t
226
_objectMoved(JSObject* obj, JSObject* old)
227
0
{
228
0
  mozilla::dom::CreateOfferRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CreateOfferRequest>(obj);
229
0
  if (self) {
230
0
    UpdateWrapper(self, self, obj, old);
231
0
  }
232
0
233
0
  return 0;
234
0
}
235
236
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
237
#if defined(__clang__)
238
#pragma clang diagnostic push
239
#pragma clang diagnostic ignored "-Wmissing-braces"
240
#endif
241
static const JSFunctionSpec sChromeStaticMethods_specs[] = {
242
  JS_FNSPEC("_create", CreateOfferRequest::_Create, nullptr, 2, 0, nullptr),
243
  JS_FS_END
244
};
245
#if defined(__clang__)
246
#pragma clang diagnostic pop
247
#endif
248
249
250
static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = {
251
  { nullptr, &sChromeStaticMethods_specs[0] },
252
  { nullptr, nullptr }
253
};
254
255
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
256
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
257
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
258
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
259
260
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
261
#if defined(__clang__)
262
#pragma clang diagnostic push
263
#pragma clang diagnostic ignored "-Wmissing-braces"
264
#endif
265
static const JSPropertySpec sAttributes_specs[] = {
266
  { "windowID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &windowID_getterinfo, nullptr, nullptr },
267
  { "innerWindowID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &innerWindowID_getterinfo, nullptr, nullptr },
268
  { "callID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &callID_getterinfo, nullptr, nullptr },
269
  { "isSecure", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isSecure_getterinfo, nullptr, nullptr },
270
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
271
};
272
#if defined(__clang__)
273
#pragma clang diagnostic pop
274
#endif
275
276
277
static const Prefable<const JSPropertySpec> sAttributes[] = {
278
  { nullptr, &sAttributes_specs[0] },
279
  { nullptr, nullptr }
280
};
281
282
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
283
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
284
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
285
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
286
287
288
static uint16_t sNativeProperties_sortedPropertyIndices[4];
289
static PropertyInfo sNativeProperties_propertyInfos[4];
290
291
static const NativePropertiesN<1> sNativeProperties = {
292
  false, 0,
293
  false, 0,
294
  false, 0,
295
  true,  0 /* sAttributes */,
296
  false, 0,
297
  false, 0,
298
  false, 0,
299
  -1,
300
  4,
301
  sNativeProperties_sortedPropertyIndices,
302
  {
303
    { sAttributes, &sNativeProperties_propertyInfos[0] }
304
  }
305
};
306
static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
307
    "We have a property info count that is oversized");
308
309
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
310
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
311
312
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
313
  true,  0 /* sChromeStaticMethods */,
314
  false, 0,
315
  false, 0,
316
  false, 0,
317
  false, 0,
318
  false, 0,
319
  false, 0,
320
  -1,
321
  1,
322
  sChromeOnlyNativeProperties_sortedPropertyIndices,
323
  {
324
    { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
325
  }
326
};
327
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
328
    "We have a property info count that is oversized");
329
330
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
331
  {
332
    "Function",
333
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
334
    &sBoringInterfaceObjectClassClassOps,
335
    JS_NULL_CLASS_SPEC,
336
    JS_NULL_CLASS_EXT,
337
    &sInterfaceObjectClassObjectOps
338
  },
339
  eInterface,
340
  true,
341
  prototypes::id::CreateOfferRequest,
342
  PrototypeTraits<prototypes::id::CreateOfferRequest>::Depth,
343
  sNativePropertyHooks,
344
  "function CreateOfferRequest() {\n    [native code]\n}",
345
  JS::GetRealmFunctionPrototype
346
};
347
348
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
349
  {
350
    "CreateOfferRequestPrototype",
351
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
352
    JS_NULL_CLASS_OPS,
353
    JS_NULL_CLASS_SPEC,
354
    JS_NULL_CLASS_EXT,
355
    JS_NULL_OBJECT_OPS
356
  },
357
  eInterfacePrototype,
358
  false,
359
  prototypes::id::CreateOfferRequest,
360
  PrototypeTraits<prototypes::id::CreateOfferRequest>::Depth,
361
  sNativePropertyHooks,
362
  "[object CreateOfferRequestPrototype]",
363
  JS::GetRealmObjectPrototype
364
};
365
366
bool
367
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
368
0
{
369
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
370
0
}
371
372
static const js::ClassOps sClassOps = {
373
  _addProperty, /* addProperty */
374
  nullptr,               /* delProperty */
375
  nullptr,               /* enumerate */
376
  nullptr, /* newEnumerate */
377
  nullptr, /* resolve */
378
  nullptr, /* mayResolve */
379
  _finalize, /* finalize */
380
  nullptr, /* call */
381
  nullptr,               /* hasInstance */
382
  nullptr,               /* construct */
383
  nullptr, /* trace */
384
};
385
386
static const js::ClassExtension sClassExtension = {
387
  nullptr, /* weakmapKeyDelegateOp */
388
  _objectMoved /* objectMovedOp */
389
};
390
391
static const DOMJSClass sClass = {
392
  { "CreateOfferRequest",
393
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
394
    &sClassOps,
395
    JS_NULL_CLASS_SPEC,
396
    &sClassExtension,
397
    JS_NULL_OBJECT_OPS
398
  },
399
  { prototypes::id::CreateOfferRequest, 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 },
400
  IsBaseOf<nsISupports, mozilla::dom::CreateOfferRequest >::value,
401
  sNativePropertyHooks,
402
  FindAssociatedGlobalForNative<mozilla::dom::CreateOfferRequest>::Get,
403
  GetProtoObjectHandle,
404
  GetCCParticipant<mozilla::dom::CreateOfferRequest>::Get()
405
};
406
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
407
              "Must have the right minimal number of reserved slots.");
408
static_assert(1 >= 1,
409
              "Must have enough reserved slots.");
410
411
const JSClass*
412
GetJSClass()
413
0
{
414
0
  return sClass.ToJSClass();
415
0
}
416
417
bool
418
Wrap(JSContext* aCx, mozilla::dom::CreateOfferRequest* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
419
0
{
420
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CreateOfferRequest>::value,
421
0
                "Shouldn't have wrappercached things that are not refcounted.");
422
0
  MOZ_ASSERT(static_cast<mozilla::dom::CreateOfferRequest*>(aObject) ==
423
0
             reinterpret_cast<mozilla::dom::CreateOfferRequest*>(aObject),
424
0
             "Multiple inheritance for mozilla::dom::CreateOfferRequest is broken.");
425
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
426
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
427
0
  MOZ_ASSERT(!aCache->GetWrapper(),
428
0
             "You should probably not be using Wrap() directly; use "
429
0
             "GetOrCreateDOMReflector instead");
430
0
431
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
432
0
             "nsISupports must be on our primary inheritance chain");
433
0
434
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
435
0
  if (!global) {
436
0
    return false;
437
0
  }
438
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
439
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
440
0
441
0
  // That might have ended up wrapping us already, due to the wonders
442
0
  // of XBL.  Check for that, and bail out as needed.
443
0
  aReflector.set(aCache->GetWrapper());
444
0
  if (aReflector) {
445
#ifdef DEBUG
446
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
447
#endif // DEBUG
448
    return true;
449
0
  }
450
0
451
0
  JSAutoRealm ar(aCx, global);
452
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
453
0
  if (!canonicalProto) {
454
0
    return false;
455
0
  }
456
0
  JS::Rooted<JSObject*> proto(aCx);
457
0
  if (aGivenProto) {
458
0
    proto = aGivenProto;
459
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
460
0
    // coming in, we changed compartments to that of "parent" so may need
461
0
    // to wrap the proto here.
462
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
463
0
      if (!JS_WrapObject(aCx, &proto)) {
464
0
        return false;
465
0
      }
466
0
    }
467
0
  } else {
468
0
    proto = canonicalProto;
469
0
  }
470
0
471
0
  BindingJSObjectCreator<mozilla::dom::CreateOfferRequest> creator(aCx);
472
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
473
0
  if (!aReflector) {
474
0
    return false;
475
0
  }
476
0
477
0
  aCache->SetWrapper(aReflector);
478
0
  creator.InitializationSucceeded();
479
0
480
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
481
0
             aCache->GetWrapperPreserveColor() == aReflector);
482
0
  // If proto != canonicalProto, we have to preserve our wrapper;
483
0
  // otherwise we won't be able to properly recreate it later, since
484
0
  // we won't know what proto to use.  Note that we don't check
485
0
  // aGivenProto here, since it's entirely possible (and even
486
0
  // somewhat common) to have a non-null aGivenProto which is the
487
0
  // same as canonicalProto.
488
0
  if (proto != canonicalProto) {
489
0
    PreserveWrapper(aObject);
490
0
  }
491
0
492
0
  return true;
493
0
}
494
495
const NativePropertyHooks sNativePropertyHooks[] = { {
496
  nullptr,
497
  nullptr,
498
  nullptr,
499
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
500
  prototypes::id::CreateOfferRequest,
501
  constructors::id::CreateOfferRequest,
502
  nullptr,
503
  &DefaultXrayExpandoObjectClass
504
} };
505
506
void
507
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
508
0
{
509
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
510
0
  if (!parentProto) {
511
0
    return;
512
0
  }
513
0
514
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
515
0
  if (!constructorProto) {
516
0
    return;
517
0
  }
518
0
519
0
  static bool sIdsInited = false;
520
0
  if (!sIdsInited && NS_IsMainThread()) {
521
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
522
0
      return;
523
0
    }
524
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
525
0
      return;
526
0
    }
527
0
    sIdsInited = true;
528
0
  }
529
0
530
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CreateOfferRequest);
531
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CreateOfferRequest);
532
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
533
0
                              &sPrototypeClass.mBase, protoCache,
534
0
                              nullptr,
535
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
536
0
                              interfaceCache,
537
0
                              sNativeProperties.Upcast(),
538
0
                              sChromeOnlyNativeProperties.Upcast(),
539
0
                              "CreateOfferRequest", aDefineOnGlobal,
540
0
                              nullptr,
541
0
                              false);
542
0
}
543
544
JSObject*
545
GetConstructorObject(JSContext* aCx)
546
0
{
547
0
  return GetConstructorObjectHandle(aCx);
548
0
}
549
550
} // namespace CreateOfferRequest_Binding
551
552
553
554
bool
555
CreateOfferRequestJSImpl::InitIds(JSContext* cx, CreateOfferRequestAtoms* atomsCache)
556
0
{
557
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
558
0
559
0
  // Initialize these in reverse order so that any failure leaves the first one
560
0
  // uninitialized.
561
0
  if (!atomsCache->isSecure_id.init(cx, "isSecure") ||
562
0
      !atomsCache->callID_id.init(cx, "callID") ||
563
0
      !atomsCache->innerWindowID_id.init(cx, "innerWindowID") ||
564
0
      !atomsCache->windowID_id.init(cx, "windowID")) {
565
0
    return false;
566
0
  }
567
0
  return true;
568
0
}
569
570
571
uint64_t
572
CreateOfferRequestJSImpl::GetWindowID(ErrorResult& aRv, JS::Realm* aRealm)
573
0
{
574
0
  CallSetup s(this, aRv, "CreateOfferRequest.windowID", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
575
0
  JSContext* cx = s.GetContext();
576
0
  if (!cx) {
577
0
    MOZ_ASSERT(aRv.Failed());
578
0
    return uint64_t(0);
579
0
  }
580
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
581
0
582
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
583
0
  CreateOfferRequestAtoms* atomsCache = GetAtomCache<CreateOfferRequestAtoms>(cx);
584
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
585
0
      !JS_GetPropertyById(cx, callback, atomsCache->windowID_id, &rval)) {
586
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
587
0
    return uint64_t(0);
588
0
  }
589
0
  uint64_t rvalDecl;
590
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, rval, &rvalDecl)) {
591
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
592
0
    return uint64_t(0);
593
0
  }
594
0
  return rvalDecl;
595
0
}
596
597
uint64_t
598
CreateOfferRequestJSImpl::GetInnerWindowID(ErrorResult& aRv, JS::Realm* aRealm)
599
0
{
600
0
  CallSetup s(this, aRv, "CreateOfferRequest.innerWindowID", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
601
0
  JSContext* cx = s.GetContext();
602
0
  if (!cx) {
603
0
    MOZ_ASSERT(aRv.Failed());
604
0
    return uint64_t(0);
605
0
  }
606
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
607
0
608
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
609
0
  CreateOfferRequestAtoms* atomsCache = GetAtomCache<CreateOfferRequestAtoms>(cx);
610
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
611
0
      !JS_GetPropertyById(cx, callback, atomsCache->innerWindowID_id, &rval)) {
612
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
613
0
    return uint64_t(0);
614
0
  }
615
0
  uint64_t rvalDecl;
616
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, rval, &rvalDecl)) {
617
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
618
0
    return uint64_t(0);
619
0
  }
620
0
  return rvalDecl;
621
0
}
622
623
void
624
CreateOfferRequestJSImpl::GetCallID(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm)
625
0
{
626
0
  CallSetup s(this, aRv, "CreateOfferRequest.callID", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
627
0
  JSContext* cx = s.GetContext();
628
0
  if (!cx) {
629
0
    MOZ_ASSERT(aRv.Failed());
630
0
    return;
631
0
  }
632
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
633
0
634
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
635
0
  CreateOfferRequestAtoms* atomsCache = GetAtomCache<CreateOfferRequestAtoms>(cx);
636
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
637
0
      !JS_GetPropertyById(cx, callback, atomsCache->callID_id, &rval)) {
638
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
639
0
    return;
640
0
  }
641
0
  binding_detail::FakeString rvalDecl;
642
0
  if (!ConvertJSValueToString(cx, rval, eStringify, eStringify, rvalDecl)) {
643
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
644
0
    return;
645
0
  }
646
0
  aRetVal = rvalDecl;
647
0
}
648
649
bool
650
CreateOfferRequestJSImpl::GetIsSecure(ErrorResult& aRv, JS::Realm* aRealm)
651
0
{
652
0
  CallSetup s(this, aRv, "CreateOfferRequest.isSecure", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true);
653
0
  JSContext* cx = s.GetContext();
654
0
  if (!cx) {
655
0
    MOZ_ASSERT(aRv.Failed());
656
0
    return bool(0);
657
0
  }
658
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
659
0
660
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
661
0
  CreateOfferRequestAtoms* atomsCache = GetAtomCache<CreateOfferRequestAtoms>(cx);
662
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
663
0
      !JS_GetPropertyById(cx, callback, atomsCache->isSecure_id, &rval)) {
664
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
665
0
    return bool(0);
666
0
  }
667
0
  bool rvalDecl;
668
0
  if (!ValueToPrimitive<bool, eDefault>(cx, rval, &rvalDecl)) {
669
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
670
0
    return bool(0);
671
0
  }
672
0
  return rvalDecl;
673
0
}
674
675
676
NS_IMPL_CYCLE_COLLECTION_CLASS(CreateOfferRequest)
677
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CreateOfferRequest)
678
0
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mImpl)
679
0
  NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
680
0
  NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
681
0
  tmp->ClearWeakReferences();
682
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
683
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CreateOfferRequest)
684
0
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl)
685
0
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
686
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
687
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CreateOfferRequest)
688
NS_IMPL_CYCLE_COLLECTING_ADDREF(CreateOfferRequest)
689
NS_IMPL_CYCLE_COLLECTING_RELEASE(CreateOfferRequest)
690
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CreateOfferRequest)
691
0
  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
692
0
  NS_INTERFACE_MAP_ENTRY(nsISupports)
693
0
  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
694
0
NS_INTERFACE_MAP_END
695
696
CreateOfferRequest::CreateOfferRequest(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent)
697
  : mImpl(new CreateOfferRequestJSImpl(nullptr, aJSImplObject, aJSImplGlobal, /* aIncumbentGlobal = */ nullptr)),
698
    mParent(aParent)
699
0
{
700
0
}
701
702
703
CreateOfferRequest::~CreateOfferRequest()
704
0
{
705
0
}
706
707
nsISupports*
708
CreateOfferRequest::GetParentObject() const
709
0
{
710
0
  return mParent;
711
0
}
712
713
JSObject*
714
CreateOfferRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
715
0
{
716
0
  JS::Rooted<JSObject*> obj(aCx, CreateOfferRequest_Binding::Wrap(aCx, this, aGivenProto));
717
0
  if (!obj) {
718
0
    return nullptr;
719
0
  }
720
0
721
0
  // Now define it on our chrome object
722
0
  JSAutoRealm ar(aCx, mImpl->CallbackGlobalOrNull());
723
0
  if (!JS_WrapObject(aCx, &obj)) {
724
0
    return nullptr;
725
0
  }
726
0
  if (!JS_DefineProperty(aCx, mImpl->CallbackOrNull(), "__DOM_IMPL__", obj, 0)) {
727
0
    return nullptr;
728
0
  }
729
0
  return obj;
730
0
}
731
732
uint64_t
733
CreateOfferRequest::GetWindowID(ErrorResult& aRv, JS::Realm* aRealm) const
734
0
{
735
0
  return mImpl->GetWindowID(aRv, aRealm);
736
0
}
737
738
uint64_t
739
CreateOfferRequest::GetInnerWindowID(ErrorResult& aRv, JS::Realm* aRealm) const
740
0
{
741
0
  return mImpl->GetInnerWindowID(aRv, aRealm);
742
0
}
743
744
void
745
CreateOfferRequest::GetCallID(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) const
746
0
{
747
0
  return mImpl->GetCallID(aRetVal, aRv, aRealm);
748
0
}
749
750
bool
751
CreateOfferRequest::GetIsSecure(ErrorResult& aRv, JS::Realm* aRealm) const
752
0
{
753
0
  return mImpl->GetIsSecure(aRv, aRealm);
754
0
}
755
756
bool
757
CreateOfferRequest::_Create(JSContext* cx, unsigned argc, JS::Value* vp)
758
0
{
759
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
760
0
  if (args.length() < 2) {
761
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CreateOfferRequest._create");
762
0
  }
763
0
  if (!args[0].isObject()) {
764
0
    return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CreateOfferRequest._create");
765
0
  }
766
0
  if (!args[1].isObject()) {
767
0
    return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of CreateOfferRequest._create");
768
0
  }
769
0
770
0
  // GlobalObject will go through wrappers as needed for us, and
771
0
  // is simpler than the right UnwrapArg incantation.
772
0
  GlobalObject global(cx, &args[0].toObject());
773
0
  if (global.Failed()) {
774
0
    return false;
775
0
  }
776
0
  nsCOMPtr<nsIGlobalObject> globalHolder = do_QueryInterface(global.GetAsSupports());
777
0
  MOZ_ASSERT(globalHolder);
778
0
  JS::Rooted<JSObject*> arg(cx, &args[1].toObject());
779
0
  JS::Rooted<JSObject*> argGlobal(cx, JS::CurrentGlobalOrNull(cx));
780
0
  RefPtr<CreateOfferRequest> impl = new CreateOfferRequest(arg, argGlobal, globalHolder);
781
0
  MOZ_ASSERT(js::IsObjectInContextCompartment(arg, cx));
782
0
  return GetOrCreateDOMReflector(cx, impl, args.rval());
783
0
}
784
785
786
} // namespace dom
787
} // namespace mozilla