Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/ServiceWorkerGlobalScopeBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM ServiceWorkerGlobalScope.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "EventHandlerBinding.h"
4
#include "ServiceWorkerGlobalScopeBinding.h"
5
#include "WorkerGlobalScopeBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/Clients.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/NonRefcountedDOMObject.h"
12
#include "mozilla/dom/Nullable.h"
13
#include "mozilla/dom/Promise.h"
14
#include "mozilla/dom/ServiceWorkerRegistration.h"
15
#include "mozilla/dom/ToJSValue.h"
16
#include "mozilla/dom/WorkerScope.h"
17
#include "nsThreadUtils.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
namespace binding_detail {}; // Just to make sure it's known as a namespace
23
using namespace mozilla::dom::binding_detail;
24
25
26
namespace ServiceWorkerGlobalScope_Binding {
27
28
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<WorkerGlobalScope_Binding::NativeType>::value,
29
              "Can't inherit from an interface with a different ownership model.");
30
31
MOZ_CAN_RUN_SCRIPT static bool
32
get_clients(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
33
0
{
34
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.clients", DOM, cx);
35
0
36
0
  auto result(StrongOrRawPtr<mozilla::dom::Clients>(self->GetClients()));
37
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
38
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
39
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
40
0
    return false;
41
0
  }
42
0
  return true;
43
0
}
44
45
static const JSJitInfo clients_getterinfo = {
46
  { (JSJitGetterOp)get_clients },
47
  { prototypes::id::ServiceWorkerGlobalScope },
48
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
49
  JSJitInfo::Getter,
50
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
51
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
52
  false,  /* isInfallible. False in setters. */
53
  true,  /* isMovable.  Not relevant for setters. */
54
  true, /* isEliminatable.  Not relevant for setters. */
55
  false, /* isAlwaysInSlot.  Only relevant for getters. */
56
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
57
  false,  /* isTypedMethod.  Only relevant for methods. */
58
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
59
};
60
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
61
static_assert(0 < 3, "There is no slot for us");
62
63
MOZ_CAN_RUN_SCRIPT static bool
64
get_registration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
65
0
{
66
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.registration", DOM, cx);
67
0
68
0
  auto result(StrongOrRawPtr<mozilla::dom::ServiceWorkerRegistration>(self->Registration()));
69
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
70
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
71
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
72
0
    return false;
73
0
  }
74
0
  return true;
75
0
}
76
77
static const JSJitInfo registration_getterinfo = {
78
  { (JSJitGetterOp)get_registration },
79
  { prototypes::id::ServiceWorkerGlobalScope },
80
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
81
  JSJitInfo::Getter,
82
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
83
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
84
  false,  /* isInfallible. False in setters. */
85
  true,  /* isMovable.  Not relevant for setters. */
86
  true, /* isEliminatable.  Not relevant for setters. */
87
  false, /* isAlwaysInSlot.  Only relevant for getters. */
88
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
89
  false,  /* isTypedMethod.  Only relevant for methods. */
90
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
91
};
92
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
93
static_assert(0 < 3, "There is no slot for us");
94
95
MOZ_CAN_RUN_SCRIPT static bool
96
skipWaiting(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, const JSJitMethodCallArgs& args)
97
0
{
98
0
  AUTO_PROFILER_LABEL_FAST("ServiceWorkerGlobalScope.skipWaiting", DOM, cx);
99
0
100
0
  FastErrorResult rv;
101
0
  auto result(StrongOrRawPtr<Promise>(self->SkipWaiting(rv)));
102
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
103
0
    return false;
104
0
  }
105
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
106
0
  static_assert(!IsPointer<decltype(result)>::value,
107
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
108
0
  if (!ToJSValue(cx, result, args.rval())) {
109
0
    return false;
110
0
  }
111
0
  return true;
112
0
}
113
114
MOZ_CAN_RUN_SCRIPT static bool
115
skipWaiting_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, const JSJitMethodCallArgs& args)
116
0
{
117
0
  bool ok = skipWaiting(cx, obj, self, args);
118
0
  if (ok) {
119
0
    return true;
120
0
  }
121
0
  return ConvertExceptionToPromise(cx, args.rval());
122
0
}
123
124
static const JSJitInfo skipWaiting_methodinfo = {
125
  { (JSJitGetterOp)skipWaiting_promiseWrapper },
126
  { prototypes::id::ServiceWorkerGlobalScope },
127
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
128
  JSJitInfo::Method,
129
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
130
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
131
  false,  /* 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 < 3, "There is no slot for us");
141
142
MOZ_CAN_RUN_SCRIPT static bool
143
get_oninstall(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
144
0
{
145
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.oninstall", DOM, cx);
146
0
147
0
  RefPtr<EventHandlerNonNull> result(self->GetOninstall());
148
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
149
0
  if (result) {
150
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
151
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
152
0
      return false;
153
0
    }
154
0
    return true;
155
0
  } else {
156
0
    args.rval().setNull();
157
0
    return true;
158
0
  }
159
0
}
160
161
MOZ_CAN_RUN_SCRIPT static bool
162
set_oninstall(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
163
0
{
164
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.oninstall", DOM, cx);
165
0
166
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
167
0
  if (args[0].isObject()) {
168
0
    { // scope for tempRoot and tempGlobalRoot if needed
169
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
170
0
    }
171
0
  } else {
172
0
    arg0 = nullptr;
173
0
  }
174
0
  self->SetOninstall(Constify(arg0));
175
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
176
0
177
0
  return true;
178
0
}
179
180
static const JSJitInfo oninstall_getterinfo = {
181
  { (JSJitGetterOp)get_oninstall },
182
  { prototypes::id::ServiceWorkerGlobalScope },
183
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
184
  JSJitInfo::Getter,
185
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
186
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
187
  false,  /* isInfallible. False in setters. */
188
  false,  /* isMovable.  Not relevant for setters. */
189
  false, /* isEliminatable.  Not relevant for setters. */
190
  false, /* isAlwaysInSlot.  Only relevant for getters. */
191
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
192
  false,  /* isTypedMethod.  Only relevant for methods. */
193
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
194
};
195
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
196
static_assert(0 < 3, "There is no slot for us");
197
static const JSJitInfo oninstall_setterinfo = {
198
  { (JSJitGetterOp)set_oninstall },
199
  { prototypes::id::ServiceWorkerGlobalScope },
200
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
201
  JSJitInfo::Setter,
202
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
203
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
204
  false,  /* isInfallible. False in setters. */
205
  false,  /* isMovable.  Not relevant for setters. */
206
  false, /* isEliminatable.  Not relevant for setters. */
207
  false, /* isAlwaysInSlot.  Only relevant for getters. */
208
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
209
  false,  /* isTypedMethod.  Only relevant for methods. */
210
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
211
};
212
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
213
static_assert(0 < 3, "There is no slot for us");
214
215
MOZ_CAN_RUN_SCRIPT static bool
216
get_onactivate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
217
0
{
218
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.onactivate", DOM, cx);
219
0
220
0
  RefPtr<EventHandlerNonNull> result(self->GetOnactivate());
221
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
222
0
  if (result) {
223
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
224
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
225
0
      return false;
226
0
    }
227
0
    return true;
228
0
  } else {
229
0
    args.rval().setNull();
230
0
    return true;
231
0
  }
232
0
}
233
234
MOZ_CAN_RUN_SCRIPT static bool
235
set_onactivate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
236
0
{
237
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.onactivate", DOM, cx);
238
0
239
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
240
0
  if (args[0].isObject()) {
241
0
    { // scope for tempRoot and tempGlobalRoot if needed
242
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
243
0
    }
244
0
  } else {
245
0
    arg0 = nullptr;
246
0
  }
247
0
  self->SetOnactivate(Constify(arg0));
248
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
249
0
250
0
  return true;
251
0
}
252
253
static const JSJitInfo onactivate_getterinfo = {
254
  { (JSJitGetterOp)get_onactivate },
255
  { prototypes::id::ServiceWorkerGlobalScope },
256
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
257
  JSJitInfo::Getter,
258
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
259
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
260
  false,  /* isInfallible. False in setters. */
261
  false,  /* isMovable.  Not relevant for setters. */
262
  false, /* isEliminatable.  Not relevant for setters. */
263
  false, /* isAlwaysInSlot.  Only relevant for getters. */
264
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
265
  false,  /* isTypedMethod.  Only relevant for methods. */
266
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
267
};
268
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
269
static_assert(0 < 3, "There is no slot for us");
270
static const JSJitInfo onactivate_setterinfo = {
271
  { (JSJitGetterOp)set_onactivate },
272
  { prototypes::id::ServiceWorkerGlobalScope },
273
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
274
  JSJitInfo::Setter,
275
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
276
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
277
  false,  /* isInfallible. False in setters. */
278
  false,  /* isMovable.  Not relevant for setters. */
279
  false, /* isEliminatable.  Not relevant for setters. */
280
  false, /* isAlwaysInSlot.  Only relevant for getters. */
281
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
282
  false,  /* isTypedMethod.  Only relevant for methods. */
283
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
284
};
285
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
286
static_assert(0 < 3, "There is no slot for us");
287
288
MOZ_CAN_RUN_SCRIPT static bool
289
get_onfetch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
290
0
{
291
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.onfetch", DOM, cx);
292
0
293
0
  RefPtr<EventHandlerNonNull> result(self->GetOnfetch());
294
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
295
0
  if (result) {
296
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
297
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
298
0
      return false;
299
0
    }
300
0
    return true;
301
0
  } else {
302
0
    args.rval().setNull();
303
0
    return true;
304
0
  }
305
0
}
306
307
MOZ_CAN_RUN_SCRIPT static bool
308
set_onfetch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
309
0
{
310
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.onfetch", DOM, cx);
311
0
312
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
313
0
  if (args[0].isObject()) {
314
0
    { // scope for tempRoot and tempGlobalRoot if needed
315
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
316
0
    }
317
0
  } else {
318
0
    arg0 = nullptr;
319
0
  }
320
0
  self->SetOnfetch(Constify(arg0));
321
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
322
0
323
0
  return true;
324
0
}
325
326
static const JSJitInfo onfetch_getterinfo = {
327
  { (JSJitGetterOp)get_onfetch },
328
  { prototypes::id::ServiceWorkerGlobalScope },
329
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
330
  JSJitInfo::Getter,
331
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
332
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
333
  false,  /* isInfallible. False in setters. */
334
  false,  /* isMovable.  Not relevant for setters. */
335
  false, /* isEliminatable.  Not relevant for setters. */
336
  false, /* isAlwaysInSlot.  Only relevant for getters. */
337
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
338
  false,  /* isTypedMethod.  Only relevant for methods. */
339
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
340
};
341
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
342
static_assert(0 < 3, "There is no slot for us");
343
static const JSJitInfo onfetch_setterinfo = {
344
  { (JSJitGetterOp)set_onfetch },
345
  { prototypes::id::ServiceWorkerGlobalScope },
346
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
347
  JSJitInfo::Setter,
348
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
349
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
350
  false,  /* isInfallible. False in setters. */
351
  false,  /* isMovable.  Not relevant for setters. */
352
  false, /* isEliminatable.  Not relevant for setters. */
353
  false, /* isAlwaysInSlot.  Only relevant for getters. */
354
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
355
  false,  /* isTypedMethod.  Only relevant for methods. */
356
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
357
};
358
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
359
static_assert(0 < 3, "There is no slot for us");
360
361
MOZ_CAN_RUN_SCRIPT static bool
362
get_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
363
0
{
364
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.onmessage", DOM, cx);
365
0
366
0
  RefPtr<EventHandlerNonNull> result(self->GetOnmessage());
367
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
368
0
  if (result) {
369
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
370
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
371
0
      return false;
372
0
    }
373
0
    return true;
374
0
  } else {
375
0
    args.rval().setNull();
376
0
    return true;
377
0
  }
378
0
}
379
380
MOZ_CAN_RUN_SCRIPT static bool
381
set_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
382
0
{
383
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.onmessage", DOM, cx);
384
0
385
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
386
0
  if (args[0].isObject()) {
387
0
    { // scope for tempRoot and tempGlobalRoot if needed
388
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
389
0
    }
390
0
  } else {
391
0
    arg0 = nullptr;
392
0
  }
393
0
  self->SetOnmessage(Constify(arg0));
394
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
395
0
396
0
  return true;
397
0
}
398
399
static const JSJitInfo onmessage_getterinfo = {
400
  { (JSJitGetterOp)get_onmessage },
401
  { prototypes::id::ServiceWorkerGlobalScope },
402
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
403
  JSJitInfo::Getter,
404
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
405
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
406
  false,  /* isInfallible. False in setters. */
407
  false,  /* isMovable.  Not relevant for setters. */
408
  false, /* isEliminatable.  Not relevant for setters. */
409
  false, /* isAlwaysInSlot.  Only relevant for getters. */
410
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
411
  false,  /* isTypedMethod.  Only relevant for methods. */
412
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
413
};
414
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
415
static_assert(0 < 3, "There is no slot for us");
416
static const JSJitInfo onmessage_setterinfo = {
417
  { (JSJitGetterOp)set_onmessage },
418
  { prototypes::id::ServiceWorkerGlobalScope },
419
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
420
  JSJitInfo::Setter,
421
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
422
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
423
  false,  /* isInfallible. False in setters. */
424
  false,  /* isMovable.  Not relevant for setters. */
425
  false, /* isEliminatable.  Not relevant for setters. */
426
  false, /* isAlwaysInSlot.  Only relevant for getters. */
427
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
428
  false,  /* isTypedMethod.  Only relevant for methods. */
429
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
430
};
431
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
432
static_assert(0 < 3, "There is no slot for us");
433
434
MOZ_CAN_RUN_SCRIPT static bool
435
get_onpush(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
436
0
{
437
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.onpush", DOM, cx);
438
0
439
0
  RefPtr<EventHandlerNonNull> result(self->GetOnpush());
440
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
441
0
  if (result) {
442
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
443
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
444
0
      return false;
445
0
    }
446
0
    return true;
447
0
  } else {
448
0
    args.rval().setNull();
449
0
    return true;
450
0
  }
451
0
}
452
453
MOZ_CAN_RUN_SCRIPT static bool
454
set_onpush(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
455
0
{
456
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.onpush", DOM, cx);
457
0
458
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
459
0
  if (args[0].isObject()) {
460
0
    { // scope for tempRoot and tempGlobalRoot if needed
461
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
462
0
    }
463
0
  } else {
464
0
    arg0 = nullptr;
465
0
  }
466
0
  self->SetOnpush(Constify(arg0));
467
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
468
0
469
0
  return true;
470
0
}
471
472
static const JSJitInfo onpush_getterinfo = {
473
  { (JSJitGetterOp)get_onpush },
474
  { prototypes::id::ServiceWorkerGlobalScope },
475
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
476
  JSJitInfo::Getter,
477
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
478
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
479
  false,  /* isInfallible. False in setters. */
480
  false,  /* isMovable.  Not relevant for setters. */
481
  false, /* isEliminatable.  Not relevant for setters. */
482
  false, /* isAlwaysInSlot.  Only relevant for getters. */
483
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
484
  false,  /* isTypedMethod.  Only relevant for methods. */
485
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
486
};
487
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
488
static_assert(0 < 3, "There is no slot for us");
489
static const JSJitInfo onpush_setterinfo = {
490
  { (JSJitGetterOp)set_onpush },
491
  { prototypes::id::ServiceWorkerGlobalScope },
492
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
493
  JSJitInfo::Setter,
494
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
495
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
496
  false,  /* isInfallible. False in setters. */
497
  false,  /* isMovable.  Not relevant for setters. */
498
  false, /* isEliminatable.  Not relevant for setters. */
499
  false, /* isAlwaysInSlot.  Only relevant for getters. */
500
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
501
  false,  /* isTypedMethod.  Only relevant for methods. */
502
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
503
};
504
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
505
static_assert(0 < 3, "There is no slot for us");
506
507
MOZ_CAN_RUN_SCRIPT static bool
508
get_onpushsubscriptionchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
509
0
{
510
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.onpushsubscriptionchange", DOM, cx);
511
0
512
0
  RefPtr<EventHandlerNonNull> result(self->GetOnpushsubscriptionchange());
513
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
514
0
  if (result) {
515
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
516
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
517
0
      return false;
518
0
    }
519
0
    return true;
520
0
  } else {
521
0
    args.rval().setNull();
522
0
    return true;
523
0
  }
524
0
}
525
526
MOZ_CAN_RUN_SCRIPT static bool
527
set_onpushsubscriptionchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
528
0
{
529
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.onpushsubscriptionchange", DOM, cx);
530
0
531
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
532
0
  if (args[0].isObject()) {
533
0
    { // scope for tempRoot and tempGlobalRoot if needed
534
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
535
0
    }
536
0
  } else {
537
0
    arg0 = nullptr;
538
0
  }
539
0
  self->SetOnpushsubscriptionchange(Constify(arg0));
540
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
541
0
542
0
  return true;
543
0
}
544
545
static const JSJitInfo onpushsubscriptionchange_getterinfo = {
546
  { (JSJitGetterOp)get_onpushsubscriptionchange },
547
  { prototypes::id::ServiceWorkerGlobalScope },
548
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
549
  JSJitInfo::Getter,
550
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
551
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
552
  false,  /* isInfallible. False in setters. */
553
  false,  /* isMovable.  Not relevant for setters. */
554
  false, /* isEliminatable.  Not relevant for setters. */
555
  false, /* isAlwaysInSlot.  Only relevant for getters. */
556
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
557
  false,  /* isTypedMethod.  Only relevant for methods. */
558
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
559
};
560
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
561
static_assert(0 < 3, "There is no slot for us");
562
static const JSJitInfo onpushsubscriptionchange_setterinfo = {
563
  { (JSJitGetterOp)set_onpushsubscriptionchange },
564
  { prototypes::id::ServiceWorkerGlobalScope },
565
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
566
  JSJitInfo::Setter,
567
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
568
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
569
  false,  /* isInfallible. False in setters. */
570
  false,  /* isMovable.  Not relevant for setters. */
571
  false, /* isEliminatable.  Not relevant for setters. */
572
  false, /* isAlwaysInSlot.  Only relevant for getters. */
573
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
574
  false,  /* isTypedMethod.  Only relevant for methods. */
575
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
576
};
577
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
578
static_assert(0 < 3, "There is no slot for us");
579
580
MOZ_CAN_RUN_SCRIPT static bool
581
get_onnotificationclick(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
582
0
{
583
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.onnotificationclick", DOM, cx);
584
0
585
0
  RefPtr<EventHandlerNonNull> result(self->GetOnnotificationclick());
586
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
587
0
  if (result) {
588
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
589
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
590
0
      return false;
591
0
    }
592
0
    return true;
593
0
  } else {
594
0
    args.rval().setNull();
595
0
    return true;
596
0
  }
597
0
}
598
599
MOZ_CAN_RUN_SCRIPT static bool
600
set_onnotificationclick(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
601
0
{
602
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.onnotificationclick", DOM, cx);
603
0
604
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
605
0
  if (args[0].isObject()) {
606
0
    { // scope for tempRoot and tempGlobalRoot if needed
607
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
608
0
    }
609
0
  } else {
610
0
    arg0 = nullptr;
611
0
  }
612
0
  self->SetOnnotificationclick(Constify(arg0));
613
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
614
0
615
0
  return true;
616
0
}
617
618
static const JSJitInfo onnotificationclick_getterinfo = {
619
  { (JSJitGetterOp)get_onnotificationclick },
620
  { prototypes::id::ServiceWorkerGlobalScope },
621
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
622
  JSJitInfo::Getter,
623
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
624
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
625
  false,  /* isInfallible. False in setters. */
626
  false,  /* isMovable.  Not relevant for setters. */
627
  false, /* isEliminatable.  Not relevant for setters. */
628
  false, /* isAlwaysInSlot.  Only relevant for getters. */
629
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
630
  false,  /* isTypedMethod.  Only relevant for methods. */
631
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
632
};
633
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
634
static_assert(0 < 3, "There is no slot for us");
635
static const JSJitInfo onnotificationclick_setterinfo = {
636
  { (JSJitGetterOp)set_onnotificationclick },
637
  { prototypes::id::ServiceWorkerGlobalScope },
638
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
639
  JSJitInfo::Setter,
640
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
641
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
642
  false,  /* isInfallible. False in setters. */
643
  false,  /* isMovable.  Not relevant for setters. */
644
  false, /* isEliminatable.  Not relevant for setters. */
645
  false, /* isAlwaysInSlot.  Only relevant for getters. */
646
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
647
  false,  /* isTypedMethod.  Only relevant for methods. */
648
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
649
};
650
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
651
static_assert(0 < 3, "There is no slot for us");
652
653
MOZ_CAN_RUN_SCRIPT static bool
654
get_onnotificationclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitGetterCallArgs args)
655
0
{
656
0
  AUTO_PROFILER_LABEL_FAST("get ServiceWorkerGlobalScope.onnotificationclose", DOM, cx);
657
0
658
0
  RefPtr<EventHandlerNonNull> result(self->GetOnnotificationclose());
659
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
660
0
  if (result) {
661
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
662
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
663
0
      return false;
664
0
    }
665
0
    return true;
666
0
  } else {
667
0
    args.rval().setNull();
668
0
    return true;
669
0
  }
670
0
}
671
672
MOZ_CAN_RUN_SCRIPT static bool
673
set_onnotificationclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ServiceWorkerGlobalScope* self, JSJitSetterCallArgs args)
674
0
{
675
0
  AUTO_PROFILER_LABEL_FAST("set ServiceWorkerGlobalScope.onnotificationclose", DOM, cx);
676
0
677
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
678
0
  if (args[0].isObject()) {
679
0
    { // scope for tempRoot and tempGlobalRoot if needed
680
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
681
0
    }
682
0
  } else {
683
0
    arg0 = nullptr;
684
0
  }
685
0
  self->SetOnnotificationclose(Constify(arg0));
686
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
687
0
688
0
  return true;
689
0
}
690
691
static const JSJitInfo onnotificationclose_getterinfo = {
692
  { (JSJitGetterOp)get_onnotificationclose },
693
  { prototypes::id::ServiceWorkerGlobalScope },
694
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
695
  JSJitInfo::Getter,
696
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
697
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
698
  false,  /* isInfallible. False in setters. */
699
  false,  /* isMovable.  Not relevant for setters. */
700
  false, /* isEliminatable.  Not relevant for setters. */
701
  false, /* isAlwaysInSlot.  Only relevant for getters. */
702
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
703
  false,  /* isTypedMethod.  Only relevant for methods. */
704
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
705
};
706
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
707
static_assert(0 < 3, "There is no slot for us");
708
static const JSJitInfo onnotificationclose_setterinfo = {
709
  { (JSJitGetterOp)set_onnotificationclose },
710
  { prototypes::id::ServiceWorkerGlobalScope },
711
  { PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth },
712
  JSJitInfo::Setter,
713
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
714
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
715
  false,  /* isInfallible. False in setters. */
716
  false,  /* isMovable.  Not relevant for setters. */
717
  false, /* isEliminatable.  Not relevant for setters. */
718
  false, /* isAlwaysInSlot.  Only relevant for getters. */
719
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
720
  false,  /* isTypedMethod.  Only relevant for methods. */
721
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
722
};
723
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
724
static_assert(0 < 3, "There is no slot for us");
725
726
static void
727
_finalize(js::FreeOp* fop, JSObject* obj)
728
0
{
729
0
  mozilla::dom::ServiceWorkerGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ServiceWorkerGlobalScope>(obj);
730
0
  if (self) {
731
0
    ClearWrapper(self, self, obj);
732
0
    mozilla::dom::FinalizeGlobal(CastToJSFreeOp(fop), obj);
733
0
    AddForDeferredFinalization<mozilla::dom::ServiceWorkerGlobalScope>(self);
734
0
  }
735
0
}
736
737
static size_t
738
_objectMoved(JSObject* obj, JSObject* old)
739
0
{
740
0
  mozilla::dom::ServiceWorkerGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ServiceWorkerGlobalScope>(obj);
741
0
  if (self) {
742
0
    UpdateWrapper(self, self, obj, old);
743
0
  }
744
0
745
0
  return 0;
746
0
}
747
748
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
749
#if defined(__clang__)
750
#pragma clang diagnostic push
751
#pragma clang diagnostic ignored "-Wmissing-braces"
752
#endif
753
static const JSFunctionSpec sMethods_specs[] = {
754
  JS_FNSPEC("skipWaiting", (GenericMethod<MaybeGlobalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&skipWaiting_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
755
  JS_FS_END
756
};
757
#if defined(__clang__)
758
#pragma clang diagnostic pop
759
#endif
760
761
762
static const Prefable<const JSFunctionSpec> sMethods[] = {
763
  { nullptr, &sMethods_specs[0] },
764
  { nullptr, nullptr }
765
};
766
767
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
768
#if defined(__clang__)
769
#pragma clang diagnostic push
770
#pragma clang diagnostic ignored "-Wmissing-braces"
771
#endif
772
static const JSPropertySpec sAttributes_specs[] = {
773
  { "clients", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &clients_getterinfo, nullptr, nullptr },
774
  { "registration", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &registration_getterinfo, nullptr, nullptr },
775
  { "oninstall", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &oninstall_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &oninstall_setterinfo },
776
  { "onactivate", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onactivate_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onactivate_setterinfo },
777
  { "onfetch", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onfetch_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onfetch_setterinfo },
778
  { "onmessage", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onmessage_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onmessage_setterinfo },
779
  { "onpush", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onpush_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onpush_setterinfo },
780
  { "onpushsubscriptionchange", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onpushsubscriptionchange_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onpushsubscriptionchange_setterinfo },
781
  { "onnotificationclick", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onnotificationclick_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onnotificationclick_setterinfo },
782
  { "onnotificationclose", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onnotificationclose_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onnotificationclose_setterinfo },
783
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
784
};
785
#if defined(__clang__)
786
#pragma clang diagnostic pop
787
#endif
788
789
790
static const Prefable<const JSPropertySpec> sAttributes[] = {
791
  { nullptr, &sAttributes_specs[0] },
792
  { nullptr, nullptr }
793
};
794
795
796
static const NativePropertiesN<2> sNativeProperties = {
797
  false, 0,
798
  false, 0,
799
  true,  0 /* sMethods */,
800
  true,  1 /* sAttributes */,
801
  false, 0,
802
  false, 0,
803
  false, 0,
804
  -1,
805
  0,
806
  nullptr,
807
  {
808
    { sMethods, nullptr },
809
    { sAttributes, nullptr }
810
  }
811
};
812
813
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
814
  {
815
    "Function",
816
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
817
    &sBoringInterfaceObjectClassClassOps,
818
    JS_NULL_CLASS_SPEC,
819
    JS_NULL_CLASS_EXT,
820
    &sInterfaceObjectClassObjectOps
821
  },
822
  eInterface,
823
  true,
824
  prototypes::id::ServiceWorkerGlobalScope,
825
  PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth,
826
  &sEmptyNativePropertyHooks,
827
  "function ServiceWorkerGlobalScope() {\n    [native code]\n}",
828
  WorkerGlobalScope_Binding::GetConstructorObject
829
};
830
831
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
832
  {
833
    "ServiceWorkerGlobalScopePrototype",
834
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
835
    JS_NULL_CLASS_OPS,
836
    JS_NULL_CLASS_SPEC,
837
    JS_NULL_CLASS_EXT,
838
    JS_NULL_OBJECT_OPS
839
  },
840
  eGlobalInterfacePrototype,
841
  false,
842
  prototypes::id::ServiceWorkerGlobalScope,
843
  PrototypeTraits<prototypes::id::ServiceWorkerGlobalScope>::Depth,
844
  &sEmptyNativePropertyHooks,
845
  "[object ServiceWorkerGlobalScopePrototype]",
846
  WorkerGlobalScope_Binding::GetProtoObject
847
};
848
849
bool
850
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
851
0
{
852
0
  MOZ_ASSERT(!NS_IsMainThread(), "Why did we even get called?");
853
0
854
0
  const char* name = js::GetObjectClass(aObj)->name;
855
0
  if (strcmp(name, "ServiceWorkerGlobalScope")) {
856
0
    return false;
857
0
  }
858
0
859
0
  return true;
860
0
}
861
862
static const js::ClassOps sClassOps = {
863
  nullptr, /* addProperty */
864
  nullptr,               /* delProperty */
865
  nullptr,               /* enumerate */
866
  mozilla::dom::EnumerateGlobal, /* newEnumerate */
867
  mozilla::dom::ResolveGlobal, /* resolve */
868
  mozilla::dom::MayResolveGlobal, /* mayResolve */
869
  _finalize, /* finalize */
870
  nullptr, /* call */
871
  nullptr,               /* hasInstance */
872
  nullptr,               /* construct */
873
  JS_GlobalObjectTraceHook, /* trace */
874
};
875
876
static const js::ClassExtension sClassExtension = {
877
  nullptr, /* weakmapKeyDelegateOp */
878
  _objectMoved /* objectMovedOp */
879
};
880
881
static const DOMJSClass sClass = {
882
  { "ServiceWorkerGlobalScope",
883
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS),
884
    &sClassOps,
885
    JS_NULL_CLASS_SPEC,
886
    &sClassExtension,
887
    JS_NULL_OBJECT_OPS
888
  },
889
  { prototypes::id::EventTarget, prototypes::id::WorkerGlobalScope, prototypes::id::ServiceWorkerGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
890
  IsBaseOf<nsISupports, mozilla::dom::ServiceWorkerGlobalScope >::value,
891
  &sEmptyNativePropertyHooks,
892
  FindAssociatedGlobalForNative<mozilla::dom::ServiceWorkerGlobalScope>::Get,
893
  GetProtoObjectHandle,
894
  GetCCParticipant<mozilla::dom::ServiceWorkerGlobalScope>::Get()
895
};
896
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
897
              "Must have the right minimal number of reserved slots.");
898
static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 3,
899
              "Must have enough reserved slots.");
900
901
const JSClass*
902
GetJSClass()
903
0
{
904
0
  return sClass.ToJSClass();
905
0
}
906
907
bool
908
Wrap(JSContext* aCx, mozilla::dom::ServiceWorkerGlobalScope* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, bool aInitStandardClasses, JS::MutableHandle<JSObject*> aReflector)
909
0
{
910
0
  MOZ_ASSERT(static_cast<mozilla::dom::ServiceWorkerGlobalScope*>(aObject) ==
911
0
             reinterpret_cast<mozilla::dom::ServiceWorkerGlobalScope*>(aObject),
912
0
             "Multiple inheritance for mozilla::dom::ServiceWorkerGlobalScope is broken.");
913
0
  MOZ_ASSERT(static_cast<mozilla::dom::WorkerGlobalScope*>(aObject) ==
914
0
             reinterpret_cast<mozilla::dom::WorkerGlobalScope*>(aObject),
915
0
             "Multiple inheritance for mozilla::dom::WorkerGlobalScope is broken.");
916
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
917
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
918
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
919
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
920
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
921
0
             "nsISupports must be on our primary inheritance chain");
922
0
923
0
  if (!CreateGlobal<mozilla::dom::ServiceWorkerGlobalScope, GetProtoObjectHandle>(aCx,
924
0
                                   aObject,
925
0
                                   aCache,
926
0
                                   sClass.ToJSClass(),
927
0
                                   aOptions,
928
0
                                   aPrincipal,
929
0
                                   aInitStandardClasses,
930
0
                                   aReflector)) {
931
0
    aCache->ReleaseWrapper(aObject);
932
0
    aCache->ClearWrapper();
933
0
    return false;
934
0
  }
935
0
936
0
  // aReflector is a new global, so has a new realm.  Enter it
937
0
  // before doing anything with it.
938
0
  JSAutoRealm ar(aCx, aReflector);
939
0
940
0
  if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) {
941
0
    aCache->ReleaseWrapper(aObject);
942
0
    aCache->ClearWrapper();
943
0
    return false;
944
0
  }
945
0
946
0
947
0
  return true;
948
0
}
949
950
void
951
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
952
0
{
953
0
  JS::Handle<JSObject*> parentProto(WorkerGlobalScope_Binding::GetProtoObjectHandle(aCx));
954
0
  if (!parentProto) {
955
0
    return;
956
0
  }
957
0
958
0
  JS::Handle<JSObject*> constructorProto(WorkerGlobalScope_Binding::GetConstructorObjectHandle(aCx));
959
0
  if (!constructorProto) {
960
0
    return;
961
0
  }
962
0
963
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ServiceWorkerGlobalScope);
964
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ServiceWorkerGlobalScope);
965
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
966
0
                              &sPrototypeClass.mBase, protoCache,
967
0
                              nullptr,
968
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
969
0
                              interfaceCache,
970
0
                              sNativeProperties.Upcast(),
971
0
                              nullptr,
972
0
                              "ServiceWorkerGlobalScope", aDefineOnGlobal,
973
0
                              nullptr,
974
0
                              true);
975
0
976
0
  if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ServiceWorkerGlobalScope)) {
977
0
    bool succeeded;
978
0
    JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx);
979
0
    if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) {
980
0
      *protoCache = nullptr;
981
0
      if (interfaceCache) {
982
0
        *interfaceCache = nullptr;
983
0
      }
984
0
      return;
985
0
    }
986
0
987
0
    MOZ_ASSERT(succeeded,
988
0
               "making a fresh prototype object's [[Prototype]] "
989
0
               "immutable can internally fail, but it should "
990
0
               "never be unsuccessful");
991
0
  }
992
0
}
993
994
JSObject*
995
GetConstructorObject(JSContext* aCx)
996
0
{
997
0
  return GetConstructorObjectHandle(aCx);
998
0
}
999
1000
} // namespace ServiceWorkerGlobalScope_Binding
1001
1002
1003
1004
} // namespace dom
1005
} // namespace mozilla