Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/IDBFileHandleBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM IDBFileHandle.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "EventHandlerBinding.h"
5
#include "EventTargetBinding.h"
6
#include "IDBFileHandleBinding.h"
7
#include "WrapperFactory.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/Blob.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/IDBFileHandle.h"
13
#include "mozilla/dom/IDBFileRequest.h"
14
#include "mozilla/dom/IDBMutableFile.h"
15
#include "mozilla/dom/NonRefcountedDOMObject.h"
16
#include "mozilla/dom/Nullable.h"
17
#include "mozilla/dom/PrimitiveConversions.h"
18
#include "mozilla/dom/ScriptSettings.h"
19
#include "mozilla/dom/SimpleGlobalObject.h"
20
#include "mozilla/dom/UnionConversions.h"
21
#include "mozilla/dom/XrayExpandoClass.h"
22
23
namespace mozilla {
24
namespace dom {
25
26
namespace binding_detail {}; // Just to make sure it's known as a namespace
27
using namespace mozilla::dom::binding_detail;
28
29
30
void
31
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningStringOrArrayBufferOrArrayBufferViewOrBlob& aUnion, const char* aName, uint32_t aFlags)
32
0
{
33
0
  if (aUnion.IsBlob()) {
34
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsBlob(), "mBlob", aFlags);
35
0
  }
36
0
}
37
38
39
void
40
ImplCycleCollectionUnlink(OwningStringOrArrayBufferOrArrayBufferViewOrBlob& aUnion)
41
0
{
42
0
  aUnion.Uninit();
43
0
}
44
45
46
47
IDBFileMetadataParameters::IDBFileMetadataParameters()
48
0
{
49
0
  // Safe to pass a null context if we pass a null value
50
0
  Init(nullptr, JS::NullHandleValue);
51
0
}
52
53
54
55
bool
56
IDBFileMetadataParameters::InitIds(JSContext* cx, IDBFileMetadataParametersAtoms* atomsCache)
57
0
{
58
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
59
0
60
0
  // Initialize these in reverse order so that any failure leaves the first one
61
0
  // uninitialized.
62
0
  if (!atomsCache->size_id.init(cx, "size") ||
63
0
      !atomsCache->lastModified_id.init(cx, "lastModified")) {
64
0
    return false;
65
0
  }
66
0
  return true;
67
0
}
68
69
bool
70
IDBFileMetadataParameters::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
71
0
{
72
0
  // Passing a null JSContext is OK only if we're initing from null,
73
0
  // Since in that case we will not have to do any property gets
74
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
75
0
  // checkers by static analysis tools
76
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
77
0
  IDBFileMetadataParametersAtoms* atomsCache = nullptr;
78
0
  if (cx) {
79
0
    atomsCache = GetAtomCache<IDBFileMetadataParametersAtoms>(cx);
80
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
81
0
      return false;
82
0
    }
83
0
  }
84
0
85
0
  if (!IsConvertibleToDictionary(val)) {
86
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
87
0
  }
88
0
89
0
  bool isNull = val.isNullOrUndefined();
90
0
  // We only need these if !isNull, in which case we have |cx|.
91
0
  Maybe<JS::Rooted<JSObject *> > object;
92
0
  Maybe<JS::Rooted<JS::Value> > temp;
93
0
  if (!isNull) {
94
0
    MOZ_ASSERT(cx);
95
0
    object.emplace(cx, &val.toObject());
96
0
    temp.emplace(cx);
97
0
  }
98
0
  if (!isNull) {
99
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->lastModified_id, temp.ptr())) {
100
0
      return false;
101
0
    }
102
0
  }
103
0
  if (!isNull && !temp->isUndefined()) {
104
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mLastModified)) {
105
0
      return false;
106
0
    }
107
0
  } else {
108
0
    mLastModified = true;
109
0
  }
110
0
  mIsAnyMemberPresent = true;
111
0
112
0
  if (!isNull) {
113
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->size_id, temp.ptr())) {
114
0
      return false;
115
0
    }
116
0
  }
117
0
  if (!isNull && !temp->isUndefined()) {
118
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mSize)) {
119
0
      return false;
120
0
    }
121
0
  } else {
122
0
    mSize = true;
123
0
  }
124
0
  mIsAnyMemberPresent = true;
125
0
  return true;
126
0
}
127
128
bool
129
IDBFileMetadataParameters::Init(const nsAString& aJSON)
130
0
{
131
0
  AutoJSAPI jsapi;
132
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
133
0
  if (!cleanGlobal) {
134
0
    return false;
135
0
  }
136
0
  if (!jsapi.Init(cleanGlobal)) {
137
0
    return false;
138
0
  }
139
0
  JSContext* cx = jsapi.cx();
140
0
  JS::Rooted<JS::Value> json(cx);
141
0
  bool ok = ParseJSON(cx, aJSON, &json);
142
0
  NS_ENSURE_TRUE(ok, false);
143
0
  return Init(cx, json);
144
0
}
145
146
bool
147
IDBFileMetadataParameters::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
148
0
{
149
0
  IDBFileMetadataParametersAtoms* atomsCache = GetAtomCache<IDBFileMetadataParametersAtoms>(cx);
150
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
151
0
    return false;
152
0
  }
153
0
154
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
155
0
  if (!obj) {
156
0
    return false;
157
0
  }
158
0
  rval.set(JS::ObjectValue(*obj));
159
0
160
0
  do {
161
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
162
0
    JS::Rooted<JS::Value> temp(cx);
163
0
    bool const & currentValue = mLastModified;
164
0
    temp.setBoolean(currentValue);
165
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->lastModified_id, temp, JSPROP_ENUMERATE)) {
166
0
      return false;
167
0
    }
168
0
    break;
169
0
  } while(false);
170
0
171
0
  do {
172
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
173
0
    JS::Rooted<JS::Value> temp(cx);
174
0
    bool const & currentValue = mSize;
175
0
    temp.setBoolean(currentValue);
176
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->size_id, temp, JSPROP_ENUMERATE)) {
177
0
      return false;
178
0
    }
179
0
    break;
180
0
  } while(false);
181
0
182
0
  return true;
183
0
}
184
185
bool
186
IDBFileMetadataParameters::ToJSON(nsAString& aJSON) const
187
0
{
188
0
  AutoJSAPI jsapi;
189
0
  jsapi.Init();
190
0
  JSContext *cx = jsapi.cx();
191
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
192
0
  // because we'll only be creating objects, in ways that have no
193
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
194
0
  // which likewise guarantees no side-effects for the sorts of
195
0
  // things we will pass it.
196
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
197
0
  JS::Rooted<JS::Value> val(cx);
198
0
  if (!ToObjectInternal(cx, &val)) {
199
0
    return false;
200
0
  }
201
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
202
0
  return StringifyToJSON(cx, obj, aJSON);
203
0
}
204
205
void
206
IDBFileMetadataParameters::TraceDictionary(JSTracer* trc)
207
0
{
208
0
}
209
210
IDBFileMetadataParameters&
211
IDBFileMetadataParameters::operator=(const IDBFileMetadataParameters& aOther)
212
0
{
213
0
  DictionaryBase::operator=(aOther);
214
0
  mLastModified = aOther.mLastModified;
215
0
  mSize = aOther.mSize;
216
0
  return *this;
217
0
}
218
219
namespace binding_detail {
220
} // namespace binding_detail
221
222
223
bool
224
StringOrArrayBufferOrArrayBufferViewOrBlob::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
225
0
{
226
0
  switch (mType) {
227
0
    case eUninitialized: {
228
0
      return false;
229
0
      break;
230
0
    }
231
0
    case eString: {
232
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
233
0
        return false;
234
0
      }
235
0
      return true;
236
0
      break;
237
0
    }
238
0
    case eArrayBuffer: {
239
0
      rval.setObject(*mValue.mArrayBuffer.Value().Obj());
240
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
241
0
        return false;
242
0
      }
243
0
      return true;
244
0
      break;
245
0
    }
246
0
    case eArrayBufferView: {
247
0
      rval.setObject(*mValue.mArrayBufferView.Value().Obj());
248
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
249
0
        return false;
250
0
      }
251
0
      return true;
252
0
      break;
253
0
    }
254
0
    case eBlob: {
255
0
      if (!GetOrCreateDOMReflector(cx, mValue.mBlob.Value(), rval)) {
256
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
257
0
        return false;
258
0
      }
259
0
      return true;
260
0
      break;
261
0
    }
262
0
    default: {
263
0
      return false;
264
0
      break;
265
0
    }
266
0
  }
267
0
268
0
  return false;
269
0
}
270
271
272
nsString&
273
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::RawSetAsString()
274
0
{
275
0
  if (mType == eString) {
276
0
    return mValue.mString.Value();
277
0
  }
278
0
  MOZ_ASSERT(mType == eUninitialized);
279
0
  mType = eString;
280
0
  return mValue.mString.SetValue();
281
0
}
282
283
nsString&
284
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::SetAsString()
285
0
{
286
0
  if (mType == eString) {
287
0
    return mValue.mString.Value();
288
0
  }
289
0
  Uninit();
290
0
  mType = eString;
291
0
  return mValue.mString.SetValue();
292
0
}
293
294
bool
295
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
296
0
{
297
0
  tryNext = false;
298
0
  { // scope for memberSlot
299
0
    nsString& memberSlot = RawSetAsString();
300
0
    if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
301
0
      return false;
302
0
    }
303
0
  }
304
0
  return true;
305
0
}
306
307
308
void
309
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::DestroyString()
310
0
{
311
0
  MOZ_ASSERT(IsString(), "Wrong type!");
312
0
  mValue.mString.Destroy();
313
0
  mType = eUninitialized;
314
0
}
315
316
317
318
319
ArrayBuffer&
320
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::RawSetAsArrayBuffer()
321
0
{
322
0
  if (mType == eArrayBuffer) {
323
0
    return mValue.mArrayBuffer.Value();
324
0
  }
325
0
  MOZ_ASSERT(mType == eUninitialized);
326
0
  mType = eArrayBuffer;
327
0
  return mValue.mArrayBuffer.SetValue();
328
0
}
329
330
ArrayBuffer&
331
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::SetAsArrayBuffer()
332
0
{
333
0
  if (mType == eArrayBuffer) {
334
0
    return mValue.mArrayBuffer.Value();
335
0
  }
336
0
  Uninit();
337
0
  mType = eArrayBuffer;
338
0
  return mValue.mArrayBuffer.SetValue();
339
0
}
340
341
bool
342
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
343
0
{
344
0
  tryNext = false;
345
0
  { // scope for memberSlot
346
0
    ArrayBuffer& memberSlot = RawSetAsArrayBuffer();
347
0
    if (!memberSlot.Init(&value.toObject())) {
348
0
      DestroyArrayBuffer();
349
0
      tryNext = true;
350
0
      return true;
351
0
    }
352
0
  }
353
0
  return true;
354
0
}
355
356
void
357
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::DestroyArrayBuffer()
358
0
{
359
0
  MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
360
0
  mValue.mArrayBuffer.Destroy();
361
0
  mType = eUninitialized;
362
0
}
363
364
365
366
367
ArrayBufferView&
368
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::RawSetAsArrayBufferView()
369
0
{
370
0
  if (mType == eArrayBufferView) {
371
0
    return mValue.mArrayBufferView.Value();
372
0
  }
373
0
  MOZ_ASSERT(mType == eUninitialized);
374
0
  mType = eArrayBufferView;
375
0
  return mValue.mArrayBufferView.SetValue();
376
0
}
377
378
ArrayBufferView&
379
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::SetAsArrayBufferView()
380
0
{
381
0
  if (mType == eArrayBufferView) {
382
0
    return mValue.mArrayBufferView.Value();
383
0
  }
384
0
  Uninit();
385
0
  mType = eArrayBufferView;
386
0
  return mValue.mArrayBufferView.SetValue();
387
0
}
388
389
bool
390
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
391
0
{
392
0
  tryNext = false;
393
0
  { // scope for memberSlot
394
0
    ArrayBufferView& memberSlot = RawSetAsArrayBufferView();
395
0
    if (!memberSlot.Init(&value.toObject())) {
396
0
      DestroyArrayBufferView();
397
0
      tryNext = true;
398
0
      return true;
399
0
    }
400
0
  }
401
0
  return true;
402
0
}
403
404
void
405
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::DestroyArrayBufferView()
406
0
{
407
0
  MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
408
0
  mValue.mArrayBufferView.Destroy();
409
0
  mType = eUninitialized;
410
0
}
411
412
413
414
415
OwningNonNull<mozilla::dom::Blob>&
416
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::RawSetAsBlob()
417
0
{
418
0
  if (mType == eBlob) {
419
0
    return mValue.mBlob.Value();
420
0
  }
421
0
  MOZ_ASSERT(mType == eUninitialized);
422
0
  mType = eBlob;
423
0
  return mValue.mBlob.SetValue();
424
0
}
425
426
OwningNonNull<mozilla::dom::Blob>&
427
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::SetAsBlob()
428
0
{
429
0
  if (mType == eBlob) {
430
0
    return mValue.mBlob.Value();
431
0
  }
432
0
  Uninit();
433
0
  mType = eBlob;
434
0
  return mValue.mBlob.SetValue();
435
0
}
436
437
bool
438
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::TrySetToBlob(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
439
0
{
440
0
  tryNext = false;
441
0
  { // scope for memberSlot
442
0
    OwningNonNull<mozilla::dom::Blob>& memberSlot = RawSetAsBlob();
443
0
    static_assert(IsRefcounted<mozilla::dom::Blob>::value, "We can only store refcounted classes.");{
444
0
      nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(value, memberSlot);
445
0
      if (NS_FAILED(rv)) {
446
0
        DestroyBlob();
447
0
        tryNext = true;
448
0
        return true;
449
0
      }
450
0
    }
451
0
  }
452
0
  return true;
453
0
}
454
455
void
456
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::DestroyBlob()
457
0
{
458
0
  MOZ_ASSERT(IsBlob(), "Wrong type!");
459
0
  mValue.mBlob.Destroy();
460
0
  mType = eUninitialized;
461
0
}
462
463
464
465
466
void
467
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::Uninit()
468
{
469
  switch (mType) {
470
    case eUninitialized: {
471
      break;
472
    }
473
    case eString: {
474
      DestroyString();
475
      break;
476
    }
477
    case eArrayBuffer: {
478
      DestroyArrayBuffer();
479
      break;
480
    }
481
    case eArrayBufferView: {
482
      DestroyArrayBufferView();
483
      break;
484
    }
485
    case eBlob: {
486
      DestroyBlob();
487
      break;
488
    }
489
  }
490
}
491
492
bool
493
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
494
0
{
495
0
  switch (mType) {
496
0
    case eUninitialized: {
497
0
      return false;
498
0
      break;
499
0
    }
500
0
    case eString: {
501
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
502
0
        return false;
503
0
      }
504
0
      return true;
505
0
      break;
506
0
    }
507
0
    case eArrayBuffer: {
508
0
      rval.setObject(*mValue.mArrayBuffer.Value().Obj());
509
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
510
0
        return false;
511
0
      }
512
0
      return true;
513
0
      break;
514
0
    }
515
0
    case eArrayBufferView: {
516
0
      rval.setObject(*mValue.mArrayBufferView.Value().Obj());
517
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
518
0
        return false;
519
0
      }
520
0
      return true;
521
0
      break;
522
0
    }
523
0
    case eBlob: {
524
0
      if (!GetOrCreateDOMReflector(cx, mValue.mBlob.Value(), rval)) {
525
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
526
0
        return false;
527
0
      }
528
0
      return true;
529
0
      break;
530
0
    }
531
0
    default: {
532
0
      return false;
533
0
      break;
534
0
    }
535
0
  }
536
0
537
0
  return false;
538
0
}
539
540
void
541
OwningStringOrArrayBufferOrArrayBufferViewOrBlob::TraceUnion(JSTracer* trc)
542
{
543
  switch (mType) {
544
    case eArrayBuffer: {
545
      mValue.mArrayBuffer.Value().TraceSelf(trc);
546
      break;
547
    }
548
    case eArrayBufferView: {
549
      mValue.mArrayBufferView.Value().TraceSelf(trc);
550
      break;
551
    }
552
    default: {
553
      break;
554
    }
555
  }
556
}
557
558
559
namespace IDBFileHandle_Binding {
560
561
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
562
              "Can't inherit from an interface with a different ownership model.");
563
564
MOZ_CAN_RUN_SCRIPT static bool
565
get_mutableFile(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
566
0
{
567
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.mutableFile", DOM, cx);
568
0
569
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBMutableFile>(self->GetMutableFile()));
570
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
571
0
  if (!result) {
572
0
    args.rval().setNull();
573
0
    return true;
574
0
  }
575
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
576
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
577
0
    return false;
578
0
  }
579
0
  return true;
580
0
}
581
582
static const JSJitInfo mutableFile_getterinfo = {
583
  { (JSJitGetterOp)get_mutableFile },
584
  { prototypes::id::IDBFileHandle },
585
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
586
  JSJitInfo::Getter,
587
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
588
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
589
  false,  /* isInfallible. False in setters. */
590
  false,  /* isMovable.  Not relevant for setters. */
591
  false, /* isEliminatable.  Not relevant for setters. */
592
  false, /* isAlwaysInSlot.  Only relevant for getters. */
593
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
594
  false,  /* isTypedMethod.  Only relevant for methods. */
595
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
596
};
597
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
598
static_assert(0 < 1, "There is no slot for us");
599
600
MOZ_CAN_RUN_SCRIPT static bool
601
get_fileHandle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
602
0
{
603
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.fileHandle", DOM, cx);
604
0
605
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBMutableFile>(self->GetFileHandle()));
606
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
607
0
  if (!result) {
608
0
    args.rval().setNull();
609
0
    return true;
610
0
  }
611
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
612
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
613
0
    return false;
614
0
  }
615
0
  return true;
616
0
}
617
618
static const JSJitInfo fileHandle_getterinfo = {
619
  { (JSJitGetterOp)get_fileHandle },
620
  { prototypes::id::IDBFileHandle },
621
  { PrototypeTraits<prototypes::id::IDBFileHandle>::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 < 1, "There is no slot for us");
635
636
MOZ_CAN_RUN_SCRIPT static bool
637
get_mode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
638
0
{
639
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.mode", DOM, cx);
640
0
641
0
  FileMode result(self->Mode());
642
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
643
0
  if (!ToJSValue(cx, result, args.rval())) {
644
0
    return false;
645
0
  }
646
0
  return true;
647
0
}
648
649
static const JSJitInfo mode_getterinfo = {
650
  { (JSJitGetterOp)get_mode },
651
  { prototypes::id::IDBFileHandle },
652
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
653
  JSJitInfo::Getter,
654
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
655
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
656
  false,  /* isInfallible. False in setters. */
657
  false,  /* isMovable.  Not relevant for setters. */
658
  false, /* isEliminatable.  Not relevant for setters. */
659
  false, /* isAlwaysInSlot.  Only relevant for getters. */
660
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
661
  false,  /* isTypedMethod.  Only relevant for methods. */
662
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
663
};
664
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
665
static_assert(0 < 1, "There is no slot for us");
666
667
MOZ_CAN_RUN_SCRIPT static bool
668
get_active(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
669
0
{
670
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.active", DOM, cx);
671
0
672
0
  bool result(self->Active());
673
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
674
0
  args.rval().setBoolean(result);
675
0
  return true;
676
0
}
677
678
static const JSJitInfo active_getterinfo = {
679
  { (JSJitGetterOp)get_active },
680
  { prototypes::id::IDBFileHandle },
681
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
682
  JSJitInfo::Getter,
683
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
684
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
685
  true,  /* isInfallible. False in setters. */
686
  false,  /* isMovable.  Not relevant for setters. */
687
  false, /* isEliminatable.  Not relevant for setters. */
688
  false, /* isAlwaysInSlot.  Only relevant for getters. */
689
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
690
  false,  /* isTypedMethod.  Only relevant for methods. */
691
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
692
};
693
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
694
static_assert(0 < 1, "There is no slot for us");
695
696
MOZ_CAN_RUN_SCRIPT static bool
697
get_location(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
698
0
{
699
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.location", DOM, cx);
700
0
701
0
  Nullable<uint64_t> result(self->GetLocation());
702
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
703
0
  if (result.IsNull()) {
704
0
    args.rval().setNull();
705
0
    return true;
706
0
  }
707
0
  args.rval().set(JS_NumberValue(double(result.Value())));
708
0
  return true;
709
0
}
710
711
MOZ_CAN_RUN_SCRIPT static bool
712
set_location(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitSetterCallArgs args)
713
0
{
714
0
  AUTO_PROFILER_LABEL_FAST("set IDBFileHandle.location", DOM, cx);
715
0
716
0
  Nullable<uint64_t> arg0;
717
0
  if (args[0].isNullOrUndefined()) {
718
0
    arg0.SetNull();
719
0
  } else if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0.SetValue())) {
720
0
    return false;
721
0
  }
722
0
  self->SetLocation(Constify(arg0));
723
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
724
0
725
0
  return true;
726
0
}
727
728
static const JSJitInfo location_getterinfo = {
729
  { (JSJitGetterOp)get_location },
730
  { prototypes::id::IDBFileHandle },
731
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
732
  JSJitInfo::Getter,
733
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
734
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
735
  true,  /* isInfallible. False in setters. */
736
  false,  /* isMovable.  Not relevant for setters. */
737
  false, /* isEliminatable.  Not relevant for setters. */
738
  false, /* isAlwaysInSlot.  Only relevant for getters. */
739
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
740
  false,  /* isTypedMethod.  Only relevant for methods. */
741
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
742
};
743
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
744
static_assert(0 < 1, "There is no slot for us");
745
static const JSJitInfo location_setterinfo = {
746
  { (JSJitGetterOp)set_location },
747
  { prototypes::id::IDBFileHandle },
748
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
749
  JSJitInfo::Setter,
750
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
751
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
752
  false,  /* isInfallible. False in setters. */
753
  false,  /* isMovable.  Not relevant for setters. */
754
  false, /* isEliminatable.  Not relevant for setters. */
755
  false, /* isAlwaysInSlot.  Only relevant for getters. */
756
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
757
  false,  /* isTypedMethod.  Only relevant for methods. */
758
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
759
};
760
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
761
static_assert(0 < 1, "There is no slot for us");
762
763
MOZ_CAN_RUN_SCRIPT static bool
764
getMetadata(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
765
0
{
766
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.getMetadata", DOM, cx);
767
0
768
0
  binding_detail::FastIDBFileMetadataParameters arg0;
769
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of IDBFileHandle.getMetadata", false)) {
770
0
    return false;
771
0
  }
772
0
  FastErrorResult rv;
773
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileRequest>(self->GetMetadata(Constify(arg0), rv)));
774
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
775
0
    return false;
776
0
  }
777
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
778
0
  if (!result) {
779
0
    args.rval().setNull();
780
0
    return true;
781
0
  }
782
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
783
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
784
0
    return false;
785
0
  }
786
0
  return true;
787
0
}
788
789
static const JSJitInfo getMetadata_methodinfo = {
790
  { (JSJitGetterOp)getMetadata },
791
  { prototypes::id::IDBFileHandle },
792
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
793
  JSJitInfo::Method,
794
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
795
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
796
  false,  /* isInfallible. False in setters. */
797
  false,  /* isMovable.  Not relevant for setters. */
798
  false, /* isEliminatable.  Not relevant for setters. */
799
  false, /* isAlwaysInSlot.  Only relevant for getters. */
800
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
801
  false,  /* isTypedMethod.  Only relevant for methods. */
802
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
803
};
804
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
805
static_assert(0 < 1, "There is no slot for us");
806
807
MOZ_CAN_RUN_SCRIPT static bool
808
readAsArrayBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
809
0
{
810
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.readAsArrayBuffer", DOM, cx);
811
0
812
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
813
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFileHandle.readAsArrayBuffer");
814
0
  }
815
0
  uint64_t arg0;
816
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0)) {
817
0
    return false;
818
0
  }
819
0
  FastErrorResult rv;
820
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileRequest>(self->ReadAsArrayBuffer(arg0, rv)));
821
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
822
0
    return false;
823
0
  }
824
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
825
0
  if (!result) {
826
0
    args.rval().setNull();
827
0
    return true;
828
0
  }
829
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
830
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
831
0
    return false;
832
0
  }
833
0
  return true;
834
0
}
835
836
static const JSJitInfo readAsArrayBuffer_methodinfo = {
837
  { (JSJitGetterOp)readAsArrayBuffer },
838
  { prototypes::id::IDBFileHandle },
839
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
840
  JSJitInfo::Method,
841
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
842
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
843
  false,  /* isInfallible. False in setters. */
844
  false,  /* isMovable.  Not relevant for setters. */
845
  false, /* isEliminatable.  Not relevant for setters. */
846
  false, /* isAlwaysInSlot.  Only relevant for getters. */
847
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
848
  false,  /* isTypedMethod.  Only relevant for methods. */
849
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
850
};
851
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
852
static_assert(0 < 1, "There is no slot for us");
853
854
MOZ_CAN_RUN_SCRIPT static bool
855
readAsText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
856
0
{
857
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.readAsText", DOM, cx);
858
0
859
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
860
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFileHandle.readAsText");
861
0
  }
862
0
  uint64_t arg0;
863
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0)) {
864
0
    return false;
865
0
  }
866
0
  binding_detail::FakeString arg1;
867
0
  if (args.hasDefined(1)) {
868
0
    if (!ConvertJSValueToString(cx, args[1], eNull, eNull, arg1)) {
869
0
      return false;
870
0
    }
871
0
  } else {
872
0
    arg1.SetIsVoid(true);
873
0
  }
874
0
  FastErrorResult rv;
875
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileRequest>(self->ReadAsText(arg0, NonNullHelper(Constify(arg1)), rv)));
876
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
877
0
    return false;
878
0
  }
879
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
880
0
  if (!result) {
881
0
    args.rval().setNull();
882
0
    return true;
883
0
  }
884
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
885
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
886
0
    return false;
887
0
  }
888
0
  return true;
889
0
}
890
891
static const JSJitInfo readAsText_methodinfo = {
892
  { (JSJitGetterOp)readAsText },
893
  { prototypes::id::IDBFileHandle },
894
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
895
  JSJitInfo::Method,
896
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
897
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
898
  false,  /* isInfallible. False in setters. */
899
  false,  /* isMovable.  Not relevant for setters. */
900
  false, /* isEliminatable.  Not relevant for setters. */
901
  false, /* isAlwaysInSlot.  Only relevant for getters. */
902
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
903
  false,  /* isTypedMethod.  Only relevant for methods. */
904
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
905
};
906
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
907
static_assert(0 < 1, "There is no slot for us");
908
909
MOZ_CAN_RUN_SCRIPT static bool
910
write(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
911
0
{
912
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.write", DOM, cx);
913
0
914
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
915
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFileHandle.write");
916
0
  }
917
0
  StringOrArrayBufferOrArrayBufferViewOrBlob arg0;
918
0
  StringOrArrayBufferOrArrayBufferViewOrBlobArgument arg0_holder(arg0);
919
0
  {
920
0
    bool done = false, failed = false, tryNext;
921
0
    if (args[0].isObject()) {
922
0
      done = (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext ||
923
0
             (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext ||
924
0
             (failed = !arg0_holder.TrySetToBlob(cx, args[0], tryNext, false)) || !tryNext;
925
0
926
0
    }
927
0
    if (!done) {
928
0
      do {
929
0
        done = (failed = !arg0_holder.TrySetToString(cx, args[0], tryNext)) || !tryNext;
930
0
        break;
931
0
      } while (false);
932
0
    }
933
0
    if (failed) {
934
0
      return false;
935
0
    }
936
0
    if (!done) {
937
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of IDBFileHandle.write", "ArrayBuffer, ArrayBufferView, Blob");
938
0
      return false;
939
0
    }
940
0
  }
941
0
  FastErrorResult rv;
942
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileRequest>(self->Write(Constify(arg0), rv)));
943
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
944
0
    return false;
945
0
  }
946
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
947
0
  if (!result) {
948
0
    args.rval().setNull();
949
0
    return true;
950
0
  }
951
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
952
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
953
0
    return false;
954
0
  }
955
0
  return true;
956
0
}
957
958
static const JSJitInfo write_methodinfo = {
959
  { (JSJitGetterOp)write },
960
  { prototypes::id::IDBFileHandle },
961
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
962
  JSJitInfo::Method,
963
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
964
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
965
  false,  /* isInfallible. False in setters. */
966
  false,  /* isMovable.  Not relevant for setters. */
967
  false, /* isEliminatable.  Not relevant for setters. */
968
  false, /* isAlwaysInSlot.  Only relevant for getters. */
969
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
970
  false,  /* isTypedMethod.  Only relevant for methods. */
971
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
972
};
973
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
974
static_assert(0 < 1, "There is no slot for us");
975
976
MOZ_CAN_RUN_SCRIPT static bool
977
append(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
978
0
{
979
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.append", DOM, cx);
980
0
981
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
982
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBFileHandle.append");
983
0
  }
984
0
  StringOrArrayBufferOrArrayBufferViewOrBlob arg0;
985
0
  StringOrArrayBufferOrArrayBufferViewOrBlobArgument arg0_holder(arg0);
986
0
  {
987
0
    bool done = false, failed = false, tryNext;
988
0
    if (args[0].isObject()) {
989
0
      done = (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext ||
990
0
             (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext ||
991
0
             (failed = !arg0_holder.TrySetToBlob(cx, args[0], tryNext, false)) || !tryNext;
992
0
993
0
    }
994
0
    if (!done) {
995
0
      do {
996
0
        done = (failed = !arg0_holder.TrySetToString(cx, args[0], tryNext)) || !tryNext;
997
0
        break;
998
0
      } while (false);
999
0
    }
1000
0
    if (failed) {
1001
0
      return false;
1002
0
    }
1003
0
    if (!done) {
1004
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of IDBFileHandle.append", "ArrayBuffer, ArrayBufferView, Blob");
1005
0
      return false;
1006
0
    }
1007
0
  }
1008
0
  FastErrorResult rv;
1009
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileRequest>(self->Append(Constify(arg0), rv)));
1010
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1011
0
    return false;
1012
0
  }
1013
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1014
0
  if (!result) {
1015
0
    args.rval().setNull();
1016
0
    return true;
1017
0
  }
1018
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1019
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1020
0
    return false;
1021
0
  }
1022
0
  return true;
1023
0
}
1024
1025
static const JSJitInfo append_methodinfo = {
1026
  { (JSJitGetterOp)append },
1027
  { prototypes::id::IDBFileHandle },
1028
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1029
  JSJitInfo::Method,
1030
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1031
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1032
  false,  /* isInfallible. False in setters. */
1033
  false,  /* isMovable.  Not relevant for setters. */
1034
  false, /* isEliminatable.  Not relevant for setters. */
1035
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1036
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1037
  false,  /* isTypedMethod.  Only relevant for methods. */
1038
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1039
};
1040
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1041
static_assert(0 < 1, "There is no slot for us");
1042
1043
MOZ_CAN_RUN_SCRIPT static bool
1044
truncate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
1045
0
{
1046
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.truncate", DOM, cx);
1047
0
1048
0
  Optional<uint64_t> arg0;
1049
0
  if (args.hasDefined(0)) {
1050
0
    arg0.Construct();
1051
0
    if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0.Value())) {
1052
0
      return false;
1053
0
    }
1054
0
  }
1055
0
  FastErrorResult rv;
1056
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileRequest>(self->Truncate(Constify(arg0), rv)));
1057
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1058
0
    return false;
1059
0
  }
1060
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1061
0
  if (!result) {
1062
0
    args.rval().setNull();
1063
0
    return true;
1064
0
  }
1065
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1066
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1067
0
    return false;
1068
0
  }
1069
0
  return true;
1070
0
}
1071
1072
static const JSJitInfo truncate_methodinfo = {
1073
  { (JSJitGetterOp)truncate },
1074
  { prototypes::id::IDBFileHandle },
1075
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1076
  JSJitInfo::Method,
1077
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1078
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1079
  false,  /* isInfallible. False in setters. */
1080
  false,  /* isMovable.  Not relevant for setters. */
1081
  false, /* isEliminatable.  Not relevant for setters. */
1082
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1083
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1084
  false,  /* isTypedMethod.  Only relevant for methods. */
1085
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1086
};
1087
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1088
static_assert(0 < 1, "There is no slot for us");
1089
1090
MOZ_CAN_RUN_SCRIPT static bool
1091
flush(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
1092
0
{
1093
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.flush", DOM, cx);
1094
0
1095
0
  FastErrorResult rv;
1096
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBFileRequest>(self->Flush(rv)));
1097
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1098
0
    return false;
1099
0
  }
1100
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1101
0
  if (!result) {
1102
0
    args.rval().setNull();
1103
0
    return true;
1104
0
  }
1105
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1106
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1107
0
    return false;
1108
0
  }
1109
0
  return true;
1110
0
}
1111
1112
static const JSJitInfo flush_methodinfo = {
1113
  { (JSJitGetterOp)flush },
1114
  { prototypes::id::IDBFileHandle },
1115
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1116
  JSJitInfo::Method,
1117
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1118
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1119
  false,  /* isInfallible. False in setters. */
1120
  false,  /* isMovable.  Not relevant for setters. */
1121
  false, /* isEliminatable.  Not relevant for setters. */
1122
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1123
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1124
  false,  /* isTypedMethod.  Only relevant for methods. */
1125
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1126
};
1127
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1128
static_assert(0 < 1, "There is no slot for us");
1129
1130
MOZ_CAN_RUN_SCRIPT static bool
1131
abort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, const JSJitMethodCallArgs& args)
1132
0
{
1133
0
  AUTO_PROFILER_LABEL_FAST("IDBFileHandle.abort", DOM, cx);
1134
0
1135
0
  FastErrorResult rv;
1136
0
  self->Abort(rv);
1137
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1138
0
    return false;
1139
0
  }
1140
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1141
0
  args.rval().setUndefined();
1142
0
  return true;
1143
0
}
1144
1145
static const JSJitInfo abort_methodinfo = {
1146
  { (JSJitGetterOp)abort },
1147
  { prototypes::id::IDBFileHandle },
1148
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1149
  JSJitInfo::Method,
1150
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1151
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1152
  false,  /* isInfallible. False in setters. */
1153
  false,  /* isMovable.  Not relevant for setters. */
1154
  false, /* isEliminatable.  Not relevant for setters. */
1155
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1156
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1157
  false,  /* isTypedMethod.  Only relevant for methods. */
1158
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1159
};
1160
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1161
static_assert(0 < 1, "There is no slot for us");
1162
1163
MOZ_CAN_RUN_SCRIPT static bool
1164
get_oncomplete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
1165
0
{
1166
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.oncomplete", DOM, cx);
1167
0
1168
0
  RefPtr<EventHandlerNonNull> result(self->GetOncomplete());
1169
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1170
0
  if (result) {
1171
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
1172
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
1173
0
      return false;
1174
0
    }
1175
0
    return true;
1176
0
  } else {
1177
0
    args.rval().setNull();
1178
0
    return true;
1179
0
  }
1180
0
}
1181
1182
MOZ_CAN_RUN_SCRIPT static bool
1183
set_oncomplete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitSetterCallArgs args)
1184
0
{
1185
0
  AUTO_PROFILER_LABEL_FAST("set IDBFileHandle.oncomplete", DOM, cx);
1186
0
1187
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
1188
0
  if (args[0].isObject()) {
1189
0
    { // scope for tempRoot and tempGlobalRoot if needed
1190
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
1191
0
    }
1192
0
  } else {
1193
0
    arg0 = nullptr;
1194
0
  }
1195
0
  self->SetOncomplete(Constify(arg0));
1196
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1197
0
1198
0
  return true;
1199
0
}
1200
1201
static const JSJitInfo oncomplete_getterinfo = {
1202
  { (JSJitGetterOp)get_oncomplete },
1203
  { prototypes::id::IDBFileHandle },
1204
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1205
  JSJitInfo::Getter,
1206
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1207
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1208
  false,  /* isInfallible. False in setters. */
1209
  false,  /* isMovable.  Not relevant for setters. */
1210
  false, /* isEliminatable.  Not relevant for setters. */
1211
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1212
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1213
  false,  /* isTypedMethod.  Only relevant for methods. */
1214
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1215
};
1216
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1217
static_assert(0 < 1, "There is no slot for us");
1218
static const JSJitInfo oncomplete_setterinfo = {
1219
  { (JSJitGetterOp)set_oncomplete },
1220
  { prototypes::id::IDBFileHandle },
1221
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1222
  JSJitInfo::Setter,
1223
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1224
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1225
  false,  /* isInfallible. False in setters. */
1226
  false,  /* isMovable.  Not relevant for setters. */
1227
  false, /* isEliminatable.  Not relevant for setters. */
1228
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1229
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1230
  false,  /* isTypedMethod.  Only relevant for methods. */
1231
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1232
};
1233
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1234
static_assert(0 < 1, "There is no slot for us");
1235
1236
MOZ_CAN_RUN_SCRIPT static bool
1237
get_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
1238
0
{
1239
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.onabort", DOM, cx);
1240
0
1241
0
  RefPtr<EventHandlerNonNull> result(self->GetOnabort());
1242
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1243
0
  if (result) {
1244
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
1245
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
1246
0
      return false;
1247
0
    }
1248
0
    return true;
1249
0
  } else {
1250
0
    args.rval().setNull();
1251
0
    return true;
1252
0
  }
1253
0
}
1254
1255
MOZ_CAN_RUN_SCRIPT static bool
1256
set_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitSetterCallArgs args)
1257
0
{
1258
0
  AUTO_PROFILER_LABEL_FAST("set IDBFileHandle.onabort", DOM, cx);
1259
0
1260
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
1261
0
  if (args[0].isObject()) {
1262
0
    { // scope for tempRoot and tempGlobalRoot if needed
1263
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
1264
0
    }
1265
0
  } else {
1266
0
    arg0 = nullptr;
1267
0
  }
1268
0
  self->SetOnabort(Constify(arg0));
1269
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1270
0
1271
0
  return true;
1272
0
}
1273
1274
static const JSJitInfo onabort_getterinfo = {
1275
  { (JSJitGetterOp)get_onabort },
1276
  { prototypes::id::IDBFileHandle },
1277
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1278
  JSJitInfo::Getter,
1279
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1280
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1281
  false,  /* isInfallible. False in setters. */
1282
  false,  /* isMovable.  Not relevant for setters. */
1283
  false, /* isEliminatable.  Not relevant for setters. */
1284
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1285
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1286
  false,  /* isTypedMethod.  Only relevant for methods. */
1287
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1288
};
1289
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1290
static_assert(0 < 1, "There is no slot for us");
1291
static const JSJitInfo onabort_setterinfo = {
1292
  { (JSJitGetterOp)set_onabort },
1293
  { prototypes::id::IDBFileHandle },
1294
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1295
  JSJitInfo::Setter,
1296
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1297
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1298
  false,  /* isInfallible. False in setters. */
1299
  false,  /* isMovable.  Not relevant for setters. */
1300
  false, /* isEliminatable.  Not relevant for setters. */
1301
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1302
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1303
  false,  /* isTypedMethod.  Only relevant for methods. */
1304
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1305
};
1306
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1307
static_assert(0 < 1, "There is no slot for us");
1308
1309
MOZ_CAN_RUN_SCRIPT static bool
1310
get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitGetterCallArgs args)
1311
0
{
1312
0
  AUTO_PROFILER_LABEL_FAST("get IDBFileHandle.onerror", DOM, cx);
1313
0
1314
0
  RefPtr<EventHandlerNonNull> result(self->GetOnerror());
1315
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1316
0
  if (result) {
1317
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
1318
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
1319
0
      return false;
1320
0
    }
1321
0
    return true;
1322
0
  } else {
1323
0
    args.rval().setNull();
1324
0
    return true;
1325
0
  }
1326
0
}
1327
1328
MOZ_CAN_RUN_SCRIPT static bool
1329
set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBFileHandle* self, JSJitSetterCallArgs args)
1330
0
{
1331
0
  AUTO_PROFILER_LABEL_FAST("set IDBFileHandle.onerror", DOM, cx);
1332
0
1333
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
1334
0
  if (args[0].isObject()) {
1335
0
    { // scope for tempRoot and tempGlobalRoot if needed
1336
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
1337
0
    }
1338
0
  } else {
1339
0
    arg0 = nullptr;
1340
0
  }
1341
0
  self->SetOnerror(Constify(arg0));
1342
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1343
0
1344
0
  return true;
1345
0
}
1346
1347
static const JSJitInfo onerror_getterinfo = {
1348
  { (JSJitGetterOp)get_onerror },
1349
  { prototypes::id::IDBFileHandle },
1350
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1351
  JSJitInfo::Getter,
1352
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1353
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1354
  false,  /* isInfallible. False in setters. */
1355
  false,  /* isMovable.  Not relevant for setters. */
1356
  false, /* isEliminatable.  Not relevant for setters. */
1357
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1358
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1359
  false,  /* isTypedMethod.  Only relevant for methods. */
1360
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1361
};
1362
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1363
static_assert(0 < 1, "There is no slot for us");
1364
static const JSJitInfo onerror_setterinfo = {
1365
  { (JSJitGetterOp)set_onerror },
1366
  { prototypes::id::IDBFileHandle },
1367
  { PrototypeTraits<prototypes::id::IDBFileHandle>::Depth },
1368
  JSJitInfo::Setter,
1369
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1370
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1371
  false,  /* isInfallible. False in setters. */
1372
  false,  /* isMovable.  Not relevant for setters. */
1373
  false, /* isEliminatable.  Not relevant for setters. */
1374
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1375
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1376
  false,  /* isTypedMethod.  Only relevant for methods. */
1377
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1378
};
1379
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1380
static_assert(0 < 1, "There is no slot for us");
1381
1382
static bool
1383
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1384
0
{
1385
0
  mozilla::dom::IDBFileHandle* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBFileHandle>(obj);
1386
0
  // We don't want to preserve if we don't have a wrapper, and we
1387
0
  // obviously can't preserve if we're not initialized.
1388
0
  if (self && self->GetWrapperPreserveColor()) {
1389
0
    PreserveWrapper(self);
1390
0
  }
1391
0
  return true;
1392
0
}
1393
1394
static void
1395
_finalize(js::FreeOp* fop, JSObject* obj)
1396
0
{
1397
0
  mozilla::dom::IDBFileHandle* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBFileHandle>(obj);
1398
0
  if (self) {
1399
0
    ClearWrapper(self, self, obj);
1400
0
    AddForDeferredFinalization<mozilla::dom::IDBFileHandle>(self);
1401
0
  }
1402
0
}
1403
1404
static size_t
1405
_objectMoved(JSObject* obj, JSObject* old)
1406
0
{
1407
0
  mozilla::dom::IDBFileHandle* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBFileHandle>(obj);
1408
0
  if (self) {
1409
0
    UpdateWrapper(self, self, obj, old);
1410
0
  }
1411
0
1412
0
  return 0;
1413
0
}
1414
1415
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1416
#if defined(__clang__)
1417
#pragma clang diagnostic push
1418
#pragma clang diagnostic ignored "-Wmissing-braces"
1419
#endif
1420
static const JSFunctionSpec sMethods_specs[] = {
1421
  JS_FNSPEC("getMetadata", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getMetadata_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1422
  JS_FNSPEC("readAsArrayBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&readAsArrayBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1423
  JS_FNSPEC("readAsText", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&readAsText_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1424
  JS_FNSPEC("write", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&write_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1425
  JS_FNSPEC("append", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&append_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1426
  JS_FNSPEC("truncate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&truncate_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1427
  JS_FNSPEC("flush", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&flush_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1428
  JS_FNSPEC("abort", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&abort_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1429
  JS_FS_END
1430
};
1431
#if defined(__clang__)
1432
#pragma clang diagnostic pop
1433
#endif
1434
1435
1436
static const Prefable<const JSFunctionSpec> sMethods[] = {
1437
  { nullptr, &sMethods_specs[0] },
1438
  { nullptr, nullptr }
1439
};
1440
1441
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1442
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1443
static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1444
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1445
1446
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1447
#if defined(__clang__)
1448
#pragma clang diagnostic push
1449
#pragma clang diagnostic ignored "-Wmissing-braces"
1450
#endif
1451
static const JSPropertySpec sAttributes_specs[] = {
1452
  { "mutableFile", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mutableFile_getterinfo, nullptr, nullptr },
1453
  { "fileHandle", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fileHandle_getterinfo, nullptr, nullptr },
1454
  { "mode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mode_getterinfo, nullptr, nullptr },
1455
  { "active", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &active_getterinfo, nullptr, nullptr },
1456
  { "location", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &location_getterinfo, GenericSetter<NormalThisPolicy>, &location_setterinfo },
1457
  { "oncomplete", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &oncomplete_getterinfo, GenericSetter<NormalThisPolicy>, &oncomplete_setterinfo },
1458
  { "onabort", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onabort_getterinfo, GenericSetter<NormalThisPolicy>, &onabort_setterinfo },
1459
  { "onerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onerror_getterinfo, GenericSetter<NormalThisPolicy>, &onerror_setterinfo },
1460
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1461
};
1462
#if defined(__clang__)
1463
#pragma clang diagnostic pop
1464
#endif
1465
1466
1467
static const Prefable<const JSPropertySpec> sAttributes[] = {
1468
  { nullptr, &sAttributes_specs[0] },
1469
  { nullptr, nullptr }
1470
};
1471
1472
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1473
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1474
static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1475
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1476
1477
1478
static uint16_t sNativeProperties_sortedPropertyIndices[16];
1479
static PropertyInfo sNativeProperties_propertyInfos[16];
1480
1481
static const NativePropertiesN<2> sNativeProperties = {
1482
  false, 0,
1483
  false, 0,
1484
  true,  0 /* sMethods */,
1485
  true,  1 /* sAttributes */,
1486
  false, 0,
1487
  false, 0,
1488
  false, 0,
1489
  -1,
1490
  16,
1491
  sNativeProperties_sortedPropertyIndices,
1492
  {
1493
    { sMethods, &sNativeProperties_propertyInfos[0] },
1494
    { sAttributes, &sNativeProperties_propertyInfos[8] }
1495
  }
1496
};
1497
static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1498
    "We have a property info count that is oversized");
1499
1500
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1501
  {
1502
    "Function",
1503
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1504
    &sBoringInterfaceObjectClassClassOps,
1505
    JS_NULL_CLASS_SPEC,
1506
    JS_NULL_CLASS_EXT,
1507
    &sInterfaceObjectClassObjectOps
1508
  },
1509
  eInterface,
1510
  true,
1511
  prototypes::id::IDBFileHandle,
1512
  PrototypeTraits<prototypes::id::IDBFileHandle>::Depth,
1513
  sNativePropertyHooks,
1514
  "function IDBFileHandle() {\n    [native code]\n}",
1515
  EventTarget_Binding::GetConstructorObject
1516
};
1517
1518
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1519
  {
1520
    "IDBFileHandlePrototype",
1521
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1522
    JS_NULL_CLASS_OPS,
1523
    JS_NULL_CLASS_SPEC,
1524
    JS_NULL_CLASS_EXT,
1525
    JS_NULL_OBJECT_OPS
1526
  },
1527
  eInterfacePrototype,
1528
  false,
1529
  prototypes::id::IDBFileHandle,
1530
  PrototypeTraits<prototypes::id::IDBFileHandle>::Depth,
1531
  sNativePropertyHooks,
1532
  "[object IDBFileHandlePrototype]",
1533
  EventTarget_Binding::GetProtoObject
1534
};
1535
1536
static const js::ClassOps sClassOps = {
1537
  _addProperty, /* addProperty */
1538
  nullptr,               /* delProperty */
1539
  nullptr,               /* enumerate */
1540
  nullptr, /* newEnumerate */
1541
  nullptr, /* resolve */
1542
  nullptr, /* mayResolve */
1543
  _finalize, /* finalize */
1544
  nullptr, /* call */
1545
  nullptr,               /* hasInstance */
1546
  nullptr,               /* construct */
1547
  nullptr, /* trace */
1548
};
1549
1550
static const js::ClassExtension sClassExtension = {
1551
  nullptr, /* weakmapKeyDelegateOp */
1552
  _objectMoved /* objectMovedOp */
1553
};
1554
1555
static const DOMJSClass sClass = {
1556
  { "IDBFileHandle",
1557
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1558
    &sClassOps,
1559
    JS_NULL_CLASS_SPEC,
1560
    &sClassExtension,
1561
    JS_NULL_OBJECT_OPS
1562
  },
1563
  { prototypes::id::EventTarget, prototypes::id::IDBFileHandle, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1564
  IsBaseOf<nsISupports, mozilla::dom::IDBFileHandle >::value,
1565
  sNativePropertyHooks,
1566
  FindAssociatedGlobalForNative<mozilla::dom::IDBFileHandle>::Get,
1567
  GetProtoObjectHandle,
1568
  GetCCParticipant<mozilla::dom::IDBFileHandle>::Get()
1569
};
1570
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1571
              "Must have the right minimal number of reserved slots.");
1572
static_assert(1 >= 1,
1573
              "Must have enough reserved slots.");
1574
1575
const JSClass*
1576
GetJSClass()
1577
0
{
1578
0
  return sClass.ToJSClass();
1579
0
}
1580
1581
bool
1582
Wrap(JSContext* aCx, mozilla::dom::IDBFileHandle* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1583
0
{
1584
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::IDBFileHandle>::value,
1585
0
                "Shouldn't have wrappercached things that are not refcounted.");
1586
0
  MOZ_ASSERT(static_cast<mozilla::dom::IDBFileHandle*>(aObject) ==
1587
0
             reinterpret_cast<mozilla::dom::IDBFileHandle*>(aObject),
1588
0
             "Multiple inheritance for mozilla::dom::IDBFileHandle is broken.");
1589
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1590
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1591
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1592
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1593
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1594
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1595
0
             "You should probably not be using Wrap() directly; use "
1596
0
             "GetOrCreateDOMReflector instead");
1597
0
1598
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1599
0
             "nsISupports must be on our primary inheritance chain");
1600
0
1601
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1602
0
  if (!global) {
1603
0
    return false;
1604
0
  }
1605
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1606
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1607
0
1608
0
  // That might have ended up wrapping us already, due to the wonders
1609
0
  // of XBL.  Check for that, and bail out as needed.
1610
0
  aReflector.set(aCache->GetWrapper());
1611
0
  if (aReflector) {
1612
#ifdef DEBUG
1613
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1614
#endif // DEBUG
1615
    return true;
1616
0
  }
1617
0
1618
0
  JSAutoRealm ar(aCx, global);
1619
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1620
0
  if (!canonicalProto) {
1621
0
    return false;
1622
0
  }
1623
0
  JS::Rooted<JSObject*> proto(aCx);
1624
0
  if (aGivenProto) {
1625
0
    proto = aGivenProto;
1626
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1627
0
    // coming in, we changed compartments to that of "parent" so may need
1628
0
    // to wrap the proto here.
1629
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1630
0
      if (!JS_WrapObject(aCx, &proto)) {
1631
0
        return false;
1632
0
      }
1633
0
    }
1634
0
  } else {
1635
0
    proto = canonicalProto;
1636
0
  }
1637
0
1638
0
  BindingJSObjectCreator<mozilla::dom::IDBFileHandle> creator(aCx);
1639
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1640
0
  if (!aReflector) {
1641
0
    return false;
1642
0
  }
1643
0
1644
0
  aCache->SetWrapper(aReflector);
1645
0
  creator.InitializationSucceeded();
1646
0
1647
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1648
0
             aCache->GetWrapperPreserveColor() == aReflector);
1649
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1650
0
  // otherwise we won't be able to properly recreate it later, since
1651
0
  // we won't know what proto to use.  Note that we don't check
1652
0
  // aGivenProto here, since it's entirely possible (and even
1653
0
  // somewhat common) to have a non-null aGivenProto which is the
1654
0
  // same as canonicalProto.
1655
0
  if (proto != canonicalProto) {
1656
0
    PreserveWrapper(aObject);
1657
0
  }
1658
0
1659
0
  return true;
1660
0
}
1661
1662
const NativePropertyHooks sNativePropertyHooks[] = { {
1663
  nullptr,
1664
  nullptr,
1665
  nullptr,
1666
  { sNativeProperties.Upcast(), nullptr },
1667
  prototypes::id::IDBFileHandle,
1668
  constructors::id::IDBFileHandle,
1669
  EventTarget_Binding::sNativePropertyHooks,
1670
  &DefaultXrayExpandoObjectClass
1671
} };
1672
1673
void
1674
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1675
0
{
1676
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
1677
0
  if (!parentProto) {
1678
0
    return;
1679
0
  }
1680
0
1681
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
1682
0
  if (!constructorProto) {
1683
0
    return;
1684
0
  }
1685
0
1686
0
  static bool sIdsInited = false;
1687
0
  if (!sIdsInited && NS_IsMainThread()) {
1688
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1689
0
      return;
1690
0
    }
1691
0
    sIdsInited = true;
1692
0
  }
1693
0
1694
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBFileHandle);
1695
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBFileHandle);
1696
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1697
0
                              &sPrototypeClass.mBase, protoCache,
1698
0
                              nullptr,
1699
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1700
0
                              interfaceCache,
1701
0
                              sNativeProperties.Upcast(),
1702
0
                              nullptr,
1703
0
                              "IDBFileHandle", aDefineOnGlobal,
1704
0
                              nullptr,
1705
0
                              false);
1706
0
}
1707
1708
JSObject*
1709
GetConstructorObject(JSContext* aCx)
1710
0
{
1711
0
  return GetConstructorObjectHandle(aCx);
1712
0
}
1713
1714
} // namespace IDBFileHandle_Binding
1715
1716
1717
1718
} // namespace dom
1719
} // namespace mozilla