Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/PerformanceNavigationTimingBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM PerformanceNavigationTiming.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "PerformanceEntryBinding.h"
4
#include "PerformanceNavigationTimingBinding.h"
5
#include "PerformanceResourceTimingBinding.h"
6
#include "WrapperFactory.h"
7
#include "XrayWrapper.h"
8
#include "jsapi.h"
9
#include "mozilla/FloatingPoint.h"
10
#include "mozilla/OwningNonNull.h"
11
#include "mozilla/dom/BindingUtils.h"
12
#include "mozilla/dom/DOMJSClass.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/PerformanceNavigationTiming.h"
15
#include "mozilla/dom/PrimitiveConversions.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
namespace NavigationTypeValues {
26
extern const EnumEntry strings[5] = {
27
  {"navigate", 8},
28
  {"reload", 6},
29
  {"back_forward", 12},
30
  {"prerender", 9},
31
  { nullptr, 0 }
32
};
33
} // namespace NavigationTypeValues
34
35
bool
36
ToJSValue(JSContext* aCx, NavigationType aArgument, JS::MutableHandle<JS::Value> aValue)
37
0
{
38
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(NavigationTypeValues::strings));
39
0
  JSString* resultStr =
40
0
    JS_NewStringCopyN(aCx, NavigationTypeValues::strings[uint32_t(aArgument)].value,
41
0
                      NavigationTypeValues::strings[uint32_t(aArgument)].length);
42
0
  if (!resultStr) {
43
0
    return false;
44
0
  }
45
0
  aValue.setString(resultStr);
46
0
  return true;
47
0
}
48
49
50
namespace PerformanceNavigationTiming_Binding {
51
52
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<PerformanceResourceTiming_Binding::NativeType>::value,
53
              "Can't inherit from an interface with a different ownership model.");
54
55
MOZ_CAN_RUN_SCRIPT static bool
56
get_unloadEventStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
57
0
{
58
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.unloadEventStart", DOM, cx);
59
0
60
0
  double result(self->UnloadEventStart());
61
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
62
0
  args.rval().set(JS_NumberValue(double(result)));
63
0
  return true;
64
0
}
65
66
static const JSJitInfo unloadEventStart_getterinfo = {
67
  { (JSJitGetterOp)get_unloadEventStart },
68
  { prototypes::id::PerformanceNavigationTiming },
69
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
70
  JSJitInfo::Getter,
71
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
72
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
73
  true,  /* isInfallible. False in setters. */
74
  false,  /* isMovable.  Not relevant for setters. */
75
  false, /* isEliminatable.  Not relevant for setters. */
76
  false, /* isAlwaysInSlot.  Only relevant for getters. */
77
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
78
  false,  /* isTypedMethod.  Only relevant for methods. */
79
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
80
};
81
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
82
static_assert(0 < 2, "There is no slot for us");
83
84
MOZ_CAN_RUN_SCRIPT static bool
85
get_unloadEventEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
86
0
{
87
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.unloadEventEnd", DOM, cx);
88
0
89
0
  double result(self->UnloadEventEnd());
90
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
91
0
  args.rval().set(JS_NumberValue(double(result)));
92
0
  return true;
93
0
}
94
95
static const JSJitInfo unloadEventEnd_getterinfo = {
96
  { (JSJitGetterOp)get_unloadEventEnd },
97
  { prototypes::id::PerformanceNavigationTiming },
98
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
99
  JSJitInfo::Getter,
100
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
101
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
102
  true,  /* isInfallible. False in setters. */
103
  false,  /* isMovable.  Not relevant for setters. */
104
  false, /* isEliminatable.  Not relevant for setters. */
105
  false, /* isAlwaysInSlot.  Only relevant for getters. */
106
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
107
  false,  /* isTypedMethod.  Only relevant for methods. */
108
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
109
};
110
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
111
static_assert(0 < 2, "There is no slot for us");
112
113
MOZ_CAN_RUN_SCRIPT static bool
114
get_domInteractive(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
115
0
{
116
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.domInteractive", DOM, cx);
117
0
118
0
  double result(self->DomInteractive());
119
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
120
0
  args.rval().set(JS_NumberValue(double(result)));
121
0
  return true;
122
0
}
123
124
static const JSJitInfo domInteractive_getterinfo = {
125
  { (JSJitGetterOp)get_domInteractive },
126
  { prototypes::id::PerformanceNavigationTiming },
127
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
128
  JSJitInfo::Getter,
129
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
130
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
131
  true,  /* isInfallible. False in setters. */
132
  false,  /* isMovable.  Not relevant for setters. */
133
  false, /* isEliminatable.  Not relevant for setters. */
134
  false, /* isAlwaysInSlot.  Only relevant for getters. */
135
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
136
  false,  /* isTypedMethod.  Only relevant for methods. */
137
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
138
};
139
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
140
static_assert(0 < 2, "There is no slot for us");
141
142
MOZ_CAN_RUN_SCRIPT static bool
143
get_domContentLoadedEventStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
144
0
{
145
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.domContentLoadedEventStart", DOM, cx);
146
0
147
0
  double result(self->DomContentLoadedEventStart());
148
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
149
0
  args.rval().set(JS_NumberValue(double(result)));
150
0
  return true;
151
0
}
152
153
static const JSJitInfo domContentLoadedEventStart_getterinfo = {
154
  { (JSJitGetterOp)get_domContentLoadedEventStart },
155
  { prototypes::id::PerformanceNavigationTiming },
156
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
157
  JSJitInfo::Getter,
158
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
159
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
160
  true,  /* isInfallible. False in setters. */
161
  false,  /* isMovable.  Not relevant for setters. */
162
  false, /* isEliminatable.  Not relevant for setters. */
163
  false, /* isAlwaysInSlot.  Only relevant for getters. */
164
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
165
  false,  /* isTypedMethod.  Only relevant for methods. */
166
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
167
};
168
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
169
static_assert(0 < 2, "There is no slot for us");
170
171
MOZ_CAN_RUN_SCRIPT static bool
172
get_domContentLoadedEventEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
173
0
{
174
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.domContentLoadedEventEnd", DOM, cx);
175
0
176
0
  double result(self->DomContentLoadedEventEnd());
177
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
178
0
  args.rval().set(JS_NumberValue(double(result)));
179
0
  return true;
180
0
}
181
182
static const JSJitInfo domContentLoadedEventEnd_getterinfo = {
183
  { (JSJitGetterOp)get_domContentLoadedEventEnd },
184
  { prototypes::id::PerformanceNavigationTiming },
185
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
186
  JSJitInfo::Getter,
187
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
188
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
189
  true,  /* isInfallible. False in setters. */
190
  false,  /* isMovable.  Not relevant for setters. */
191
  false, /* isEliminatable.  Not relevant for setters. */
192
  false, /* isAlwaysInSlot.  Only relevant for getters. */
193
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
194
  false,  /* isTypedMethod.  Only relevant for methods. */
195
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
196
};
197
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
198
static_assert(0 < 2, "There is no slot for us");
199
200
MOZ_CAN_RUN_SCRIPT static bool
201
get_domComplete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
202
0
{
203
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.domComplete", DOM, cx);
204
0
205
0
  double result(self->DomComplete());
206
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
207
0
  args.rval().set(JS_NumberValue(double(result)));
208
0
  return true;
209
0
}
210
211
static const JSJitInfo domComplete_getterinfo = {
212
  { (JSJitGetterOp)get_domComplete },
213
  { prototypes::id::PerformanceNavigationTiming },
214
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
215
  JSJitInfo::Getter,
216
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
217
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
218
  true,  /* isInfallible. False in setters. */
219
  false,  /* isMovable.  Not relevant for setters. */
220
  false, /* isEliminatable.  Not relevant for setters. */
221
  false, /* isAlwaysInSlot.  Only relevant for getters. */
222
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
223
  false,  /* isTypedMethod.  Only relevant for methods. */
224
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
225
};
226
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
227
static_assert(0 < 2, "There is no slot for us");
228
229
MOZ_CAN_RUN_SCRIPT static bool
230
get_loadEventStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
231
0
{
232
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.loadEventStart", DOM, cx);
233
0
234
0
  double result(self->LoadEventStart());
235
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
236
0
  args.rval().set(JS_NumberValue(double(result)));
237
0
  return true;
238
0
}
239
240
static const JSJitInfo loadEventStart_getterinfo = {
241
  { (JSJitGetterOp)get_loadEventStart },
242
  { prototypes::id::PerformanceNavigationTiming },
243
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
244
  JSJitInfo::Getter,
245
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
246
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
247
  true,  /* isInfallible. False in setters. */
248
  false,  /* isMovable.  Not relevant for setters. */
249
  false, /* isEliminatable.  Not relevant for setters. */
250
  false, /* isAlwaysInSlot.  Only relevant for getters. */
251
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
252
  false,  /* isTypedMethod.  Only relevant for methods. */
253
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
254
};
255
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
256
static_assert(0 < 2, "There is no slot for us");
257
258
MOZ_CAN_RUN_SCRIPT static bool
259
get_loadEventEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
260
0
{
261
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.loadEventEnd", DOM, cx);
262
0
263
0
  double result(self->LoadEventEnd());
264
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
265
0
  args.rval().set(JS_NumberValue(double(result)));
266
0
  return true;
267
0
}
268
269
static const JSJitInfo loadEventEnd_getterinfo = {
270
  { (JSJitGetterOp)get_loadEventEnd },
271
  { prototypes::id::PerformanceNavigationTiming },
272
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
273
  JSJitInfo::Getter,
274
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
275
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
276
  true,  /* isInfallible. False in setters. */
277
  false,  /* isMovable.  Not relevant for setters. */
278
  false, /* isEliminatable.  Not relevant for setters. */
279
  false, /* isAlwaysInSlot.  Only relevant for getters. */
280
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
281
  false,  /* isTypedMethod.  Only relevant for methods. */
282
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
283
};
284
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
285
static_assert(0 < 2, "There is no slot for us");
286
287
MOZ_CAN_RUN_SCRIPT static bool
288
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
289
0
{
290
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.type", DOM, cx);
291
0
292
0
  NavigationType result(self->Type());
293
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
294
0
  if (!ToJSValue(cx, result, args.rval())) {
295
0
    return false;
296
0
  }
297
0
  return true;
298
0
}
299
300
static const JSJitInfo type_getterinfo = {
301
  { (JSJitGetterOp)get_type },
302
  { prototypes::id::PerformanceNavigationTiming },
303
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
304
  JSJitInfo::Getter,
305
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
306
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
307
  false,  /* isInfallible. False in setters. */
308
  false,  /* isMovable.  Not relevant for setters. */
309
  false, /* isEliminatable.  Not relevant for setters. */
310
  false, /* isAlwaysInSlot.  Only relevant for getters. */
311
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
312
  false,  /* isTypedMethod.  Only relevant for methods. */
313
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
314
};
315
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
316
static_assert(0 < 2, "There is no slot for us");
317
318
MOZ_CAN_RUN_SCRIPT static bool
319
get_redirectCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JSJitGetterCallArgs args)
320
0
{
321
0
  AUTO_PROFILER_LABEL_FAST("get PerformanceNavigationTiming.redirectCount", DOM, cx);
322
0
323
0
  uint16_t result(self->RedirectCount());
324
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
325
0
  args.rval().setInt32(int32_t(result));
326
0
  return true;
327
0
}
328
329
static const JSJitInfo redirectCount_getterinfo = {
330
  { (JSJitGetterOp)get_redirectCount },
331
  { prototypes::id::PerformanceNavigationTiming },
332
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
333
  JSJitInfo::Getter,
334
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
335
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
336
  true,  /* isInfallible. False in setters. */
337
  false,  /* isMovable.  Not relevant for setters. */
338
  false, /* isEliminatable.  Not relevant for setters. */
339
  false, /* isAlwaysInSlot.  Only relevant for getters. */
340
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
341
  false,  /* isTypedMethod.  Only relevant for methods. */
342
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
343
};
344
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
345
static_assert(0 < 2, "There is no slot for us");
346
347
MOZ_CAN_RUN_SCRIPT static bool
348
toJSON(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, const JSJitMethodCallArgs& args)
349
0
{
350
0
  AUTO_PROFILER_LABEL_FAST("PerformanceNavigationTiming.toJSON", DOM, cx);
351
0
352
0
  JS::Rooted<JSObject*> result(cx, JS_NewPlainObject(cx));
353
0
  if (!result) {
354
0
    return false;
355
0
  }
356
0
  if (!PerformanceEntry_Binding::CollectJSONAttributes(cx, obj, self, result)) {
357
0
    return false;
358
0
  }
359
0
  if (!PerformanceResourceTiming_Binding::CollectJSONAttributes(cx, obj, self, result)) {
360
0
    return false;
361
0
  }
362
0
  if (!PerformanceNavigationTiming_Binding::CollectJSONAttributes(cx, obj, self, result)) {
363
0
    return false;
364
0
  }
365
0
  args.rval().setObject(*result);
366
0
  return true;
367
0
}
368
369
static const JSJitInfo toJSON_methodinfo = {
370
  { (JSJitGetterOp)toJSON },
371
  { prototypes::id::PerformanceNavigationTiming },
372
  { PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth },
373
  JSJitInfo::Method,
374
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
375
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
376
  false,  /* isInfallible. False in setters. */
377
  false,  /* isMovable.  Not relevant for setters. */
378
  false, /* isEliminatable.  Not relevant for setters. */
379
  false, /* isAlwaysInSlot.  Only relevant for getters. */
380
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
381
  false,  /* isTypedMethod.  Only relevant for methods. */
382
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
383
};
384
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
385
static_assert(0 < 2, "There is no slot for us");
386
387
static bool
388
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
389
0
{
390
0
  mozilla::dom::PerformanceNavigationTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceNavigationTiming>(obj);
391
0
  // We don't want to preserve if we don't have a wrapper, and we
392
0
  // obviously can't preserve if we're not initialized.
393
0
  if (self && self->GetWrapperPreserveColor()) {
394
0
    PreserveWrapper(self);
395
0
  }
396
0
  return true;
397
0
}
398
399
static void
400
_finalize(js::FreeOp* fop, JSObject* obj)
401
0
{
402
0
  mozilla::dom::PerformanceNavigationTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceNavigationTiming>(obj);
403
0
  if (self) {
404
0
    ClearWrapper(self, self, obj);
405
0
    AddForDeferredFinalization<mozilla::dom::PerformanceNavigationTiming>(self);
406
0
  }
407
0
}
408
409
static size_t
410
_objectMoved(JSObject* obj, JSObject* old)
411
0
{
412
0
  mozilla::dom::PerformanceNavigationTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PerformanceNavigationTiming>(obj);
413
0
  if (self) {
414
0
    UpdateWrapper(self, self, obj, old);
415
0
  }
416
0
417
0
  return 0;
418
0
}
419
420
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
421
#if defined(__clang__)
422
#pragma clang diagnostic push
423
#pragma clang diagnostic ignored "-Wmissing-braces"
424
#endif
425
static const JSFunctionSpec sMethods_specs[] = {
426
  JS_FNSPEC("toJSON", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&toJSON_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
427
  JS_FS_END
428
};
429
#if defined(__clang__)
430
#pragma clang diagnostic pop
431
#endif
432
433
434
static const Prefable<const JSFunctionSpec> sMethods[] = {
435
  { nullptr, &sMethods_specs[0] },
436
  { nullptr, nullptr }
437
};
438
439
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
440
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
441
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
442
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
443
444
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
445
#if defined(__clang__)
446
#pragma clang diagnostic push
447
#pragma clang diagnostic ignored "-Wmissing-braces"
448
#endif
449
static const JSPropertySpec sAttributes_specs[] = {
450
  { "unloadEventStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &unloadEventStart_getterinfo, nullptr, nullptr },
451
  { "unloadEventEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &unloadEventEnd_getterinfo, nullptr, nullptr },
452
  { "domInteractive", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &domInteractive_getterinfo, nullptr, nullptr },
453
  { "domContentLoadedEventStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &domContentLoadedEventStart_getterinfo, nullptr, nullptr },
454
  { "domContentLoadedEventEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &domContentLoadedEventEnd_getterinfo, nullptr, nullptr },
455
  { "domComplete", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &domComplete_getterinfo, nullptr, nullptr },
456
  { "loadEventStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &loadEventStart_getterinfo, nullptr, nullptr },
457
  { "loadEventEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &loadEventEnd_getterinfo, nullptr, nullptr },
458
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr },
459
  { "redirectCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &redirectCount_getterinfo, nullptr, nullptr },
460
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
461
};
462
#if defined(__clang__)
463
#pragma clang diagnostic pop
464
#endif
465
466
467
static const Prefable<const JSPropertySpec> sAttributes[] = {
468
  { nullptr, &sAttributes_specs[0] },
469
  { nullptr, nullptr }
470
};
471
472
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
473
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
474
static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
475
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
476
477
478
static uint16_t sNativeProperties_sortedPropertyIndices[11];
479
static PropertyInfo sNativeProperties_propertyInfos[11];
480
481
static const NativePropertiesN<2> sNativeProperties = {
482
  false, 0,
483
  false, 0,
484
  true,  0 /* sMethods */,
485
  true,  1 /* sAttributes */,
486
  false, 0,
487
  false, 0,
488
  false, 0,
489
  -1,
490
  11,
491
  sNativeProperties_sortedPropertyIndices,
492
  {
493
    { sMethods, &sNativeProperties_propertyInfos[0] },
494
    { sAttributes, &sNativeProperties_propertyInfos[1] }
495
  }
496
};
497
static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
498
    "We have a property info count that is oversized");
499
500
MOZ_CAN_RUN_SCRIPT bool
501
CollectJSONAttributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PerformanceNavigationTiming* self, JS::Rooted<JSObject*>& result)
502
0
{
503
0
  { // scope for "temp"
504
0
    JS::Rooted<JS::Value> temp(cx);
505
0
    if (!get_unloadEventStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
506
0
      return false;
507
0
    }
508
0
    if (!JS_DefineProperty(cx, result, "unloadEventStart", temp, JSPROP_ENUMERATE)) {
509
0
      return false;
510
0
    }
511
0
  }
512
0
  { // scope for "temp"
513
0
    JS::Rooted<JS::Value> temp(cx);
514
0
    if (!get_unloadEventEnd(cx, obj, self, JSJitGetterCallArgs(&temp))) {
515
0
      return false;
516
0
    }
517
0
    if (!JS_DefineProperty(cx, result, "unloadEventEnd", temp, JSPROP_ENUMERATE)) {
518
0
      return false;
519
0
    }
520
0
  }
521
0
  { // scope for "temp"
522
0
    JS::Rooted<JS::Value> temp(cx);
523
0
    if (!get_domInteractive(cx, obj, self, JSJitGetterCallArgs(&temp))) {
524
0
      return false;
525
0
    }
526
0
    if (!JS_DefineProperty(cx, result, "domInteractive", temp, JSPROP_ENUMERATE)) {
527
0
      return false;
528
0
    }
529
0
  }
530
0
  { // scope for "temp"
531
0
    JS::Rooted<JS::Value> temp(cx);
532
0
    if (!get_domContentLoadedEventStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
533
0
      return false;
534
0
    }
535
0
    if (!JS_DefineProperty(cx, result, "domContentLoadedEventStart", temp, JSPROP_ENUMERATE)) {
536
0
      return false;
537
0
    }
538
0
  }
539
0
  { // scope for "temp"
540
0
    JS::Rooted<JS::Value> temp(cx);
541
0
    if (!get_domContentLoadedEventEnd(cx, obj, self, JSJitGetterCallArgs(&temp))) {
542
0
      return false;
543
0
    }
544
0
    if (!JS_DefineProperty(cx, result, "domContentLoadedEventEnd", temp, JSPROP_ENUMERATE)) {
545
0
      return false;
546
0
    }
547
0
  }
548
0
  { // scope for "temp"
549
0
    JS::Rooted<JS::Value> temp(cx);
550
0
    if (!get_domComplete(cx, obj, self, JSJitGetterCallArgs(&temp))) {
551
0
      return false;
552
0
    }
553
0
    if (!JS_DefineProperty(cx, result, "domComplete", temp, JSPROP_ENUMERATE)) {
554
0
      return false;
555
0
    }
556
0
  }
557
0
  { // scope for "temp"
558
0
    JS::Rooted<JS::Value> temp(cx);
559
0
    if (!get_loadEventStart(cx, obj, self, JSJitGetterCallArgs(&temp))) {
560
0
      return false;
561
0
    }
562
0
    if (!JS_DefineProperty(cx, result, "loadEventStart", temp, JSPROP_ENUMERATE)) {
563
0
      return false;
564
0
    }
565
0
  }
566
0
  { // scope for "temp"
567
0
    JS::Rooted<JS::Value> temp(cx);
568
0
    if (!get_loadEventEnd(cx, obj, self, JSJitGetterCallArgs(&temp))) {
569
0
      return false;
570
0
    }
571
0
    if (!JS_DefineProperty(cx, result, "loadEventEnd", temp, JSPROP_ENUMERATE)) {
572
0
      return false;
573
0
    }
574
0
  }
575
0
  { // scope for "temp"
576
0
    JS::Rooted<JS::Value> temp(cx);
577
0
    if (!get_type(cx, obj, self, JSJitGetterCallArgs(&temp))) {
578
0
      return false;
579
0
    }
580
0
    if (!JS_DefineProperty(cx, result, "type", temp, JSPROP_ENUMERATE)) {
581
0
      return false;
582
0
    }
583
0
  }
584
0
  { // scope for "temp"
585
0
    JS::Rooted<JS::Value> temp(cx);
586
0
    if (!get_redirectCount(cx, obj, self, JSJitGetterCallArgs(&temp))) {
587
0
      return false;
588
0
    }
589
0
    if (!JS_DefineProperty(cx, result, "redirectCount", temp, JSPROP_ENUMERATE)) {
590
0
      return false;
591
0
    }
592
0
  }
593
0
  return true;
594
0
}
595
596
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
597
  {
598
    "Function",
599
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
600
    &sBoringInterfaceObjectClassClassOps,
601
    JS_NULL_CLASS_SPEC,
602
    JS_NULL_CLASS_EXT,
603
    &sInterfaceObjectClassObjectOps
604
  },
605
  eInterface,
606
  true,
607
  prototypes::id::PerformanceNavigationTiming,
608
  PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth,
609
  sNativePropertyHooks,
610
  "function PerformanceNavigationTiming() {\n    [native code]\n}",
611
  PerformanceResourceTiming_Binding::GetConstructorObject
612
};
613
614
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
615
  {
616
    "PerformanceNavigationTimingPrototype",
617
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
618
    JS_NULL_CLASS_OPS,
619
    JS_NULL_CLASS_SPEC,
620
    JS_NULL_CLASS_EXT,
621
    JS_NULL_OBJECT_OPS
622
  },
623
  eInterfacePrototype,
624
  false,
625
  prototypes::id::PerformanceNavigationTiming,
626
  PrototypeTraits<prototypes::id::PerformanceNavigationTiming>::Depth,
627
  sNativePropertyHooks,
628
  "[object PerformanceNavigationTimingPrototype]",
629
  PerformanceResourceTiming_Binding::GetProtoObject
630
};
631
632
static const js::ClassOps sClassOps = {
633
  _addProperty, /* addProperty */
634
  nullptr,               /* delProperty */
635
  nullptr,               /* enumerate */
636
  nullptr, /* newEnumerate */
637
  nullptr, /* resolve */
638
  nullptr, /* mayResolve */
639
  _finalize, /* finalize */
640
  nullptr, /* call */
641
  nullptr,               /* hasInstance */
642
  nullptr,               /* construct */
643
  nullptr, /* trace */
644
};
645
646
static const js::ClassExtension sClassExtension = {
647
  nullptr, /* weakmapKeyDelegateOp */
648
  _objectMoved /* objectMovedOp */
649
};
650
651
static const DOMJSClass sClass = {
652
  { "PerformanceNavigationTiming",
653
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
654
    &sClassOps,
655
    JS_NULL_CLASS_SPEC,
656
    &sClassExtension,
657
    JS_NULL_OBJECT_OPS
658
  },
659
  { prototypes::id::PerformanceEntry, prototypes::id::PerformanceResourceTiming, prototypes::id::PerformanceNavigationTiming, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
660
  IsBaseOf<nsISupports, mozilla::dom::PerformanceNavigationTiming >::value,
661
  sNativePropertyHooks,
662
  FindAssociatedGlobalForNative<mozilla::dom::PerformanceNavigationTiming>::Get,
663
  GetProtoObjectHandle,
664
  GetCCParticipant<mozilla::dom::PerformanceNavigationTiming>::Get()
665
};
666
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
667
              "Must have the right minimal number of reserved slots.");
668
static_assert(2 >= 2,
669
              "Must have enough reserved slots.");
670
671
const JSClass*
672
GetJSClass()
673
0
{
674
0
  return sClass.ToJSClass();
675
0
}
676
677
bool
678
Wrap(JSContext* aCx, mozilla::dom::PerformanceNavigationTiming* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
679
0
{
680
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::PerformanceNavigationTiming>::value,
681
0
                "Shouldn't have wrappercached things that are not refcounted.");
682
0
  MOZ_ASSERT(static_cast<mozilla::dom::PerformanceNavigationTiming*>(aObject) ==
683
0
             reinterpret_cast<mozilla::dom::PerformanceNavigationTiming*>(aObject),
684
0
             "Multiple inheritance for mozilla::dom::PerformanceNavigationTiming is broken.");
685
0
  MOZ_ASSERT(static_cast<mozilla::dom::PerformanceResourceTiming*>(aObject) ==
686
0
             reinterpret_cast<mozilla::dom::PerformanceResourceTiming*>(aObject),
687
0
             "Multiple inheritance for mozilla::dom::PerformanceResourceTiming is broken.");
688
0
  MOZ_ASSERT(static_cast<mozilla::dom::PerformanceEntry*>(aObject) ==
689
0
             reinterpret_cast<mozilla::dom::PerformanceEntry*>(aObject),
690
0
             "Multiple inheritance for mozilla::dom::PerformanceEntry is broken.");
691
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
692
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
693
0
  MOZ_ASSERT(!aCache->GetWrapper(),
694
0
             "You should probably not be using Wrap() directly; use "
695
0
             "GetOrCreateDOMReflector instead");
696
0
697
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
698
0
             "nsISupports must be on our primary inheritance chain");
699
0
700
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
701
0
  if (!global) {
702
0
    return false;
703
0
  }
704
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
705
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
706
0
707
0
  // That might have ended up wrapping us already, due to the wonders
708
0
  // of XBL.  Check for that, and bail out as needed.
709
0
  aReflector.set(aCache->GetWrapper());
710
0
  if (aReflector) {
711
#ifdef DEBUG
712
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
713
#endif // DEBUG
714
    return true;
715
0
  }
716
0
717
0
  JSAutoRealm ar(aCx, global);
718
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
719
0
  if (!canonicalProto) {
720
0
    return false;
721
0
  }
722
0
  JS::Rooted<JSObject*> proto(aCx);
723
0
  if (aGivenProto) {
724
0
    proto = aGivenProto;
725
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
726
0
    // coming in, we changed compartments to that of "parent" so may need
727
0
    // to wrap the proto here.
728
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
729
0
      if (!JS_WrapObject(aCx, &proto)) {
730
0
        return false;
731
0
      }
732
0
    }
733
0
  } else {
734
0
    proto = canonicalProto;
735
0
  }
736
0
737
0
  BindingJSObjectCreator<mozilla::dom::PerformanceNavigationTiming> creator(aCx);
738
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
739
0
  if (!aReflector) {
740
0
    return false;
741
0
  }
742
0
743
0
  aCache->SetWrapper(aReflector);
744
0
  creator.InitializationSucceeded();
745
0
746
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
747
0
             aCache->GetWrapperPreserveColor() == aReflector);
748
0
  // If proto != canonicalProto, we have to preserve our wrapper;
749
0
  // otherwise we won't be able to properly recreate it later, since
750
0
  // we won't know what proto to use.  Note that we don't check
751
0
  // aGivenProto here, since it's entirely possible (and even
752
0
  // somewhat common) to have a non-null aGivenProto which is the
753
0
  // same as canonicalProto.
754
0
  if (proto != canonicalProto) {
755
0
    PreserveWrapper(aObject);
756
0
  }
757
0
758
0
  return true;
759
0
}
760
761
// This may allocate too many slots, because we only really need
762
// slots for our non-interface-typed members that we cache.  But
763
// allocating slots only for those would make the slot index
764
// computations much more complicated, so let's do this the simple
765
// way for now.
766
DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
767
768
const NativePropertyHooks sNativePropertyHooks[] = { {
769
  nullptr,
770
  nullptr,
771
  nullptr,
772
  { sNativeProperties.Upcast(), nullptr },
773
  prototypes::id::PerformanceNavigationTiming,
774
  constructors::id::PerformanceNavigationTiming,
775
  PerformanceResourceTiming_Binding::sNativePropertyHooks,
776
  &sXrayExpandoObjectClass
777
} };
778
779
void
780
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
781
0
{
782
0
  JS::Handle<JSObject*> parentProto(PerformanceResourceTiming_Binding::GetProtoObjectHandle(aCx));
783
0
  if (!parentProto) {
784
0
    return;
785
0
  }
786
0
787
0
  JS::Handle<JSObject*> constructorProto(PerformanceResourceTiming_Binding::GetConstructorObjectHandle(aCx));
788
0
  if (!constructorProto) {
789
0
    return;
790
0
  }
791
0
792
0
  static bool sIdsInited = false;
793
0
  if (!sIdsInited && NS_IsMainThread()) {
794
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
795
0
      return;
796
0
    }
797
0
    sIdsInited = true;
798
0
  }
799
0
800
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PerformanceNavigationTiming);
801
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PerformanceNavigationTiming);
802
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
803
0
                              &sPrototypeClass.mBase, protoCache,
804
0
                              nullptr,
805
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
806
0
                              interfaceCache,
807
0
                              sNativeProperties.Upcast(),
808
0
                              nullptr,
809
0
                              "PerformanceNavigationTiming", aDefineOnGlobal,
810
0
                              nullptr,
811
0
                              false);
812
0
}
813
814
JSObject*
815
GetConstructorObject(JSContext* aCx)
816
0
{
817
0
  return GetConstructorObjectHandle(aCx);
818
0
}
819
820
} // namespace PerformanceNavigationTiming_Binding
821
822
823
824
} // namespace dom
825
} // namespace mozilla