Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLTitleElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLTitleElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "HTMLElementBinding.h"
4
#include "HTMLTitleElementBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/CustomElementRegistry.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/DocGroup.h"
11
#include "mozilla/dom/HTMLTitleElement.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/XrayExpandoClass.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 HTMLTitleElement_Binding {
23
24
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value,
25
              "Can't inherit from an interface with a different ownership model.");
26
27
MOZ_CAN_RUN_SCRIPT static bool
28
get_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTitleElement* self, JSJitGetterCallArgs args)
29
0
{
30
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTitleElement.text", DOM, cx);
31
0
32
0
  FastErrorResult rv;
33
0
  DOMString result;
34
0
  self->GetText(result, rv);
35
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
36
0
    return false;
37
0
  }
38
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
39
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
40
0
    return false;
41
0
  }
42
0
  return true;
43
0
}
44
45
MOZ_CAN_RUN_SCRIPT static bool
46
set_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTitleElement* self, JSJitSetterCallArgs args)
47
0
{
48
0
  AUTO_PROFILER_LABEL_FAST("set HTMLTitleElement.text", DOM, cx);
49
0
50
0
  binding_detail::FakeString arg0;
51
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
52
0
    return false;
53
0
  }
54
0
  Maybe<AutoCEReaction> ceReaction;
55
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
56
0
    DocGroup* docGroup = self->GetDocGroup();
57
0
    if (docGroup) {
58
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
59
0
    }
60
0
  }
61
0
  FastErrorResult rv;
62
0
  self->SetText(NonNullHelper(Constify(arg0)), rv);
63
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
64
0
    return false;
65
0
  }
66
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
67
0
68
0
  return true;
69
0
}
70
71
static const JSJitInfo text_getterinfo = {
72
  { (JSJitGetterOp)get_text },
73
  { prototypes::id::HTMLTitleElement },
74
  { PrototypeTraits<prototypes::id::HTMLTitleElement>::Depth },
75
  JSJitInfo::Getter,
76
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
77
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
78
  false,  /* isInfallible. False in setters. */
79
  false,  /* isMovable.  Not relevant for setters. */
80
  false, /* isEliminatable.  Not relevant for setters. */
81
  false, /* isAlwaysInSlot.  Only relevant for getters. */
82
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
83
  false,  /* isTypedMethod.  Only relevant for methods. */
84
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
85
};
86
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
87
static_assert(0 < 1, "There is no slot for us");
88
static const JSJitInfo text_setterinfo = {
89
  { (JSJitGetterOp)set_text },
90
  { prototypes::id::HTMLTitleElement },
91
  { PrototypeTraits<prototypes::id::HTMLTitleElement>::Depth },
92
  JSJitInfo::Setter,
93
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
94
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
95
  false,  /* isInfallible. False in setters. */
96
  false,  /* isMovable.  Not relevant for setters. */
97
  false, /* isEliminatable.  Not relevant for setters. */
98
  false, /* isAlwaysInSlot.  Only relevant for getters. */
99
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
100
  false,  /* isTypedMethod.  Only relevant for methods. */
101
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
102
};
103
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
104
static_assert(0 < 1, "There is no slot for us");
105
106
static bool
107
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
108
0
{
109
0
  mozilla::dom::HTMLTitleElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTitleElement>(obj);
110
0
  // We don't want to preserve if we don't have a wrapper, and we
111
0
  // obviously can't preserve if we're not initialized.
112
0
  if (self && self->GetWrapperPreserveColor()) {
113
0
    PreserveWrapper(self);
114
0
  }
115
0
  return true;
116
0
}
117
118
static void
119
_finalize(js::FreeOp* fop, JSObject* obj)
120
0
{
121
0
  mozilla::dom::HTMLTitleElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTitleElement>(obj);
122
0
  if (self) {
123
0
    ClearWrapper(self, self, obj);
124
0
    AddForDeferredFinalization<mozilla::dom::HTMLTitleElement>(self);
125
0
  }
126
0
}
127
128
static size_t
129
_objectMoved(JSObject* obj, JSObject* old)
130
0
{
131
0
  mozilla::dom::HTMLTitleElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTitleElement>(obj);
132
0
  if (self) {
133
0
    UpdateWrapper(self, self, obj, old);
134
0
  }
135
0
136
0
  return 0;
137
0
}
138
139
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
140
#if defined(__clang__)
141
#pragma clang diagnostic push
142
#pragma clang diagnostic ignored "-Wmissing-braces"
143
#endif
144
static const JSPropertySpec sAttributes_specs[] = {
145
  { "text", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &text_getterinfo, GenericSetter<NormalThisPolicy>, &text_setterinfo },
146
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
147
};
148
#if defined(__clang__)
149
#pragma clang diagnostic pop
150
#endif
151
152
153
static const Prefable<const JSPropertySpec> sAttributes[] = {
154
  { nullptr, &sAttributes_specs[0] },
155
  { nullptr, nullptr }
156
};
157
158
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
159
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
160
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
161
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
162
163
164
static uint16_t sNativeProperties_sortedPropertyIndices[1];
165
static PropertyInfo sNativeProperties_propertyInfos[1];
166
167
static const NativePropertiesN<1> sNativeProperties = {
168
  false, 0,
169
  false, 0,
170
  false, 0,
171
  true,  0 /* sAttributes */,
172
  false, 0,
173
  false, 0,
174
  false, 0,
175
  -1,
176
  1,
177
  sNativeProperties_sortedPropertyIndices,
178
  {
179
    { sAttributes, &sNativeProperties_propertyInfos[0] }
180
  }
181
};
182
static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
183
    "We have a property info count that is oversized");
184
185
static bool
186
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
187
0
{
188
0
  AUTO_PROFILER_LABEL_FAST("HTMLTitleElement constructor", DOM, cx);
189
0
190
0
  return HTMLConstructor(cx, argc, vp,
191
0
                         constructors::id::HTMLTitleElement,
192
0
                         prototypes::id::HTMLTitleElement,
193
0
                         CreateInterfaceObjects);
194
0
}
195
196
static const js::ClassOps sInterfaceObjectClassOps = {
197
    nullptr,               /* addProperty */
198
    nullptr,               /* delProperty */
199
    nullptr,               /* enumerate */
200
    nullptr,               /* newEnumerate */
201
    nullptr,               /* resolve */
202
    nullptr,               /* mayResolve */
203
    nullptr,               /* finalize */
204
    _constructor, /* call */
205
    nullptr,               /* hasInstance */
206
    _constructor, /* construct */
207
    nullptr,               /* trace */
208
};
209
210
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
211
  {
212
    "Function",
213
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
214
    &sInterfaceObjectClassOps,
215
    JS_NULL_CLASS_SPEC,
216
    JS_NULL_CLASS_EXT,
217
    &sInterfaceObjectClassObjectOps
218
  },
219
  eInterface,
220
  true,
221
  prototypes::id::HTMLTitleElement,
222
  PrototypeTraits<prototypes::id::HTMLTitleElement>::Depth,
223
  sNativePropertyHooks,
224
  "function HTMLTitleElement() {\n    [native code]\n}",
225
  HTMLElement_Binding::GetConstructorObject
226
};
227
228
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
229
  {
230
    "HTMLTitleElementPrototype",
231
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
232
    JS_NULL_CLASS_OPS,
233
    JS_NULL_CLASS_SPEC,
234
    JS_NULL_CLASS_EXT,
235
    JS_NULL_OBJECT_OPS
236
  },
237
  eInterfacePrototype,
238
  false,
239
  prototypes::id::HTMLTitleElement,
240
  PrototypeTraits<prototypes::id::HTMLTitleElement>::Depth,
241
  sNativePropertyHooks,
242
  "[object HTMLTitleElementPrototype]",
243
  HTMLElement_Binding::GetProtoObject
244
};
245
246
static const js::ClassOps sClassOps = {
247
  _addProperty, /* addProperty */
248
  nullptr,               /* delProperty */
249
  nullptr,               /* enumerate */
250
  nullptr, /* newEnumerate */
251
  nullptr, /* resolve */
252
  nullptr, /* mayResolve */
253
  _finalize, /* finalize */
254
  nullptr, /* call */
255
  nullptr,               /* hasInstance */
256
  nullptr,               /* construct */
257
  nullptr, /* trace */
258
};
259
260
static const js::ClassExtension sClassExtension = {
261
  nullptr, /* weakmapKeyDelegateOp */
262
  _objectMoved /* objectMovedOp */
263
};
264
265
static const DOMJSClass sClass = {
266
  { "HTMLTitleElement",
267
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
268
    &sClassOps,
269
    JS_NULL_CLASS_SPEC,
270
    &sClassExtension,
271
    JS_NULL_OBJECT_OPS
272
  },
273
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLTitleElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
274
  IsBaseOf<nsISupports, mozilla::dom::HTMLTitleElement >::value,
275
  sNativePropertyHooks,
276
  FindAssociatedGlobalForNative<mozilla::dom::HTMLTitleElement>::Get,
277
  GetProtoObjectHandle,
278
  GetCCParticipant<mozilla::dom::HTMLTitleElement>::Get()
279
};
280
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
281
              "Must have the right minimal number of reserved slots.");
282
static_assert(1 >= 1,
283
              "Must have enough reserved slots.");
284
285
const JSClass*
286
GetJSClass()
287
0
{
288
0
  return sClass.ToJSClass();
289
0
}
290
291
bool
292
Wrap(JSContext* aCx, mozilla::dom::HTMLTitleElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
293
0
{
294
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLTitleElement>::value,
295
0
                "Shouldn't have wrappercached things that are not refcounted.");
296
0
  MOZ_ASSERT(static_cast<mozilla::dom::HTMLTitleElement*>(aObject) ==
297
0
             reinterpret_cast<mozilla::dom::HTMLTitleElement*>(aObject),
298
0
             "Multiple inheritance for mozilla::dom::HTMLTitleElement is broken.");
299
0
  MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
300
0
             reinterpret_cast<nsGenericHTMLElement*>(aObject),
301
0
             "Multiple inheritance for nsGenericHTMLElement is broken.");
302
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
303
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
304
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
305
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
306
0
             reinterpret_cast<nsINode*>(aObject),
307
0
             "Multiple inheritance for nsINode is broken.");
308
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
309
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
310
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
311
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
312
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
313
0
  MOZ_ASSERT(!aCache->GetWrapper(),
314
0
             "You should probably not be using Wrap() directly; use "
315
0
             "GetOrCreateDOMReflector instead");
316
0
317
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
318
0
             "nsISupports must be on our primary inheritance chain");
319
0
320
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
321
0
  if (!global) {
322
0
    return false;
323
0
  }
324
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
325
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
326
0
327
0
  // That might have ended up wrapping us already, due to the wonders
328
0
  // of XBL.  Check for that, and bail out as needed.
329
0
  aReflector.set(aCache->GetWrapper());
330
0
  if (aReflector) {
331
#ifdef DEBUG
332
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
333
#endif // DEBUG
334
    return true;
335
0
  }
336
0
337
0
  JSAutoRealm ar(aCx, global);
338
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
339
0
  if (!canonicalProto) {
340
0
    return false;
341
0
  }
342
0
  JS::Rooted<JSObject*> proto(aCx);
343
0
  if (aGivenProto) {
344
0
    proto = aGivenProto;
345
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
346
0
    // coming in, we changed compartments to that of "parent" so may need
347
0
    // to wrap the proto here.
348
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
349
0
      if (!JS_WrapObject(aCx, &proto)) {
350
0
        return false;
351
0
      }
352
0
    }
353
0
  } else {
354
0
    proto = canonicalProto;
355
0
  }
356
0
357
0
  BindingJSObjectCreator<mozilla::dom::HTMLTitleElement> creator(aCx);
358
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
359
0
  if (!aReflector) {
360
0
    return false;
361
0
  }
362
0
363
0
  aCache->SetWrapper(aReflector);
364
0
  creator.InitializationSucceeded();
365
0
366
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
367
0
             aCache->GetWrapperPreserveColor() == aReflector);
368
0
  // If proto != canonicalProto, we have to preserve our wrapper;
369
0
  // otherwise we won't be able to properly recreate it later, since
370
0
  // we won't know what proto to use.  Note that we don't check
371
0
  // aGivenProto here, since it's entirely possible (and even
372
0
  // somewhat common) to have a non-null aGivenProto which is the
373
0
  // same as canonicalProto.
374
0
  if (proto != canonicalProto) {
375
0
    PreserveWrapper(aObject);
376
0
  }
377
0
378
0
  return true;
379
0
}
380
381
const NativePropertyHooks sNativePropertyHooks[] = { {
382
  nullptr,
383
  nullptr,
384
  nullptr,
385
  { sNativeProperties.Upcast(), nullptr },
386
  prototypes::id::HTMLTitleElement,
387
  constructors::id::HTMLTitleElement,
388
  HTMLElement_Binding::sNativePropertyHooks,
389
  &DefaultXrayExpandoObjectClass
390
} };
391
392
void
393
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
394
0
{
395
0
  JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx));
396
0
  if (!parentProto) {
397
0
    return;
398
0
  }
399
0
400
0
  JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx));
401
0
  if (!constructorProto) {
402
0
    return;
403
0
  }
404
0
405
0
  static bool sIdsInited = false;
406
0
  if (!sIdsInited && NS_IsMainThread()) {
407
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
408
0
      return;
409
0
    }
410
0
    sIdsInited = true;
411
0
  }
412
0
413
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLTitleElement);
414
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLTitleElement);
415
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
416
0
                              &sPrototypeClass.mBase, protoCache,
417
0
                              nullptr,
418
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
419
0
                              interfaceCache,
420
0
                              sNativeProperties.Upcast(),
421
0
                              nullptr,
422
0
                              "HTMLTitleElement", aDefineOnGlobal,
423
0
                              nullptr,
424
0
                              false);
425
0
}
426
427
JSObject*
428
GetConstructorObject(JSContext* aCx)
429
0
{
430
0
  return GetConstructorObjectHandle(aCx);
431
0
}
432
433
} // namespace HTMLTitleElement_Binding
434
435
436
437
} // namespace dom
438
} // namespace mozilla