Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/InstallTriggerBinding.h
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM InstallTrigger.webidl BY Codegen.py - DO NOT EDIT */
2
3
#ifndef mozilla_dom_InstallTriggerBinding_h
4
#define mozilla_dom_InstallTriggerBinding_h
5
6
#include "GeckoProfiler.h"
7
#include "js/RootingAPI.h"
8
#include "jspubtd.h"
9
#include "mozilla/ErrorResult.h"
10
#include "mozilla/dom/BindingDeclarations.h"
11
#include "mozilla/dom/CallbackFunction.h"
12
#include "mozilla/dom/CallbackInterface.h"
13
#include "mozilla/dom/FakeString.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrototypeList.h"
16
#include "mozilla/dom/Record.h"
17
#include "mozilla/dom/ToJSValue.h"
18
#include "mozilla/dom/UnionMember.h"
19
#include "nsWeakReference.h"
20
21
namespace mozilla {
22
namespace dom {
23
24
class InstallTriggerCallback;
25
struct InstallTriggerDataAtoms;
26
class InstallTriggerImpl;
27
struct InstallTriggerImplAtoms;
28
struct NativePropertyHooks;
29
class OwningStringOrInstallTriggerData;
30
class ProtoAndIfaceCache;
31
class StringOrInstallTriggerData;
32
33
} // namespace dom
34
} // namespace mozilla
35
36
namespace mozilla {
37
namespace dom {
38
39
struct InstallTriggerData : public DictionaryBase
40
{
41
  MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mHash;
42
  MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mIconURL;
43
  MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mURL;
44
45
  InstallTriggerData();
46
47
  explicit inline InstallTriggerData(const FastDictionaryInitializer& )
48
0
  {
49
0
    // Do nothing here; this is used by our "Fast" subclass
50
0
  }
51
52
  explicit inline InstallTriggerData(const InstallTriggerData& aOther)
53
0
  {
54
0
    *this = aOther;
55
0
  }
56
57
  bool
58
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
59
60
  bool
61
  Init(const nsAString& aJSON);
62
63
  bool
64
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
65
66
  bool
67
  ToJSON(nsAString& aJSON) const;
68
69
  void
70
  TraceDictionary(JSTracer* trc);
71
72
  InstallTriggerData&
73
  operator=(const InstallTriggerData& aOther);
74
75
private:
76
  static bool
77
  InitIds(JSContext* cx, InstallTriggerDataAtoms* atomsCache);
78
};
79
80
namespace binding_detail {
81
struct FastInstallTriggerData : public InstallTriggerData
82
{
83
  inline FastInstallTriggerData()
84
    : InstallTriggerData(FastDictionaryInitializer())
85
0
  {
86
0
    // Doesn't matter what int we pass to the parent constructor
87
0
  }
88
};
89
} // namespace binding_detail
90
91
92
class StringOrInstallTriggerData
93
{
94
  friend class StringOrInstallTriggerDataArgument;
95
  enum Type
96
  {
97
    eUninitialized,
98
    eString,
99
    eInstallTriggerData
100
  };
101
102
  union Value
103
  {
104
    UnionMember<binding_detail::FakeString > mString;
105
    UnionMember<binding_detail::FastInstallTriggerData > mInstallTriggerData;
106
107
  };
108
109
  Type mType;
110
  Value mValue;
111
112
  StringOrInstallTriggerData(const StringOrInstallTriggerData&) = delete;
113
  StringOrInstallTriggerData& operator=(const StringOrInstallTriggerData&) = delete;
114
public:
115
  explicit inline StringOrInstallTriggerData()
116
    : mType(eUninitialized)
117
0
  {
118
0
  }
119
120
  inline ~StringOrInstallTriggerData()
121
0
  {
122
0
    Uninit();
123
0
  }
124
125
  inline binding_detail::FakeString&
126
  RawSetAsString()
127
0
  {
128
0
    if (mType == eString) {
129
0
      return mValue.mString.Value();
130
0
    }
131
0
    MOZ_ASSERT(mType == eUninitialized);
132
0
    mType = eString;
133
0
    return mValue.mString.SetValue();
134
0
  }
135
136
  inline binding_detail::FakeString&
137
  SetAsString()
138
0
  {
139
0
    if (mType == eString) {
140
0
      return mValue.mString.Value();
141
0
    }
142
0
    Uninit();
143
0
    mType = eString;
144
0
    return mValue.mString.SetValue();
145
0
  }
146
147
  inline bool
148
  IsString() const
149
0
  {
150
0
    return mType == eString;
151
0
  }
152
153
  inline binding_detail::FakeString&
154
  GetAsString()
155
0
  {
156
0
    MOZ_ASSERT(IsString(), "Wrong type!");
157
0
    return mValue.mString.Value();
158
0
  }
159
160
  inline const nsAString&
161
  GetAsString() const
162
0
  {
163
0
    MOZ_ASSERT(IsString(), "Wrong type!");
164
0
    return mValue.mString.Value();
165
0
  }
166
167
  inline binding_detail::FastInstallTriggerData&
168
  RawSetAsInstallTriggerData()
169
0
  {
170
0
    if (mType == eInstallTriggerData) {
171
0
      return mValue.mInstallTriggerData.Value();
172
0
    }
173
0
    MOZ_ASSERT(mType == eUninitialized);
174
0
    mType = eInstallTriggerData;
175
0
    return mValue.mInstallTriggerData.SetValue();
176
0
  }
177
178
  inline binding_detail::FastInstallTriggerData&
179
  SetAsInstallTriggerData()
180
0
  {
181
0
    if (mType == eInstallTriggerData) {
182
0
      return mValue.mInstallTriggerData.Value();
183
0
    }
184
0
    Uninit();
185
0
    mType = eInstallTriggerData;
186
0
    return mValue.mInstallTriggerData.SetValue();
187
0
  }
188
189
  inline bool
190
  IsInstallTriggerData() const
191
0
  {
192
0
    return mType == eInstallTriggerData;
193
0
  }
194
195
  inline binding_detail::FastInstallTriggerData&
196
  GetAsInstallTriggerData()
197
0
  {
198
0
    MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
199
0
    return mValue.mInstallTriggerData.Value();
200
0
  }
201
202
  inline const InstallTriggerData&
203
  GetAsInstallTriggerData() const
204
0
  {
205
0
    MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
206
0
    return mValue.mInstallTriggerData.Value();
207
0
  }
208
209
  inline void
210
  Uninit()
211
0
  {
212
0
    switch (mType) {
213
0
      case eUninitialized: {
214
0
        break;
215
0
      }
216
0
      case eString: {
217
0
        DestroyString();
218
0
        break;
219
0
      }
220
0
      case eInstallTriggerData: {
221
0
        DestroyInstallTriggerData();
222
0
        break;
223
0
      }
224
0
    }
225
0
  }
226
227
  bool
228
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
229
230
private:
231
  inline void
232
  DestroyString()
233
0
  {
234
0
    MOZ_ASSERT(IsString(), "Wrong type!");
235
0
    mValue.mString.Destroy();
236
0
    mType = eUninitialized;
237
0
  }
238
239
  inline void
240
  DestroyInstallTriggerData()
241
0
  {
242
0
    MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
243
0
    mValue.mInstallTriggerData.Destroy();
244
0
    mType = eUninitialized;
245
0
  }
246
};
247
248
249
class OwningStringOrInstallTriggerData : public AllOwningUnionBase
250
{
251
  friend void ImplCycleCollectionUnlink(OwningStringOrInstallTriggerData& aUnion);
252
  enum Type
253
  {
254
    eUninitialized,
255
    eString,
256
    eInstallTriggerData
257
  };
258
259
  union Value
260
  {
261
    UnionMember<nsString > mString;
262
    UnionMember<InstallTriggerData > mInstallTriggerData;
263
264
  };
265
266
  Type mType;
267
  Value mValue;
268
269
public:
270
  explicit inline OwningStringOrInstallTriggerData()
271
    : mType(eUninitialized)
272
0
  {
273
0
  }
274
275
  explicit inline OwningStringOrInstallTriggerData(const OwningStringOrInstallTriggerData& aOther)
276
    : mType(eUninitialized)
277
0
  {
278
0
    *this = aOther;
279
0
  }
280
281
  inline ~OwningStringOrInstallTriggerData()
282
0
  {
283
0
    Uninit();
284
0
  }
285
286
  nsString&
287
  RawSetAsString();
288
289
  nsString&
290
  SetAsString();
291
292
  bool
293
  TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
294
295
  inline void
296
  SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
297
0
  {
298
0
    RawSetAsString().Assign(aData, aLength);
299
0
  }
300
301
  inline bool
302
  IsString() const
303
0
  {
304
0
    return mType == eString;
305
0
  }
306
307
  inline nsString&
308
  GetAsString()
309
0
  {
310
0
    MOZ_ASSERT(IsString(), "Wrong type!");
311
0
    return mValue.mString.Value();
312
0
  }
313
314
  inline nsString const &
315
  GetAsString() const
316
0
  {
317
0
    MOZ_ASSERT(IsString(), "Wrong type!");
318
0
    return mValue.mString.Value();
319
0
  }
320
321
  InstallTriggerData&
322
  RawSetAsInstallTriggerData();
323
324
  InstallTriggerData&
325
  SetAsInstallTriggerData();
326
327
  bool
328
  TrySetToInstallTriggerData(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
329
330
  inline bool
331
  IsInstallTriggerData() const
332
0
  {
333
0
    return mType == eInstallTriggerData;
334
0
  }
335
336
  inline InstallTriggerData&
337
  GetAsInstallTriggerData()
338
0
  {
339
0
    MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
340
0
    return mValue.mInstallTriggerData.Value();
341
0
  }
342
343
  inline InstallTriggerData const &
344
  GetAsInstallTriggerData() const
345
0
  {
346
0
    MOZ_ASSERT(IsInstallTriggerData(), "Wrong type!");
347
0
    return mValue.mInstallTriggerData.Value();
348
0
  }
349
350
  void
351
  Uninit();
352
353
  bool
354
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
355
356
  void
357
  TraceUnion(JSTracer* trc);
358
359
  OwningStringOrInstallTriggerData&
360
  operator=(const OwningStringOrInstallTriggerData& aOther);
361
362
private:
363
  void
364
  DestroyString();
365
366
  void
367
  DestroyInstallTriggerData();
368
};
369
370
371
class InstallTriggerCallback : public CallbackFunction
372
{
373
public:
374
  explicit inline InstallTriggerCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
375
    : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
376
0
  {
377
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
378
0
  }
379
380
  explicit inline InstallTriggerCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
381
    : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
382
0
  {
383
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
384
0
  }
385
386
  explicit inline InstallTriggerCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
387
    : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
388
0
  {
389
0
    MOZ_ASSERT(JS::IsCallable(mCallback));
390
0
  }
391
392
  explicit inline InstallTriggerCallback(CallbackFunction* aOther)
393
    : CallbackFunction(aOther)
394
0
  {
395
0
  }
396
397
  template <typename T>
398
  inline void
399
  Call(const T& thisVal, const nsAString& url, int16_t status, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
400
  {
401
    MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
402
    if (!aExecutionReason) {
403
      aExecutionReason = "InstallTriggerCallback";
404
    }
405
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
406
    if (!s.GetContext()) {
407
      MOZ_ASSERT(aRv.Failed());
408
      return;
409
    }
410
    JS::Rooted<JS::Value> thisValJS(s.GetContext());
411
    if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
412
      aRv.Throw(NS_ERROR_FAILURE);
413
      return;
414
    }
415
    return Call(s.GetContext(), thisValJS, url, status, aRv);
416
  }
417
418
  inline void
419
  Call(const nsAString& url, int16_t status, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
420
0
  {
421
0
    MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
422
0
    if (!aExecutionReason) {
423
0
      aExecutionReason = "InstallTriggerCallback";
424
0
    }
425
0
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
426
0
    if (!s.GetContext()) {
427
0
      MOZ_ASSERT(aRv.Failed());
428
0
      return;
429
0
    }
430
0
    return Call(s.GetContext(), JS::UndefinedHandleValue, url, status, aRv);
431
0
  }
432
433
  template <typename T>
434
  inline void
435
  Call(const T& thisVal, const nsAString& url, int16_t status, const char* aExecutionReason = nullptr)
436
  {
437
    return Call(thisVal, url, status, IgnoreErrors(), aExecutionReason);
438
  }
439
440
  inline void
441
  Call(const nsAString& url, int16_t status, const char* aExecutionReason = nullptr)
442
0
  {
443
0
    return Call(url, status, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
444
0
  }
445
446
  inline bool
447
  operator==(const InstallTriggerCallback& aOther) const
448
0
  {
449
0
    return CallbackFunction::operator==(aOther);
450
0
  }
451
452
private:
453
  void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& url, int16_t status, ErrorResult& aRv);
454
};
455
456
457
namespace binding_detail {
458
class FastInstallTriggerCallback : public InstallTriggerCallback
459
{
460
public:
461
  explicit inline FastInstallTriggerCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
462
    : InstallTriggerCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
463
0
  {
464
0
  }
465
466
  inline void
467
  Trace(JSTracer* aTracer)
468
0
  {
469
0
    InstallTriggerCallback::Trace(aTracer);
470
0
  }
471
472
  inline void
473
  FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
474
0
  {
475
0
    InstallTriggerCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
476
0
  }
477
};
478
} // namespace binding_detail
479
480
481
namespace InstallTriggerImpl_Binding {
482
483
  typedef mozilla::dom::InstallTriggerImpl NativeType;
484
485
  static const uint16_t SKIN = 1;
486
  static const uint16_t LOCALE = 2;
487
  static const uint16_t CONTENT = 4;
488
  static const uint16_t PACKAGE = 7;
489
  bool
490
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
491
492
  const JSClass*
493
  GetJSClass();
494
495
  bool
496
  Wrap(JSContext* aCx, mozilla::dom::InstallTriggerImpl* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
497
498
  template <class T>
499
  inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
500
0
  {
501
0
    JS::Rooted<JSObject*> reflector(aCx);
502
0
    return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
503
0
  }
504
505
  // We declare this as an array so that retrieving a pointer to this
506
  // binding's property hooks only requires compile/link-time resolvable
507
  // address arithmetic.  Declaring it as a pointer instead would require
508
  // doing a run-time load to fetch a pointer to this binding's property
509
  // hooks.  And then structures which embedded a pointer to this structure
510
  // would require a run-time load for proper initialization, which would
511
  // then induce static constructors.  Lots of static constructors.
512
  extern const NativePropertyHooks sNativePropertyHooks[];
513
514
  void
515
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
516
517
  inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
518
0
  {
519
0
    /* Get the interface prototype object for this class.  This will create the
520
0
       object as needed. */
521
0
    return GetPerInterfaceObjectHandle(aCx, prototypes::id::InstallTriggerImpl,
522
0
                                       &CreateInterfaceObjects,
523
0
                                       /* aDefineOnGlobal = */ true);
524
0
525
0
  }
526
527
  inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
528
0
  {
529
0
    /* Get the interface object for this class.  This will create the object as
530
0
       needed. */
531
0
532
0
    return GetPerInterfaceObjectHandle(aCx, constructors::id::InstallTriggerImpl,
533
0
                                       &CreateInterfaceObjects,
534
0
                                       aDefineOnGlobal);
535
0
  }
536
537
  JSObject*
538
  GetConstructorObject(JSContext* aCx);
539
540
} // namespace InstallTriggerImpl_Binding
541
542
543
544
class InstallTriggerImplJSImpl : public CallbackInterface
545
{
546
public:
547
  explicit inline InstallTriggerImplJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
548
    : CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
549
0
  {
550
0
  }
551
552
  explicit inline InstallTriggerImplJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
553
    : CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor())
554
0
  {
555
0
  }
556
557
  explicit inline InstallTriggerImplJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
558
    : CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
559
0
  {
560
0
  }
561
562
  bool Enabled(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
563
564
  bool UpdateEnabled(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
565
566
  bool Install(const Record<nsString, OwningStringOrInstallTriggerData>& installs, const Optional<OwningNonNull<InstallTriggerCallback>>& callback, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
567
568
  bool InstallChrome(uint16_t type, const nsAString& url, const nsAString& skin, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
569
570
  bool StartSoftwareUpdate(const nsAString& url, const Optional<uint16_t>& flags, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
571
572
  inline bool
573
  operator==(const InstallTriggerImplJSImpl& aOther) const
574
0
  {
575
0
    return CallbackInterface::operator==(aOther);
576
0
  }
577
578
private:
579
  static bool
580
  InitIds(JSContext* cx, InstallTriggerImplAtoms* atomsCache);
581
};
582
583
584
class InstallTriggerImpl final : public nsSupportsWeakReference,
585
                                 public nsWrapperCache
586
{
587
public:
588
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
589
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(InstallTriggerImpl)
590
591
private:
592
  RefPtr<InstallTriggerImplJSImpl> mImpl;
593
  nsCOMPtr<nsIGlobalObject> mParent;
594
595
public:
596
  InstallTriggerImpl(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent);
597
598
private:
599
  ~InstallTriggerImpl();
600
601
public:
602
  nsISupports* GetParentObject() const;
603
604
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
605
606
  bool Enabled(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
607
608
  bool UpdateEnabled(ErrorResult& aRv, JS::Realm* aRealm = nullptr);
609
610
  bool Install(const Record<nsString, OwningStringOrInstallTriggerData>& installs, const Optional<OwningNonNull<InstallTriggerCallback>>& callback, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
611
612
  bool InstallChrome(uint16_t type, const nsAString& url, const nsAString& skin, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
613
614
  bool StartSoftwareUpdate(const nsAString& url, const Optional<uint16_t>& flags, ErrorResult& aRv, JS::Realm* aRealm = nullptr);
615
616
  static bool
617
  _Create(JSContext* cx, unsigned argc, JS::Value* vp);
618
};
619
620
621
} // namespace dom
622
} // namespace mozilla
623
624
#endif // mozilla_dom_InstallTriggerBinding_h