Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/WorkerLocationBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM WorkerLocation.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "WorkerLocationBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/DOMJSClass.h"
8
#include "mozilla/dom/NonRefcountedDOMObject.h"
9
#include "mozilla/dom/WorkerLocation.h"
10
11
namespace mozilla {
12
namespace dom {
13
14
namespace binding_detail {}; // Just to make sure it's known as a namespace
15
using namespace mozilla::dom::binding_detail;
16
17
18
namespace WorkerLocation_Binding {
19
20
MOZ_CAN_RUN_SCRIPT static bool
21
__stringifier(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, const JSJitMethodCallArgs& args)
22
0
{
23
0
  AUTO_PROFILER_LABEL_FAST("WorkerLocation.__stringifier", DOM, cx);
24
0
25
0
  DOMString result;
26
0
  self->Stringify(result);
27
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
28
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
29
0
    return false;
30
0
  }
31
0
  return true;
32
0
}
33
34
static const JSJitInfo __stringifier_methodinfo = {
35
  { (JSJitGetterOp)__stringifier },
36
  { prototypes::id::WorkerLocation },
37
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
38
  JSJitInfo::Method,
39
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
40
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
41
  false,  /* isInfallible. False in setters. */
42
  false,  /* isMovable.  Not relevant for setters. */
43
  false, /* isEliminatable.  Not relevant for setters. */
44
  false, /* isAlwaysInSlot.  Only relevant for getters. */
45
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
46
  false,  /* isTypedMethod.  Only relevant for methods. */
47
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
48
};
49
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
50
static_assert(0 < 1, "There is no slot for us");
51
52
MOZ_CAN_RUN_SCRIPT static bool
53
get_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
54
0
{
55
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.href", DOM, cx);
56
0
57
0
  DOMString result;
58
0
  self->GetHref(result);
59
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
60
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
61
0
    return false;
62
0
  }
63
0
  return true;
64
0
}
65
66
static const JSJitInfo href_getterinfo = {
67
  { (JSJitGetterOp)get_href },
68
  { prototypes::id::WorkerLocation },
69
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
70
  JSJitInfo::Getter,
71
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
72
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
73
  false,  /* 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 < 1, "There is no slot for us");
83
84
MOZ_CAN_RUN_SCRIPT static bool
85
get_origin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
86
0
{
87
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.origin", DOM, cx);
88
0
89
0
  DOMString result;
90
0
  self->GetOrigin(result);
91
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
92
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
93
0
    return false;
94
0
  }
95
0
  return true;
96
0
}
97
98
static const JSJitInfo origin_getterinfo = {
99
  { (JSJitGetterOp)get_origin },
100
  { prototypes::id::WorkerLocation },
101
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
102
  JSJitInfo::Getter,
103
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
104
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
105
  false,  /* isInfallible. False in setters. */
106
  false,  /* isMovable.  Not relevant for setters. */
107
  false, /* isEliminatable.  Not relevant for setters. */
108
  false, /* isAlwaysInSlot.  Only relevant for getters. */
109
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
110
  false,  /* isTypedMethod.  Only relevant for methods. */
111
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
112
};
113
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
114
static_assert(0 < 1, "There is no slot for us");
115
116
MOZ_CAN_RUN_SCRIPT static bool
117
get_protocol(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
118
0
{
119
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.protocol", DOM, cx);
120
0
121
0
  DOMString result;
122
0
  self->GetProtocol(result);
123
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
124
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
125
0
    return false;
126
0
  }
127
0
  return true;
128
0
}
129
130
static const JSJitInfo protocol_getterinfo = {
131
  { (JSJitGetterOp)get_protocol },
132
  { prototypes::id::WorkerLocation },
133
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
134
  JSJitInfo::Getter,
135
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
136
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
137
  false,  /* isInfallible. False in setters. */
138
  false,  /* isMovable.  Not relevant for setters. */
139
  false, /* isEliminatable.  Not relevant for setters. */
140
  false, /* isAlwaysInSlot.  Only relevant for getters. */
141
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
142
  false,  /* isTypedMethod.  Only relevant for methods. */
143
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
144
};
145
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
146
static_assert(0 < 1, "There is no slot for us");
147
148
MOZ_CAN_RUN_SCRIPT static bool
149
get_host(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
150
0
{
151
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.host", DOM, cx);
152
0
153
0
  DOMString result;
154
0
  self->GetHost(result);
155
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
156
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
157
0
    return false;
158
0
  }
159
0
  return true;
160
0
}
161
162
static const JSJitInfo host_getterinfo = {
163
  { (JSJitGetterOp)get_host },
164
  { prototypes::id::WorkerLocation },
165
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
166
  JSJitInfo::Getter,
167
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
168
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
169
  false,  /* isInfallible. False in setters. */
170
  false,  /* isMovable.  Not relevant for setters. */
171
  false, /* isEliminatable.  Not relevant for setters. */
172
  false, /* isAlwaysInSlot.  Only relevant for getters. */
173
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
174
  false,  /* isTypedMethod.  Only relevant for methods. */
175
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
176
};
177
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
178
static_assert(0 < 1, "There is no slot for us");
179
180
MOZ_CAN_RUN_SCRIPT static bool
181
get_hostname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
182
0
{
183
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.hostname", DOM, cx);
184
0
185
0
  DOMString result;
186
0
  self->GetHostname(result);
187
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
188
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
189
0
    return false;
190
0
  }
191
0
  return true;
192
0
}
193
194
static const JSJitInfo hostname_getterinfo = {
195
  { (JSJitGetterOp)get_hostname },
196
  { prototypes::id::WorkerLocation },
197
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
198
  JSJitInfo::Getter,
199
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
200
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
201
  false,  /* isInfallible. False in setters. */
202
  false,  /* isMovable.  Not relevant for setters. */
203
  false, /* isEliminatable.  Not relevant for setters. */
204
  false, /* isAlwaysInSlot.  Only relevant for getters. */
205
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
206
  false,  /* isTypedMethod.  Only relevant for methods. */
207
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
208
};
209
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
210
static_assert(0 < 1, "There is no slot for us");
211
212
MOZ_CAN_RUN_SCRIPT static bool
213
get_port(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
214
0
{
215
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.port", DOM, cx);
216
0
217
0
  DOMString result;
218
0
  self->GetPort(result);
219
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
220
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
221
0
    return false;
222
0
  }
223
0
  return true;
224
0
}
225
226
static const JSJitInfo port_getterinfo = {
227
  { (JSJitGetterOp)get_port },
228
  { prototypes::id::WorkerLocation },
229
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
230
  JSJitInfo::Getter,
231
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
232
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
233
  false,  /* isInfallible. False in setters. */
234
  false,  /* isMovable.  Not relevant for setters. */
235
  false, /* isEliminatable.  Not relevant for setters. */
236
  false, /* isAlwaysInSlot.  Only relevant for getters. */
237
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
238
  false,  /* isTypedMethod.  Only relevant for methods. */
239
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
240
};
241
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
242
static_assert(0 < 1, "There is no slot for us");
243
244
MOZ_CAN_RUN_SCRIPT static bool
245
get_pathname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
246
0
{
247
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.pathname", DOM, cx);
248
0
249
0
  DOMString result;
250
0
  self->GetPathname(result);
251
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
252
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
253
0
    return false;
254
0
  }
255
0
  return true;
256
0
}
257
258
static const JSJitInfo pathname_getterinfo = {
259
  { (JSJitGetterOp)get_pathname },
260
  { prototypes::id::WorkerLocation },
261
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
262
  JSJitInfo::Getter,
263
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
264
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
265
  false,  /* isInfallible. False in setters. */
266
  false,  /* isMovable.  Not relevant for setters. */
267
  false, /* isEliminatable.  Not relevant for setters. */
268
  false, /* isAlwaysInSlot.  Only relevant for getters. */
269
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
270
  false,  /* isTypedMethod.  Only relevant for methods. */
271
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
272
};
273
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
274
static_assert(0 < 1, "There is no slot for us");
275
276
MOZ_CAN_RUN_SCRIPT static bool
277
get_search(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
278
0
{
279
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.search", DOM, cx);
280
0
281
0
  DOMString result;
282
0
  self->GetSearch(result);
283
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
284
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
285
0
    return false;
286
0
  }
287
0
  return true;
288
0
}
289
290
static const JSJitInfo search_getterinfo = {
291
  { (JSJitGetterOp)get_search },
292
  { prototypes::id::WorkerLocation },
293
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
294
  JSJitInfo::Getter,
295
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
296
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
297
  false,  /* isInfallible. False in setters. */
298
  false,  /* isMovable.  Not relevant for setters. */
299
  false, /* isEliminatable.  Not relevant for setters. */
300
  false, /* isAlwaysInSlot.  Only relevant for getters. */
301
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
302
  false,  /* isTypedMethod.  Only relevant for methods. */
303
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
304
};
305
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
306
static_assert(0 < 1, "There is no slot for us");
307
308
MOZ_CAN_RUN_SCRIPT static bool
309
get_hash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerLocation* self, JSJitGetterCallArgs args)
310
0
{
311
0
  AUTO_PROFILER_LABEL_FAST("get WorkerLocation.hash", DOM, cx);
312
0
313
0
  DOMString result;
314
0
  self->GetHash(result);
315
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
316
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
317
0
    return false;
318
0
  }
319
0
  return true;
320
0
}
321
322
static const JSJitInfo hash_getterinfo = {
323
  { (JSJitGetterOp)get_hash },
324
  { prototypes::id::WorkerLocation },
325
  { PrototypeTraits<prototypes::id::WorkerLocation>::Depth },
326
  JSJitInfo::Getter,
327
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
328
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
329
  false,  /* isInfallible. False in setters. */
330
  false,  /* isMovable.  Not relevant for setters. */
331
  false, /* isEliminatable.  Not relevant for setters. */
332
  false, /* isAlwaysInSlot.  Only relevant for getters. */
333
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
334
  false,  /* isTypedMethod.  Only relevant for methods. */
335
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
336
};
337
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
338
static_assert(0 < 1, "There is no slot for us");
339
340
static bool
341
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
342
0
{
343
0
  mozilla::dom::WorkerLocation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerLocation>(obj);
344
0
  // We don't want to preserve if we don't have a wrapper, and we
345
0
  // obviously can't preserve if we're not initialized.
346
0
  if (self && self->GetWrapperPreserveColor()) {
347
0
    PreserveWrapper(self);
348
0
  }
349
0
  return true;
350
0
}
351
352
static void
353
_finalize(js::FreeOp* fop, JSObject* obj)
354
0
{
355
0
  mozilla::dom::WorkerLocation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerLocation>(obj);
356
0
  if (self) {
357
0
    ClearWrapper(self, self, obj);
358
0
    AddForDeferredFinalization<mozilla::dom::WorkerLocation>(self);
359
0
  }
360
0
}
361
362
static size_t
363
_objectMoved(JSObject* obj, JSObject* old)
364
0
{
365
0
  mozilla::dom::WorkerLocation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerLocation>(obj);
366
0
  if (self) {
367
0
    UpdateWrapper(self, self, obj, old);
368
0
  }
369
0
370
0
  return 0;
371
0
}
372
373
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
374
#if defined(__clang__)
375
#pragma clang diagnostic push
376
#pragma clang diagnostic ignored "-Wmissing-braces"
377
#endif
378
static const JSFunctionSpec sMethods_specs[] = {
379
  JS_FNSPEC("toString", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&__stringifier_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
380
  JS_FS_END
381
};
382
#if defined(__clang__)
383
#pragma clang diagnostic pop
384
#endif
385
386
387
static const Prefable<const JSFunctionSpec> sMethods[] = {
388
  { nullptr, &sMethods_specs[0] },
389
  { nullptr, nullptr }
390
};
391
392
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
393
#if defined(__clang__)
394
#pragma clang diagnostic push
395
#pragma clang diagnostic ignored "-Wmissing-braces"
396
#endif
397
static const JSPropertySpec sAttributes_specs[] = {
398
  { "href", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &href_getterinfo, nullptr, nullptr },
399
  { "origin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &origin_getterinfo, nullptr, nullptr },
400
  { "protocol", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &protocol_getterinfo, nullptr, nullptr },
401
  { "host", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &host_getterinfo, nullptr, nullptr },
402
  { "hostname", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hostname_getterinfo, nullptr, nullptr },
403
  { "port", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &port_getterinfo, nullptr, nullptr },
404
  { "pathname", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pathname_getterinfo, nullptr, nullptr },
405
  { "search", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &search_getterinfo, nullptr, nullptr },
406
  { "hash", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hash_getterinfo, nullptr, nullptr },
407
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
408
};
409
#if defined(__clang__)
410
#pragma clang diagnostic pop
411
#endif
412
413
414
static const Prefable<const JSPropertySpec> sAttributes[] = {
415
  { nullptr, &sAttributes_specs[0] },
416
  { nullptr, nullptr }
417
};
418
419
420
static const NativePropertiesN<2> sNativeProperties = {
421
  false, 0,
422
  false, 0,
423
  true,  0 /* sMethods */,
424
  true,  1 /* sAttributes */,
425
  false, 0,
426
  false, 0,
427
  false, 0,
428
  -1,
429
  0,
430
  nullptr,
431
  {
432
    { sMethods, nullptr },
433
    { sAttributes, nullptr }
434
  }
435
};
436
437
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
438
  {
439
    "Function",
440
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
441
    &sBoringInterfaceObjectClassClassOps,
442
    JS_NULL_CLASS_SPEC,
443
    JS_NULL_CLASS_EXT,
444
    &sInterfaceObjectClassObjectOps
445
  },
446
  eInterface,
447
  true,
448
  prototypes::id::WorkerLocation,
449
  PrototypeTraits<prototypes::id::WorkerLocation>::Depth,
450
  &sEmptyNativePropertyHooks,
451
  "function WorkerLocation() {\n    [native code]\n}",
452
  JS::GetRealmFunctionPrototype
453
};
454
455
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
456
  {
457
    "WorkerLocationPrototype",
458
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
459
    JS_NULL_CLASS_OPS,
460
    JS_NULL_CLASS_SPEC,
461
    JS_NULL_CLASS_EXT,
462
    JS_NULL_OBJECT_OPS
463
  },
464
  eInterfacePrototype,
465
  false,
466
  prototypes::id::WorkerLocation,
467
  PrototypeTraits<prototypes::id::WorkerLocation>::Depth,
468
  &sEmptyNativePropertyHooks,
469
  "[object WorkerLocationPrototype]",
470
  JS::GetRealmObjectPrototype
471
};
472
473
static const js::ClassOps sClassOps = {
474
  _addProperty, /* addProperty */
475
  nullptr,               /* delProperty */
476
  nullptr,               /* enumerate */
477
  nullptr, /* newEnumerate */
478
  nullptr, /* resolve */
479
  nullptr, /* mayResolve */
480
  _finalize, /* finalize */
481
  nullptr, /* call */
482
  nullptr,               /* hasInstance */
483
  nullptr,               /* construct */
484
  nullptr, /* trace */
485
};
486
487
static const js::ClassExtension sClassExtension = {
488
  nullptr, /* weakmapKeyDelegateOp */
489
  _objectMoved /* objectMovedOp */
490
};
491
492
static const DOMJSClass sClass = {
493
  { "WorkerLocation",
494
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
495
    &sClassOps,
496
    JS_NULL_CLASS_SPEC,
497
    &sClassExtension,
498
    JS_NULL_OBJECT_OPS
499
  },
500
  { prototypes::id::WorkerLocation, 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 },
501
  IsBaseOf<nsISupports, mozilla::dom::WorkerLocation >::value,
502
  &sEmptyNativePropertyHooks,
503
  FindAssociatedGlobalForNative<mozilla::dom::WorkerLocation>::Get,
504
  GetProtoObjectHandle,
505
  GetCCParticipant<mozilla::dom::WorkerLocation>::Get()
506
};
507
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
508
              "Must have the right minimal number of reserved slots.");
509
static_assert(1 >= 1,
510
              "Must have enough reserved slots.");
511
512
const JSClass*
513
GetJSClass()
514
0
{
515
0
  return sClass.ToJSClass();
516
0
}
517
518
bool
519
Wrap(JSContext* aCx, mozilla::dom::WorkerLocation* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
520
0
{
521
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::WorkerLocation>::value,
522
0
                "Shouldn't have wrappercached things that are not refcounted.");
523
0
  MOZ_ASSERT(static_cast<mozilla::dom::WorkerLocation*>(aObject) ==
524
0
             reinterpret_cast<mozilla::dom::WorkerLocation*>(aObject),
525
0
             "Multiple inheritance for mozilla::dom::WorkerLocation is broken.");
526
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
527
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
528
0
  MOZ_ASSERT(!aCache->GetWrapper(),
529
0
             "You should probably not be using Wrap() directly; use "
530
0
             "GetOrCreateDOMReflector instead");
531
0
532
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
533
0
             "nsISupports must be on our primary inheritance chain");
534
0
535
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
536
0
  if (!global) {
537
0
    return false;
538
0
  }
539
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
540
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
541
0
542
0
  // That might have ended up wrapping us already, due to the wonders
543
0
  // of XBL.  Check for that, and bail out as needed.
544
0
  aReflector.set(aCache->GetWrapper());
545
0
  if (aReflector) {
546
#ifdef DEBUG
547
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
548
#endif // DEBUG
549
    return true;
550
0
  }
551
0
552
0
  JSAutoRealm ar(aCx, global);
553
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
554
0
  if (!canonicalProto) {
555
0
    return false;
556
0
  }
557
0
  JS::Rooted<JSObject*> proto(aCx);
558
0
  if (aGivenProto) {
559
0
    proto = aGivenProto;
560
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
561
0
    // coming in, we changed compartments to that of "parent" so may need
562
0
    // to wrap the proto here.
563
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
564
0
      if (!JS_WrapObject(aCx, &proto)) {
565
0
        return false;
566
0
      }
567
0
    }
568
0
  } else {
569
0
    proto = canonicalProto;
570
0
  }
571
0
572
0
  BindingJSObjectCreator<mozilla::dom::WorkerLocation> creator(aCx);
573
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
574
0
  if (!aReflector) {
575
0
    return false;
576
0
  }
577
0
578
0
  aCache->SetWrapper(aReflector);
579
0
  creator.InitializationSucceeded();
580
0
581
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
582
0
             aCache->GetWrapperPreserveColor() == aReflector);
583
0
  // If proto != canonicalProto, we have to preserve our wrapper;
584
0
  // otherwise we won't be able to properly recreate it later, since
585
0
  // we won't know what proto to use.  Note that we don't check
586
0
  // aGivenProto here, since it's entirely possible (and even
587
0
  // somewhat common) to have a non-null aGivenProto which is the
588
0
  // same as canonicalProto.
589
0
  if (proto != canonicalProto) {
590
0
    PreserveWrapper(aObject);
591
0
  }
592
0
593
0
  return true;
594
0
}
595
596
void
597
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
598
0
{
599
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
600
0
  if (!parentProto) {
601
0
    return;
602
0
  }
603
0
604
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
605
0
  if (!constructorProto) {
606
0
    return;
607
0
  }
608
0
609
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WorkerLocation);
610
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WorkerLocation);
611
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
612
0
                              &sPrototypeClass.mBase, protoCache,
613
0
                              nullptr,
614
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
615
0
                              interfaceCache,
616
0
                              sNativeProperties.Upcast(),
617
0
                              nullptr,
618
0
                              "WorkerLocation", aDefineOnGlobal,
619
0
                              nullptr,
620
0
                              false);
621
0
}
622
623
JSObject*
624
GetConstructorObject(JSContext* aCx)
625
0
{
626
0
  return GetConstructorObjectHandle(aCx);
627
0
}
628
629
} // namespace WorkerLocation_Binding
630
631
632
633
} // namespace dom
634
} // namespace mozilla