Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/IDBTransactionBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM IDBTransaction.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "EventHandlerBinding.h"
4
#include "EventTargetBinding.h"
5
#include "IDBTransactionBinding.h"
6
#include "WrapperFactory.h"
7
#include "jsapi.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMException.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/DOMStringList.h"
13
#include "mozilla/dom/IDBDatabase.h"
14
#include "mozilla/dom/IDBObjectStore.h"
15
#include "mozilla/dom/IDBTransaction.h"
16
#include "mozilla/dom/NonRefcountedDOMObject.h"
17
#include "mozilla/dom/Nullable.h"
18
#include "mozilla/dom/XrayExpandoClass.h"
19
20
namespace mozilla {
21
namespace dom {
22
23
namespace binding_detail {}; // Just to make sure it's known as a namespace
24
using namespace mozilla::dom::binding_detail;
25
26
27
namespace IDBTransactionModeValues {
28
extern const EnumEntry strings[6] = {
29
  {"readonly", 8},
30
  {"readwrite", 9},
31
  {"readwriteflush", 14},
32
  {"cleanup", 7},
33
  {"versionchange", 13},
34
  { nullptr, 0 }
35
};
36
} // namespace IDBTransactionModeValues
37
38
bool
39
ToJSValue(JSContext* aCx, IDBTransactionMode aArgument, JS::MutableHandle<JS::Value> aValue)
40
0
{
41
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(IDBTransactionModeValues::strings));
42
0
  JSString* resultStr =
43
0
    JS_NewStringCopyN(aCx, IDBTransactionModeValues::strings[uint32_t(aArgument)].value,
44
0
                      IDBTransactionModeValues::strings[uint32_t(aArgument)].length);
45
0
  if (!resultStr) {
46
0
    return false;
47
0
  }
48
0
  aValue.setString(resultStr);
49
0
  return true;
50
0
}
51
52
53
namespace IDBTransaction_Binding {
54
55
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
56
              "Can't inherit from an interface with a different ownership model.");
57
58
MOZ_CAN_RUN_SCRIPT static bool
59
get_mode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitGetterCallArgs args)
60
0
{
61
0
  AUTO_PROFILER_LABEL_FAST("get IDBTransaction.mode", DOM, cx);
62
0
63
0
  FastErrorResult rv;
64
0
  IDBTransactionMode result(self->GetMode(rv));
65
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
66
0
    return false;
67
0
  }
68
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
69
0
  if (!ToJSValue(cx, result, args.rval())) {
70
0
    return false;
71
0
  }
72
0
  return true;
73
0
}
74
75
static const JSJitInfo mode_getterinfo = {
76
  { (JSJitGetterOp)get_mode },
77
  { prototypes::id::IDBTransaction },
78
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
79
  JSJitInfo::Getter,
80
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
81
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
82
  false,  /* isInfallible. False in setters. */
83
  false,  /* isMovable.  Not relevant for setters. */
84
  false, /* isEliminatable.  Not relevant for setters. */
85
  false, /* isAlwaysInSlot.  Only relevant for getters. */
86
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
87
  false,  /* isTypedMethod.  Only relevant for methods. */
88
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
89
};
90
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
91
static_assert(0 < 1, "There is no slot for us");
92
93
MOZ_CAN_RUN_SCRIPT static bool
94
get_db(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitGetterCallArgs args)
95
0
{
96
0
  AUTO_PROFILER_LABEL_FAST("get IDBTransaction.db", DOM, cx);
97
0
98
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBDatabase>(self->Db()));
99
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
100
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
101
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
102
0
    return false;
103
0
  }
104
0
  return true;
105
0
}
106
107
static const JSJitInfo db_getterinfo = {
108
  { (JSJitGetterOp)get_db },
109
  { prototypes::id::IDBTransaction },
110
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
111
  JSJitInfo::Getter,
112
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
113
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
114
  false,  /* isInfallible. False in setters. */
115
  false,  /* isMovable.  Not relevant for setters. */
116
  false, /* isEliminatable.  Not relevant for setters. */
117
  false, /* isAlwaysInSlot.  Only relevant for getters. */
118
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
119
  false,  /* isTypedMethod.  Only relevant for methods. */
120
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
121
};
122
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
123
static_assert(0 < 1, "There is no slot for us");
124
125
MOZ_CAN_RUN_SCRIPT static bool
126
get_error(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitGetterCallArgs args)
127
0
{
128
0
  AUTO_PROFILER_LABEL_FAST("get IDBTransaction.error", DOM, cx);
129
0
130
0
  auto result(StrongOrRawPtr<mozilla::dom::DOMException>(self->GetError()));
131
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
132
0
  if (!result) {
133
0
    args.rval().setNull();
134
0
    return true;
135
0
  }
136
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
137
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
138
0
    return false;
139
0
  }
140
0
  return true;
141
0
}
142
143
static const JSJitInfo error_getterinfo = {
144
  { (JSJitGetterOp)get_error },
145
  { prototypes::id::IDBTransaction },
146
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
147
  JSJitInfo::Getter,
148
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
149
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
150
  false,  /* isInfallible. False in setters. */
151
  false,  /* isMovable.  Not relevant for setters. */
152
  false, /* isEliminatable.  Not relevant for setters. */
153
  false, /* isAlwaysInSlot.  Only relevant for getters. */
154
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
155
  false,  /* isTypedMethod.  Only relevant for methods. */
156
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
157
};
158
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
159
static_assert(0 < 1, "There is no slot for us");
160
161
MOZ_CAN_RUN_SCRIPT static bool
162
objectStore(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, const JSJitMethodCallArgs& args)
163
0
{
164
0
  AUTO_PROFILER_LABEL_FAST("IDBTransaction.objectStore", DOM, cx);
165
0
166
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
167
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBTransaction.objectStore");
168
0
  }
169
0
  binding_detail::FakeString arg0;
170
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
171
0
    return false;
172
0
  }
173
0
  FastErrorResult rv;
174
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBObjectStore>(self->ObjectStore(NonNullHelper(Constify(arg0)), rv)));
175
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
176
0
    return false;
177
0
  }
178
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
179
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
180
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
181
0
    return false;
182
0
  }
183
0
  return true;
184
0
}
185
186
static const JSJitInfo objectStore_methodinfo = {
187
  { (JSJitGetterOp)objectStore },
188
  { prototypes::id::IDBTransaction },
189
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
190
  JSJitInfo::Method,
191
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
192
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
193
  false,  /* isInfallible. False in setters. */
194
  false,  /* isMovable.  Not relevant for setters. */
195
  false, /* isEliminatable.  Not relevant for setters. */
196
  false, /* isAlwaysInSlot.  Only relevant for getters. */
197
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
198
  false,  /* isTypedMethod.  Only relevant for methods. */
199
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
200
};
201
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
202
static_assert(0 < 1, "There is no slot for us");
203
204
MOZ_CAN_RUN_SCRIPT static bool
205
abort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, const JSJitMethodCallArgs& args)
206
0
{
207
0
  AUTO_PROFILER_LABEL_FAST("IDBTransaction.abort", DOM, cx);
208
0
209
0
  FastErrorResult rv;
210
0
  self->Abort(rv);
211
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
212
0
    return false;
213
0
  }
214
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
215
0
  args.rval().setUndefined();
216
0
  return true;
217
0
}
218
219
static const JSJitInfo abort_methodinfo = {
220
  { (JSJitGetterOp)abort },
221
  { prototypes::id::IDBTransaction },
222
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
223
  JSJitInfo::Method,
224
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
225
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
226
  false,  /* isInfallible. False in setters. */
227
  false,  /* isMovable.  Not relevant for setters. */
228
  false, /* isEliminatable.  Not relevant for setters. */
229
  false, /* isAlwaysInSlot.  Only relevant for getters. */
230
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
231
  false,  /* isTypedMethod.  Only relevant for methods. */
232
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
233
};
234
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
235
static_assert(0 < 1, "There is no slot for us");
236
237
MOZ_CAN_RUN_SCRIPT static bool
238
get_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitGetterCallArgs args)
239
0
{
240
0
  AUTO_PROFILER_LABEL_FAST("get IDBTransaction.onabort", DOM, cx);
241
0
242
0
  RefPtr<EventHandlerNonNull> result(self->GetOnabort());
243
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
244
0
  if (result) {
245
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
246
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
247
0
      return false;
248
0
    }
249
0
    return true;
250
0
  } else {
251
0
    args.rval().setNull();
252
0
    return true;
253
0
  }
254
0
}
255
256
MOZ_CAN_RUN_SCRIPT static bool
257
set_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitSetterCallArgs args)
258
0
{
259
0
  AUTO_PROFILER_LABEL_FAST("set IDBTransaction.onabort", DOM, cx);
260
0
261
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
262
0
  if (args[0].isObject()) {
263
0
    { // scope for tempRoot and tempGlobalRoot if needed
264
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
265
0
    }
266
0
  } else {
267
0
    arg0 = nullptr;
268
0
  }
269
0
  self->SetOnabort(Constify(arg0));
270
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
271
0
272
0
  return true;
273
0
}
274
275
static const JSJitInfo onabort_getterinfo = {
276
  { (JSJitGetterOp)get_onabort },
277
  { prototypes::id::IDBTransaction },
278
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
279
  JSJitInfo::Getter,
280
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
281
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
282
  false,  /* isInfallible. False in setters. */
283
  false,  /* isMovable.  Not relevant for setters. */
284
  false, /* isEliminatable.  Not relevant for setters. */
285
  false, /* isAlwaysInSlot.  Only relevant for getters. */
286
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
287
  false,  /* isTypedMethod.  Only relevant for methods. */
288
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
289
};
290
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
291
static_assert(0 < 1, "There is no slot for us");
292
static const JSJitInfo onabort_setterinfo = {
293
  { (JSJitGetterOp)set_onabort },
294
  { prototypes::id::IDBTransaction },
295
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
296
  JSJitInfo::Setter,
297
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
298
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
299
  false,  /* isInfallible. False in setters. */
300
  false,  /* isMovable.  Not relevant for setters. */
301
  false, /* isEliminatable.  Not relevant for setters. */
302
  false, /* isAlwaysInSlot.  Only relevant for getters. */
303
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
304
  false,  /* isTypedMethod.  Only relevant for methods. */
305
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
306
};
307
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
308
static_assert(0 < 1, "There is no slot for us");
309
310
MOZ_CAN_RUN_SCRIPT static bool
311
get_oncomplete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitGetterCallArgs args)
312
0
{
313
0
  AUTO_PROFILER_LABEL_FAST("get IDBTransaction.oncomplete", DOM, cx);
314
0
315
0
  RefPtr<EventHandlerNonNull> result(self->GetOncomplete());
316
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
317
0
  if (result) {
318
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
319
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
320
0
      return false;
321
0
    }
322
0
    return true;
323
0
  } else {
324
0
    args.rval().setNull();
325
0
    return true;
326
0
  }
327
0
}
328
329
MOZ_CAN_RUN_SCRIPT static bool
330
set_oncomplete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitSetterCallArgs args)
331
0
{
332
0
  AUTO_PROFILER_LABEL_FAST("set IDBTransaction.oncomplete", DOM, cx);
333
0
334
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
335
0
  if (args[0].isObject()) {
336
0
    { // scope for tempRoot and tempGlobalRoot if needed
337
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
338
0
    }
339
0
  } else {
340
0
    arg0 = nullptr;
341
0
  }
342
0
  self->SetOncomplete(Constify(arg0));
343
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
344
0
345
0
  return true;
346
0
}
347
348
static const JSJitInfo oncomplete_getterinfo = {
349
  { (JSJitGetterOp)get_oncomplete },
350
  { prototypes::id::IDBTransaction },
351
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
352
  JSJitInfo::Getter,
353
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
354
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
355
  false,  /* isInfallible. False in setters. */
356
  false,  /* isMovable.  Not relevant for setters. */
357
  false, /* isEliminatable.  Not relevant for setters. */
358
  false, /* isAlwaysInSlot.  Only relevant for getters. */
359
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
360
  false,  /* isTypedMethod.  Only relevant for methods. */
361
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
362
};
363
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
364
static_assert(0 < 1, "There is no slot for us");
365
static const JSJitInfo oncomplete_setterinfo = {
366
  { (JSJitGetterOp)set_oncomplete },
367
  { prototypes::id::IDBTransaction },
368
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
369
  JSJitInfo::Setter,
370
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
371
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
372
  false,  /* isInfallible. False in setters. */
373
  false,  /* isMovable.  Not relevant for setters. */
374
  false, /* isEliminatable.  Not relevant for setters. */
375
  false, /* isAlwaysInSlot.  Only relevant for getters. */
376
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
377
  false,  /* isTypedMethod.  Only relevant for methods. */
378
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
379
};
380
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
381
static_assert(0 < 1, "There is no slot for us");
382
383
MOZ_CAN_RUN_SCRIPT static bool
384
get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitGetterCallArgs args)
385
0
{
386
0
  AUTO_PROFILER_LABEL_FAST("get IDBTransaction.onerror", DOM, cx);
387
0
388
0
  RefPtr<EventHandlerNonNull> result(self->GetOnerror());
389
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
390
0
  if (result) {
391
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
392
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
393
0
      return false;
394
0
    }
395
0
    return true;
396
0
  } else {
397
0
    args.rval().setNull();
398
0
    return true;
399
0
  }
400
0
}
401
402
MOZ_CAN_RUN_SCRIPT static bool
403
set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitSetterCallArgs args)
404
0
{
405
0
  AUTO_PROFILER_LABEL_FAST("set IDBTransaction.onerror", DOM, cx);
406
0
407
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
408
0
  if (args[0].isObject()) {
409
0
    { // scope for tempRoot and tempGlobalRoot if needed
410
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
411
0
    }
412
0
  } else {
413
0
    arg0 = nullptr;
414
0
  }
415
0
  self->SetOnerror(Constify(arg0));
416
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
417
0
418
0
  return true;
419
0
}
420
421
static const JSJitInfo onerror_getterinfo = {
422
  { (JSJitGetterOp)get_onerror },
423
  { prototypes::id::IDBTransaction },
424
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
425
  JSJitInfo::Getter,
426
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
427
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
428
  false,  /* isInfallible. False in setters. */
429
  false,  /* isMovable.  Not relevant for setters. */
430
  false, /* isEliminatable.  Not relevant for setters. */
431
  false, /* isAlwaysInSlot.  Only relevant for getters. */
432
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
433
  false,  /* isTypedMethod.  Only relevant for methods. */
434
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
435
};
436
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
437
static_assert(0 < 1, "There is no slot for us");
438
static const JSJitInfo onerror_setterinfo = {
439
  { (JSJitGetterOp)set_onerror },
440
  { prototypes::id::IDBTransaction },
441
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
442
  JSJitInfo::Setter,
443
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
444
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
445
  false,  /* isInfallible. False in setters. */
446
  false,  /* isMovable.  Not relevant for setters. */
447
  false, /* isEliminatable.  Not relevant for setters. */
448
  false, /* isAlwaysInSlot.  Only relevant for getters. */
449
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
450
  false,  /* isTypedMethod.  Only relevant for methods. */
451
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
452
};
453
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
454
static_assert(0 < 1, "There is no slot for us");
455
456
MOZ_CAN_RUN_SCRIPT static bool
457
get_objectStoreNames(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBTransaction* self, JSJitGetterCallArgs args)
458
0
{
459
0
  AUTO_PROFILER_LABEL_FAST("get IDBTransaction.objectStoreNames", DOM, cx);
460
0
461
0
  auto result(StrongOrRawPtr<mozilla::dom::DOMStringList>(self->ObjectStoreNames()));
462
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
463
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
464
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
465
0
    return false;
466
0
  }
467
0
  return true;
468
0
}
469
470
static const JSJitInfo objectStoreNames_getterinfo = {
471
  { (JSJitGetterOp)get_objectStoreNames },
472
  { prototypes::id::IDBTransaction },
473
  { PrototypeTraits<prototypes::id::IDBTransaction>::Depth },
474
  JSJitInfo::Getter,
475
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
476
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
477
  false,  /* isInfallible. False in setters. */
478
  false,  /* isMovable.  Not relevant for setters. */
479
  false, /* isEliminatable.  Not relevant for setters. */
480
  false, /* isAlwaysInSlot.  Only relevant for getters. */
481
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
482
  false,  /* isTypedMethod.  Only relevant for methods. */
483
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
484
};
485
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
486
static_assert(0 < 1, "There is no slot for us");
487
488
static bool
489
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
490
0
{
491
0
  mozilla::dom::IDBTransaction* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBTransaction>(obj);
492
0
  // We don't want to preserve if we don't have a wrapper, and we
493
0
  // obviously can't preserve if we're not initialized.
494
0
  if (self && self->GetWrapperPreserveColor()) {
495
0
    PreserveWrapper(self);
496
0
  }
497
0
  return true;
498
0
}
499
500
static void
501
_finalize(js::FreeOp* fop, JSObject* obj)
502
0
{
503
0
  mozilla::dom::IDBTransaction* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBTransaction>(obj);
504
0
  if (self) {
505
0
    ClearWrapper(self, self, obj);
506
0
    AddForDeferredFinalization<mozilla::dom::IDBTransaction>(self);
507
0
  }
508
0
}
509
510
static size_t
511
_objectMoved(JSObject* obj, JSObject* old)
512
0
{
513
0
  mozilla::dom::IDBTransaction* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBTransaction>(obj);
514
0
  if (self) {
515
0
    UpdateWrapper(self, self, obj, old);
516
0
  }
517
0
518
0
  return 0;
519
0
}
520
521
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
522
#if defined(__clang__)
523
#pragma clang diagnostic push
524
#pragma clang diagnostic ignored "-Wmissing-braces"
525
#endif
526
static const JSFunctionSpec sMethods_specs[] = {
527
  JS_FNSPEC("objectStore", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&objectStore_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
528
  JS_FNSPEC("abort", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&abort_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
529
  JS_FS_END
530
};
531
#if defined(__clang__)
532
#pragma clang diagnostic pop
533
#endif
534
535
536
static const Prefable<const JSFunctionSpec> sMethods[] = {
537
  { nullptr, &sMethods_specs[0] },
538
  { nullptr, nullptr }
539
};
540
541
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
542
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
543
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
544
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
545
546
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
547
#if defined(__clang__)
548
#pragma clang diagnostic push
549
#pragma clang diagnostic ignored "-Wmissing-braces"
550
#endif
551
static const JSPropertySpec sAttributes_specs[] = {
552
  { "mode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mode_getterinfo, nullptr, nullptr },
553
  { "db", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &db_getterinfo, nullptr, nullptr },
554
  { "error", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &error_getterinfo, nullptr, nullptr },
555
  { "onabort", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onabort_getterinfo, GenericSetter<NormalThisPolicy>, &onabort_setterinfo },
556
  { "oncomplete", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &oncomplete_getterinfo, GenericSetter<NormalThisPolicy>, &oncomplete_setterinfo },
557
  { "onerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onerror_getterinfo, GenericSetter<NormalThisPolicy>, &onerror_setterinfo },
558
  { "objectStoreNames", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &objectStoreNames_getterinfo, nullptr, nullptr },
559
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
560
};
561
#if defined(__clang__)
562
#pragma clang diagnostic pop
563
#endif
564
565
566
static const Prefable<const JSPropertySpec> sAttributes[] = {
567
  { nullptr, &sAttributes_specs[0] },
568
  { nullptr, nullptr }
569
};
570
571
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
572
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
573
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
574
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
575
576
577
static uint16_t sNativeProperties_sortedPropertyIndices[9];
578
static PropertyInfo sNativeProperties_propertyInfos[9];
579
580
static const NativePropertiesN<2> sNativeProperties = {
581
  false, 0,
582
  false, 0,
583
  true,  0 /* sMethods */,
584
  true,  1 /* sAttributes */,
585
  false, 0,
586
  false, 0,
587
  false, 0,
588
  -1,
589
  9,
590
  sNativeProperties_sortedPropertyIndices,
591
  {
592
    { sMethods, &sNativeProperties_propertyInfos[0] },
593
    { sAttributes, &sNativeProperties_propertyInfos[2] }
594
  }
595
};
596
static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
597
    "We have a property info count that is oversized");
598
599
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
600
  {
601
    "Function",
602
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
603
    &sBoringInterfaceObjectClassClassOps,
604
    JS_NULL_CLASS_SPEC,
605
    JS_NULL_CLASS_EXT,
606
    &sInterfaceObjectClassObjectOps
607
  },
608
  eInterface,
609
  true,
610
  prototypes::id::IDBTransaction,
611
  PrototypeTraits<prototypes::id::IDBTransaction>::Depth,
612
  sNativePropertyHooks,
613
  "function IDBTransaction() {\n    [native code]\n}",
614
  EventTarget_Binding::GetConstructorObject
615
};
616
617
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
618
  {
619
    "IDBTransactionPrototype",
620
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
621
    JS_NULL_CLASS_OPS,
622
    JS_NULL_CLASS_SPEC,
623
    JS_NULL_CLASS_EXT,
624
    JS_NULL_OBJECT_OPS
625
  },
626
  eInterfacePrototype,
627
  false,
628
  prototypes::id::IDBTransaction,
629
  PrototypeTraits<prototypes::id::IDBTransaction>::Depth,
630
  sNativePropertyHooks,
631
  "[object IDBTransactionPrototype]",
632
  EventTarget_Binding::GetProtoObject
633
};
634
635
static const js::ClassOps sClassOps = {
636
  _addProperty, /* addProperty */
637
  nullptr,               /* delProperty */
638
  nullptr,               /* enumerate */
639
  nullptr, /* newEnumerate */
640
  nullptr, /* resolve */
641
  nullptr, /* mayResolve */
642
  _finalize, /* finalize */
643
  nullptr, /* call */
644
  nullptr,               /* hasInstance */
645
  nullptr,               /* construct */
646
  nullptr, /* trace */
647
};
648
649
static const js::ClassExtension sClassExtension = {
650
  nullptr, /* weakmapKeyDelegateOp */
651
  _objectMoved /* objectMovedOp */
652
};
653
654
static const DOMJSClass sClass = {
655
  { "IDBTransaction",
656
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
657
    &sClassOps,
658
    JS_NULL_CLASS_SPEC,
659
    &sClassExtension,
660
    JS_NULL_OBJECT_OPS
661
  },
662
  { prototypes::id::EventTarget, prototypes::id::IDBTransaction, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
663
  IsBaseOf<nsISupports, mozilla::dom::IDBTransaction >::value,
664
  sNativePropertyHooks,
665
  FindAssociatedGlobalForNative<mozilla::dom::IDBTransaction>::Get,
666
  GetProtoObjectHandle,
667
  GetCCParticipant<mozilla::dom::IDBTransaction>::Get()
668
};
669
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
670
              "Must have the right minimal number of reserved slots.");
671
static_assert(1 >= 1,
672
              "Must have enough reserved slots.");
673
674
const JSClass*
675
GetJSClass()
676
0
{
677
0
  return sClass.ToJSClass();
678
0
}
679
680
bool
681
Wrap(JSContext* aCx, mozilla::dom::IDBTransaction* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
682
0
{
683
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::IDBTransaction>::value,
684
0
                "Shouldn't have wrappercached things that are not refcounted.");
685
0
  MOZ_ASSERT(static_cast<mozilla::dom::IDBTransaction*>(aObject) ==
686
0
             reinterpret_cast<mozilla::dom::IDBTransaction*>(aObject),
687
0
             "Multiple inheritance for mozilla::dom::IDBTransaction is broken.");
688
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
689
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
690
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
691
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
692
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
693
0
  MOZ_ASSERT(!aCache->GetWrapper(),
694
0
             "You should probably not be using Wrap() directly; use "
695
0
             "GetOrCreateDOMReflector instead");
696
0
697
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
698
0
             "nsISupports must be on our primary inheritance chain");
699
0
700
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
701
0
  if (!global) {
702
0
    return false;
703
0
  }
704
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
705
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
706
0
707
0
  // That might have ended up wrapping us already, due to the wonders
708
0
  // of XBL.  Check for that, and bail out as needed.
709
0
  aReflector.set(aCache->GetWrapper());
710
0
  if (aReflector) {
711
#ifdef DEBUG
712
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
713
#endif // DEBUG
714
    return true;
715
0
  }
716
0
717
0
  JSAutoRealm ar(aCx, global);
718
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
719
0
  if (!canonicalProto) {
720
0
    return false;
721
0
  }
722
0
  JS::Rooted<JSObject*> proto(aCx);
723
0
  if (aGivenProto) {
724
0
    proto = aGivenProto;
725
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
726
0
    // coming in, we changed compartments to that of "parent" so may need
727
0
    // to wrap the proto here.
728
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
729
0
      if (!JS_WrapObject(aCx, &proto)) {
730
0
        return false;
731
0
      }
732
0
    }
733
0
  } else {
734
0
    proto = canonicalProto;
735
0
  }
736
0
737
0
  BindingJSObjectCreator<mozilla::dom::IDBTransaction> creator(aCx);
738
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
739
0
  if (!aReflector) {
740
0
    return false;
741
0
  }
742
0
743
0
  aCache->SetWrapper(aReflector);
744
0
  creator.InitializationSucceeded();
745
0
746
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
747
0
             aCache->GetWrapperPreserveColor() == aReflector);
748
0
  // If proto != canonicalProto, we have to preserve our wrapper;
749
0
  // otherwise we won't be able to properly recreate it later, since
750
0
  // we won't know what proto to use.  Note that we don't check
751
0
  // aGivenProto here, since it's entirely possible (and even
752
0
  // somewhat common) to have a non-null aGivenProto which is the
753
0
  // same as canonicalProto.
754
0
  if (proto != canonicalProto) {
755
0
    PreserveWrapper(aObject);
756
0
  }
757
0
758
0
  return true;
759
0
}
760
761
const NativePropertyHooks sNativePropertyHooks[] = { {
762
  nullptr,
763
  nullptr,
764
  nullptr,
765
  { sNativeProperties.Upcast(), nullptr },
766
  prototypes::id::IDBTransaction,
767
  constructors::id::IDBTransaction,
768
  EventTarget_Binding::sNativePropertyHooks,
769
  &DefaultXrayExpandoObjectClass
770
} };
771
772
void
773
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
774
0
{
775
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
776
0
  if (!parentProto) {
777
0
    return;
778
0
  }
779
0
780
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
781
0
  if (!constructorProto) {
782
0
    return;
783
0
  }
784
0
785
0
  static bool sIdsInited = false;
786
0
  if (!sIdsInited && NS_IsMainThread()) {
787
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
788
0
      return;
789
0
    }
790
0
    sIdsInited = true;
791
0
  }
792
0
793
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBTransaction);
794
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBTransaction);
795
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
796
0
                              &sPrototypeClass.mBase, protoCache,
797
0
                              nullptr,
798
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
799
0
                              interfaceCache,
800
0
                              sNativeProperties.Upcast(),
801
0
                              nullptr,
802
0
                              "IDBTransaction", aDefineOnGlobal,
803
0
                              nullptr,
804
0
                              false);
805
0
}
806
807
JSObject*
808
GetConstructorObject(JSContext* aCx)
809
0
{
810
0
  return GetConstructorObjectHandle(aCx);
811
0
}
812
813
} // namespace IDBTransaction_Binding
814
815
816
817
} // namespace dom
818
} // namespace mozilla