Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/ExtendableMessageEventBinding.h
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM ExtendableMessageEvent.webidl BY Codegen.py - DO NOT EDIT */
2
3
#ifndef mozilla_dom_ExtendableMessageEventBinding_h
4
#define mozilla_dom_ExtendableMessageEventBinding_h
5
6
#include "ExtendableEventBinding.h"
7
#include "GeckoProfiler.h"
8
#include "js/RootingAPI.h"
9
#include "jspubtd.h"
10
#include "mozilla/ErrorResult.h"
11
#include "mozilla/dom/BindingDeclarations.h"
12
#include "mozilla/dom/FakeString.h"
13
#include "mozilla/dom/MessagePort.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrototypeList.h"
16
#include "mozilla/dom/UnionMember.h"
17
18
namespace mozilla {
19
namespace dom {
20
21
class Client;
22
class ClientOrServiceWorkerOrMessagePort;
23
class ExtendableMessageEvent;
24
struct ExtendableMessageEventAtoms;
25
struct ExtendableMessageEventInitAtoms;
26
class MessagePort;
27
struct NativePropertyHooks;
28
class OwningClientOrServiceWorkerOrMessagePort;
29
class ProtoAndIfaceCache;
30
class ServiceWorker;
31
32
} // namespace dom
33
} // namespace mozilla
34
35
namespace mozilla {
36
namespace dom {
37
38
void
39
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningClientOrServiceWorkerOrMessagePort& aUnion, const char* aName, uint32_t aFlags = 0);
40
41
42
void
43
ImplCycleCollectionUnlink(OwningClientOrServiceWorkerOrMessagePort& aUnion);
44
45
46
class ClientOrServiceWorkerOrMessagePort
47
{
48
  friend class ClientOrServiceWorkerOrMessagePortArgument;
49
  enum Type
50
  {
51
    eUninitialized,
52
    eClient,
53
    eServiceWorker,
54
    eMessagePort
55
  };
56
57
  union Value
58
  {
59
    UnionMember<NonNull<mozilla::dom::Client> > mClient;
60
    UnionMember<NonNull<mozilla::dom::ServiceWorker> > mServiceWorker;
61
    UnionMember<NonNull<mozilla::dom::MessagePort> > mMessagePort;
62
63
  };
64
65
  Type mType;
66
  Value mValue;
67
68
  ClientOrServiceWorkerOrMessagePort(const ClientOrServiceWorkerOrMessagePort&) = delete;
69
  ClientOrServiceWorkerOrMessagePort& operator=(const ClientOrServiceWorkerOrMessagePort&) = delete;
70
public:
71
  explicit inline ClientOrServiceWorkerOrMessagePort()
72
    : mType(eUninitialized)
73
0
  {
74
0
  }
75
76
  inline ~ClientOrServiceWorkerOrMessagePort()
77
0
  {
78
0
    Uninit();
79
0
  }
80
81
  inline NonNull<mozilla::dom::Client>&
82
  RawSetAsClient()
83
0
  {
84
0
    if (mType == eClient) {
85
0
      return mValue.mClient.Value();
86
0
    }
87
0
    MOZ_ASSERT(mType == eUninitialized);
88
0
    mType = eClient;
89
0
    return mValue.mClient.SetValue();
90
0
  }
91
92
  inline NonNull<mozilla::dom::Client>&
93
  SetAsClient()
94
0
  {
95
0
    if (mType == eClient) {
96
0
      return mValue.mClient.Value();
97
0
    }
98
0
    Uninit();
99
0
    mType = eClient;
100
0
    return mValue.mClient.SetValue();
101
0
  }
102
103
  inline bool
104
  IsClient() const
105
0
  {
106
0
    return mType == eClient;
107
0
  }
108
109
  inline NonNull<mozilla::dom::Client>&
110
  GetAsClient()
111
0
  {
112
0
    MOZ_ASSERT(IsClient(), "Wrong type!");
113
0
    return mValue.mClient.Value();
114
0
  }
115
116
  inline mozilla::dom::Client&
117
  GetAsClient() const
118
0
  {
119
0
    MOZ_ASSERT(IsClient(), "Wrong type!");
120
0
    return mValue.mClient.Value();
121
0
  }
122
123
  inline NonNull<mozilla::dom::ServiceWorker>&
124
  RawSetAsServiceWorker()
125
0
  {
126
0
    if (mType == eServiceWorker) {
127
0
      return mValue.mServiceWorker.Value();
128
0
    }
129
0
    MOZ_ASSERT(mType == eUninitialized);
130
0
    mType = eServiceWorker;
131
0
    return mValue.mServiceWorker.SetValue();
132
0
  }
133
134
  inline NonNull<mozilla::dom::ServiceWorker>&
135
  SetAsServiceWorker()
136
0
  {
137
0
    if (mType == eServiceWorker) {
138
0
      return mValue.mServiceWorker.Value();
139
0
    }
140
0
    Uninit();
141
0
    mType = eServiceWorker;
142
0
    return mValue.mServiceWorker.SetValue();
143
0
  }
144
145
  inline bool
146
  IsServiceWorker() const
147
0
  {
148
0
    return mType == eServiceWorker;
149
0
  }
150
151
  inline NonNull<mozilla::dom::ServiceWorker>&
152
  GetAsServiceWorker()
153
0
  {
154
0
    MOZ_ASSERT(IsServiceWorker(), "Wrong type!");
155
0
    return mValue.mServiceWorker.Value();
156
0
  }
157
158
  inline mozilla::dom::ServiceWorker&
159
  GetAsServiceWorker() const
160
0
  {
161
0
    MOZ_ASSERT(IsServiceWorker(), "Wrong type!");
162
0
    return mValue.mServiceWorker.Value();
163
0
  }
164
165
  inline NonNull<mozilla::dom::MessagePort>&
166
  RawSetAsMessagePort()
167
0
  {
168
0
    if (mType == eMessagePort) {
169
0
      return mValue.mMessagePort.Value();
170
0
    }
171
0
    MOZ_ASSERT(mType == eUninitialized);
172
0
    mType = eMessagePort;
173
0
    return mValue.mMessagePort.SetValue();
174
0
  }
175
176
  inline NonNull<mozilla::dom::MessagePort>&
177
  SetAsMessagePort()
178
0
  {
179
0
    if (mType == eMessagePort) {
180
0
      return mValue.mMessagePort.Value();
181
0
    }
182
0
    Uninit();
183
0
    mType = eMessagePort;
184
0
    return mValue.mMessagePort.SetValue();
185
0
  }
186
187
  inline bool
188
  IsMessagePort() const
189
0
  {
190
0
    return mType == eMessagePort;
191
0
  }
192
193
  inline NonNull<mozilla::dom::MessagePort>&
194
  GetAsMessagePort()
195
0
  {
196
0
    MOZ_ASSERT(IsMessagePort(), "Wrong type!");
197
0
    return mValue.mMessagePort.Value();
198
0
  }
199
200
  inline mozilla::dom::MessagePort&
201
  GetAsMessagePort() const
202
0
  {
203
0
    MOZ_ASSERT(IsMessagePort(), "Wrong type!");
204
0
    return mValue.mMessagePort.Value();
205
0
  }
206
207
  inline void
208
  Uninit()
209
0
  {
210
0
    switch (mType) {
211
0
      case eUninitialized: {
212
0
        break;
213
0
      }
214
0
      case eClient: {
215
0
        DestroyClient();
216
0
        break;
217
0
      }
218
0
      case eServiceWorker: {
219
0
        DestroyServiceWorker();
220
0
        break;
221
0
      }
222
0
      case eMessagePort: {
223
0
        DestroyMessagePort();
224
0
        break;
225
0
      }
226
0
    }
227
0
  }
228
229
  bool
230
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
231
232
private:
233
  inline void
234
  DestroyClient()
235
0
  {
236
0
    MOZ_ASSERT(IsClient(), "Wrong type!");
237
0
    mValue.mClient.Destroy();
238
0
    mType = eUninitialized;
239
0
  }
240
241
  inline void
242
  DestroyServiceWorker()
243
0
  {
244
0
    MOZ_ASSERT(IsServiceWorker(), "Wrong type!");
245
0
    mValue.mServiceWorker.Destroy();
246
0
    mType = eUninitialized;
247
0
  }
248
249
  inline void
250
  DestroyMessagePort()
251
0
  {
252
0
    MOZ_ASSERT(IsMessagePort(), "Wrong type!");
253
0
    mValue.mMessagePort.Destroy();
254
0
    mType = eUninitialized;
255
0
  }
256
};
257
258
259
class OwningClientOrServiceWorkerOrMessagePort : public AllOwningUnionBase
260
{
261
  friend void ImplCycleCollectionUnlink(OwningClientOrServiceWorkerOrMessagePort& aUnion);
262
  enum Type
263
  {
264
    eUninitialized,
265
    eClient,
266
    eServiceWorker,
267
    eMessagePort
268
  };
269
270
  union Value
271
  {
272
    UnionMember<OwningNonNull<mozilla::dom::Client> > mClient;
273
    UnionMember<OwningNonNull<mozilla::dom::ServiceWorker> > mServiceWorker;
274
    UnionMember<OwningNonNull<mozilla::dom::MessagePort> > mMessagePort;
275
276
  };
277
278
  Type mType;
279
  Value mValue;
280
281
public:
282
  explicit inline OwningClientOrServiceWorkerOrMessagePort()
283
    : mType(eUninitialized)
284
0
  {
285
0
  }
286
287
  explicit inline OwningClientOrServiceWorkerOrMessagePort(const OwningClientOrServiceWorkerOrMessagePort& aOther)
288
    : mType(eUninitialized)
289
0
  {
290
0
    *this = aOther;
291
0
  }
292
293
  inline ~OwningClientOrServiceWorkerOrMessagePort()
294
0
  {
295
0
    Uninit();
296
0
  }
297
298
  OwningNonNull<mozilla::dom::Client>&
299
  RawSetAsClient();
300
301
  OwningNonNull<mozilla::dom::Client>&
302
  SetAsClient();
303
304
  bool
305
  TrySetToClient(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
306
307
  inline bool
308
  IsClient() const
309
0
  {
310
0
    return mType == eClient;
311
0
  }
312
313
  inline OwningNonNull<mozilla::dom::Client>&
314
  GetAsClient()
315
0
  {
316
0
    MOZ_ASSERT(IsClient(), "Wrong type!");
317
0
    return mValue.mClient.Value();
318
0
  }
319
320
  inline OwningNonNull<mozilla::dom::Client> const &
321
  GetAsClient() const
322
0
  {
323
0
    MOZ_ASSERT(IsClient(), "Wrong type!");
324
0
    return mValue.mClient.Value();
325
0
  }
326
327
  OwningNonNull<mozilla::dom::ServiceWorker>&
328
  RawSetAsServiceWorker();
329
330
  OwningNonNull<mozilla::dom::ServiceWorker>&
331
  SetAsServiceWorker();
332
333
  bool
334
  TrySetToServiceWorker(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
335
336
  inline bool
337
  IsServiceWorker() const
338
0
  {
339
0
    return mType == eServiceWorker;
340
0
  }
341
342
  inline OwningNonNull<mozilla::dom::ServiceWorker>&
343
  GetAsServiceWorker()
344
0
  {
345
0
    MOZ_ASSERT(IsServiceWorker(), "Wrong type!");
346
0
    return mValue.mServiceWorker.Value();
347
0
  }
348
349
  inline OwningNonNull<mozilla::dom::ServiceWorker> const &
350
  GetAsServiceWorker() const
351
0
  {
352
0
    MOZ_ASSERT(IsServiceWorker(), "Wrong type!");
353
0
    return mValue.mServiceWorker.Value();
354
0
  }
355
356
  OwningNonNull<mozilla::dom::MessagePort>&
357
  RawSetAsMessagePort();
358
359
  OwningNonNull<mozilla::dom::MessagePort>&
360
  SetAsMessagePort();
361
362
  bool
363
  TrySetToMessagePort(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
364
365
  inline bool
366
  IsMessagePort() const
367
0
  {
368
0
    return mType == eMessagePort;
369
0
  }
370
371
  inline OwningNonNull<mozilla::dom::MessagePort>&
372
  GetAsMessagePort()
373
0
  {
374
0
    MOZ_ASSERT(IsMessagePort(), "Wrong type!");
375
0
    return mValue.mMessagePort.Value();
376
0
  }
377
378
  inline OwningNonNull<mozilla::dom::MessagePort> const &
379
  GetAsMessagePort() const
380
0
  {
381
0
    MOZ_ASSERT(IsMessagePort(), "Wrong type!");
382
0
    return mValue.mMessagePort.Value();
383
0
  }
384
385
  void
386
  Uninit();
387
388
  bool
389
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
390
391
  void
392
  TraceUnion(JSTracer* trc);
393
394
  OwningClientOrServiceWorkerOrMessagePort&
395
  operator=(const OwningClientOrServiceWorkerOrMessagePort& aOther);
396
397
private:
398
  void
399
  DestroyClient();
400
401
  void
402
  DestroyServiceWorker();
403
404
  void
405
  DestroyMessagePort();
406
};
407
408
409
struct ExtendableMessageEventInit : public ExtendableEventInit
410
{
411
  MOZ_INIT_OUTSIDE_CTOR JS::Value mData;
412
  MOZ_INIT_OUTSIDE_CTOR nsString mLastEventId;
413
  MOZ_INIT_OUTSIDE_CTOR nsString mOrigin;
414
  MOZ_INIT_OUTSIDE_CTOR Sequence<OwningNonNull<mozilla::dom::MessagePort>> mPorts;
415
  MOZ_INIT_OUTSIDE_CTOR Nullable<OwningClientOrServiceWorkerOrMessagePort > mSource;
416
417
  ExtendableMessageEventInit();
418
419
  explicit inline ExtendableMessageEventInit(const FastDictionaryInitializer& )
420
    : ExtendableEventInit(FastDictionaryInitializer()),
421
      mData(JS::UndefinedValue())
422
0
  {
423
0
    // Do nothing here; this is used by our "Fast" subclass
424
0
  }
425
426
private:
427
  ExtendableMessageEventInit(const ExtendableMessageEventInit&) = delete;
428
  ExtendableMessageEventInit& operator=(const ExtendableMessageEventInit&) = delete;
429
430
  static bool
431
  InitIds(JSContext* cx, ExtendableMessageEventInitAtoms* atomsCache);
432
433
public:
434
  bool
435
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
436
437
  bool
438
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
439
440
  void
441
  TraceDictionary(JSTracer* trc);
442
443
  inline void
444
  TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
445
0
  {
446
0
    ImplCycleCollectionTraverse(aCallback, mPorts, "mPorts", aFlags);
447
0
    ImplCycleCollectionTraverse(aCallback, mSource, "mSource", aFlags);
448
0
  }
449
450
  inline void
451
  UnlinkForCC()
452
0
  {
453
0
    ImplCycleCollectionUnlink(mPorts);
454
0
    ImplCycleCollectionUnlink(mSource);
455
0
  }
456
};
457
458
namespace binding_detail {
459
struct FastExtendableMessageEventInit : public ExtendableMessageEventInit
460
{
461
  inline FastExtendableMessageEventInit()
462
    : ExtendableMessageEventInit(FastDictionaryInitializer())
463
0
  {
464
0
    // Doesn't matter what int we pass to the parent constructor
465
0
  }
466
};
467
} // namespace binding_detail
468
469
470
namespace ExtendableMessageEvent_Binding {
471
472
  typedef mozilla::dom::ExtendableMessageEvent NativeType;
473
474
  bool
475
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
476
477
  const JSClass*
478
  GetJSClass();
479
480
  bool
481
  Wrap(JSContext* aCx, mozilla::dom::ExtendableMessageEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
482
483
  template <class T>
484
  inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
485
0
  {
486
0
    JS::Rooted<JSObject*> reflector(aCx);
487
0
    return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
488
0
  }
489
490
  void
491
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
492
493
  inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
494
0
  {
495
0
    /* Get the interface prototype object for this class.  This will create the
496
0
       object as needed. */
497
0
    return GetPerInterfaceObjectHandle(aCx, prototypes::id::ExtendableMessageEvent,
498
0
                                       &CreateInterfaceObjects,
499
0
                                       /* aDefineOnGlobal = */ true);
500
0
501
0
  }
502
503
  inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
504
0
  {
505
0
    /* Get the interface object for this class.  This will create the object as
506
0
       needed. */
507
0
508
0
    return GetPerInterfaceObjectHandle(aCx, constructors::id::ExtendableMessageEvent,
509
0
                                       &CreateInterfaceObjects,
510
0
                                       aDefineOnGlobal);
511
0
  }
512
513
  JSObject*
514
  GetConstructorObject(JSContext* aCx);
515
516
} // namespace ExtendableMessageEvent_Binding
517
518
519
520
} // namespace dom
521
} // namespace mozilla
522
523
#endif // mozilla_dom_ExtendableMessageEventBinding_h