Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/FileReaderSyncBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM FileReaderSync.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "FileReaderSyncBinding.h"
4
#include "WrapperFactory.h"
5
#include "jsfriendapi.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/Blob.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/FileReaderSync.h"
11
#include "mozilla/dom/NonRefcountedDOMObject.h"
12
#include "mozilla/dom/TypedArray.h"
13
#include "nsThreadUtils.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
namespace binding_detail {}; // Just to make sure it's known as a namespace
19
using namespace mozilla::dom::binding_detail;
20
21
22
namespace FileReaderSync_Binding {
23
24
MOZ_CAN_RUN_SCRIPT static bool
25
readAsArrayBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
26
0
{
27
0
  AUTO_PROFILER_LABEL_FAST("FileReaderSync.readAsArrayBuffer", DOM, cx);
28
0
29
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
30
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsArrayBuffer");
31
0
  }
32
0
  JS::Rooted<JSObject*> unwrappedObj(cx, js::CheckedUnwrap(obj));
33
0
  // Caller should have ensured that "obj" can be unwrapped already.
34
0
  MOZ_DIAGNOSTIC_ASSERT(unwrappedObj);
35
0
  NonNull<mozilla::dom::Blob> arg0;
36
0
  if (args[0].isObject()) {
37
0
    {
38
0
      nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
39
0
      if (NS_FAILED(rv)) {
40
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsArrayBuffer", "Blob");
41
0
        return false;
42
0
      }
43
0
    }
44
0
  } else {
45
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsArrayBuffer");
46
0
    return false;
47
0
  }
48
0
  FastErrorResult rv;
49
0
  JS::Rooted<JSObject*> result(cx);
50
0
  self->ReadAsArrayBuffer(cx, unwrappedObj, MOZ_KnownLive(NonNullHelper(arg0)), &result, rv);
51
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
52
0
    return false;
53
0
  }
54
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
55
0
  JS::ExposeObjectToActiveJS(result);
56
0
  args.rval().setObject(*result);
57
0
  if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
58
0
    return false;
59
0
  }
60
0
  return true;
61
0
}
62
63
static const JSJitInfo readAsArrayBuffer_methodinfo = {
64
  { (JSJitGetterOp)readAsArrayBuffer },
65
  { prototypes::id::FileReaderSync },
66
  { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
67
  JSJitInfo::Method,
68
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
69
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
70
  false,  /* isInfallible. False in setters. */
71
  false,  /* isMovable.  Not relevant for setters. */
72
  false, /* isEliminatable.  Not relevant for setters. */
73
  false, /* isAlwaysInSlot.  Only relevant for getters. */
74
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
75
  false,  /* isTypedMethod.  Only relevant for methods. */
76
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
77
};
78
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
79
static_assert(0 < 1, "There is no slot for us");
80
81
MOZ_CAN_RUN_SCRIPT static bool
82
readAsBinaryString(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
83
0
{
84
0
  AUTO_PROFILER_LABEL_FAST("FileReaderSync.readAsBinaryString", DOM, cx);
85
0
86
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
87
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsBinaryString");
88
0
  }
89
0
  NonNull<mozilla::dom::Blob> arg0;
90
0
  if (args[0].isObject()) {
91
0
    {
92
0
      nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
93
0
      if (NS_FAILED(rv)) {
94
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsBinaryString", "Blob");
95
0
        return false;
96
0
      }
97
0
    }
98
0
  } else {
99
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsBinaryString");
100
0
    return false;
101
0
  }
102
0
  FastErrorResult rv;
103
0
  DOMString result;
104
0
  self->ReadAsBinaryString(MOZ_KnownLive(NonNullHelper(arg0)), result, rv);
105
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
106
0
    return false;
107
0
  }
108
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
109
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
110
0
    return false;
111
0
  }
112
0
  return true;
113
0
}
114
115
static const JSJitInfo readAsBinaryString_methodinfo = {
116
  { (JSJitGetterOp)readAsBinaryString },
117
  { prototypes::id::FileReaderSync },
118
  { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
119
  JSJitInfo::Method,
120
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
121
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
122
  false,  /* isInfallible. False in setters. */
123
  false,  /* isMovable.  Not relevant for setters. */
124
  false, /* isEliminatable.  Not relevant for setters. */
125
  false, /* isAlwaysInSlot.  Only relevant for getters. */
126
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
127
  false,  /* isTypedMethod.  Only relevant for methods. */
128
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
129
};
130
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
131
static_assert(0 < 1, "There is no slot for us");
132
133
MOZ_CAN_RUN_SCRIPT static bool
134
readAsText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
135
0
{
136
0
  AUTO_PROFILER_LABEL_FAST("FileReaderSync.readAsText", DOM, cx);
137
0
138
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
139
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsText");
140
0
  }
141
0
  NonNull<mozilla::dom::Blob> arg0;
142
0
  if (args[0].isObject()) {
143
0
    {
144
0
      nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
145
0
      if (NS_FAILED(rv)) {
146
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsText", "Blob");
147
0
        return false;
148
0
      }
149
0
    }
150
0
  } else {
151
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsText");
152
0
    return false;
153
0
  }
154
0
  Optional<nsAString> arg1;
155
0
  binding_detail::FakeString arg1_holder;
156
0
  if (args.hasDefined(1)) {
157
0
    if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1_holder)) {
158
0
      return false;
159
0
    }
160
0
    arg1 = &arg1_holder;
161
0
  }
162
0
  FastErrorResult rv;
163
0
  DOMString result;
164
0
  self->ReadAsText(MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1)), result, rv);
165
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
166
0
    return false;
167
0
  }
168
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
169
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
170
0
    return false;
171
0
  }
172
0
  return true;
173
0
}
174
175
static const JSJitInfo readAsText_methodinfo = {
176
  { (JSJitGetterOp)readAsText },
177
  { prototypes::id::FileReaderSync },
178
  { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
179
  JSJitInfo::Method,
180
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
181
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
182
  false,  /* isInfallible. False in setters. */
183
  false,  /* isMovable.  Not relevant for setters. */
184
  false, /* isEliminatable.  Not relevant for setters. */
185
  false, /* isAlwaysInSlot.  Only relevant for getters. */
186
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
187
  false,  /* isTypedMethod.  Only relevant for methods. */
188
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
189
};
190
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
191
static_assert(0 < 1, "There is no slot for us");
192
193
MOZ_CAN_RUN_SCRIPT static bool
194
readAsDataURL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileReaderSync* self, const JSJitMethodCallArgs& args)
195
0
{
196
0
  AUTO_PROFILER_LABEL_FAST("FileReaderSync.readAsDataURL", DOM, cx);
197
0
198
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
199
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileReaderSync.readAsDataURL");
200
0
  }
201
0
  NonNull<mozilla::dom::Blob> arg0;
202
0
  if (args[0].isObject()) {
203
0
    {
204
0
      nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
205
0
      if (NS_FAILED(rv)) {
206
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FileReaderSync.readAsDataURL", "Blob");
207
0
        return false;
208
0
      }
209
0
    }
210
0
  } else {
211
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileReaderSync.readAsDataURL");
212
0
    return false;
213
0
  }
214
0
  FastErrorResult rv;
215
0
  DOMString result;
216
0
  self->ReadAsDataURL(MOZ_KnownLive(NonNullHelper(arg0)), result, rv);
217
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
218
0
    return false;
219
0
  }
220
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
221
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
222
0
    return false;
223
0
  }
224
0
  return true;
225
0
}
226
227
static const JSJitInfo readAsDataURL_methodinfo = {
228
  { (JSJitGetterOp)readAsDataURL },
229
  { prototypes::id::FileReaderSync },
230
  { PrototypeTraits<prototypes::id::FileReaderSync>::Depth },
231
  JSJitInfo::Method,
232
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
233
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
234
  false,  /* isInfallible. False in setters. */
235
  false,  /* isMovable.  Not relevant for setters. */
236
  false, /* isEliminatable.  Not relevant for setters. */
237
  false, /* isAlwaysInSlot.  Only relevant for getters. */
238
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
239
  false,  /* isTypedMethod.  Only relevant for methods. */
240
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
241
};
242
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
243
static_assert(0 < 1, "There is no slot for us");
244
245
static void
246
_finalize(js::FreeOp* fop, JSObject* obj)
247
0
{
248
0
  mozilla::dom::FileReaderSync* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FileReaderSync>(obj);
249
0
  if (self) {
250
0
    AddForDeferredFinalization<mozilla::dom::FileReaderSync>(self);
251
0
  }
252
0
}
253
254
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
255
#if defined(__clang__)
256
#pragma clang diagnostic push
257
#pragma clang diagnostic ignored "-Wmissing-braces"
258
#endif
259
static const JSFunctionSpec sMethods_specs[] = {
260
  JS_FNSPEC("readAsArrayBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&readAsArrayBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
261
  JS_FNSPEC("readAsBinaryString", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&readAsBinaryString_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
262
  JS_FNSPEC("readAsText", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&readAsText_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
263
  JS_FNSPEC("readAsDataURL", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&readAsDataURL_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
264
  JS_FS_END
265
};
266
#if defined(__clang__)
267
#pragma clang diagnostic pop
268
#endif
269
270
271
static const Prefable<const JSFunctionSpec> sMethods[] = {
272
  { nullptr, &sMethods_specs[0] },
273
  { nullptr, nullptr }
274
};
275
276
277
static const NativePropertiesN<1> sNativeProperties = {
278
  false, 0,
279
  false, 0,
280
  true,  0 /* sMethods */,
281
  false, 0,
282
  false, 0,
283
  false, 0,
284
  false, 0,
285
  -1,
286
  0,
287
  nullptr,
288
  {
289
    { sMethods, nullptr }
290
  }
291
};
292
293
static bool
294
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
295
0
{
296
0
  AUTO_PROFILER_LABEL_FAST("FileReaderSync constructor", DOM, cx);
297
0
298
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
299
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
300
0
  if (!args.isConstructing()) {
301
0
    // XXXbz wish I could get the name from the callee instead of
302
0
    // Adding more relocations
303
0
    return ThrowConstructorWithoutNew(cx, "FileReaderSync");
304
0
  }
305
0
306
0
  JS::Rooted<JSObject*> desiredProto(cx);
307
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
308
0
    return false;
309
0
  }
310
0
311
0
  GlobalObject global(cx, obj);
312
0
  if (global.Failed()) {
313
0
    return false;
314
0
  }
315
0
316
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
317
0
  Maybe<JSAutoRealm> ar;
318
0
  if (objIsXray) {
319
0
    obj = js::CheckedUnwrap(obj);
320
0
    if (!obj) {
321
0
      return false;
322
0
    }
323
0
    ar.emplace(cx, obj);
324
0
    if (!JS_WrapObject(cx, &desiredProto)) {
325
0
      return false;
326
0
    }
327
0
  }
328
0
  FastErrorResult rv;
329
0
  auto result(StrongOrRawPtr<mozilla::dom::FileReaderSync>(mozilla::dom::FileReaderSync::Constructor(global, rv)));
330
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
331
0
    return false;
332
0
  }
333
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
334
0
  static_assert(!IsPointer<decltype(result)>::value,
335
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
336
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval(), desiredProto)) {
337
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
338
0
    return false;
339
0
  }
340
0
  return true;
341
0
}
342
343
static const js::ClassOps sInterfaceObjectClassOps = {
344
    nullptr,               /* addProperty */
345
    nullptr,               /* delProperty */
346
    nullptr,               /* enumerate */
347
    nullptr,               /* newEnumerate */
348
    nullptr,               /* resolve */
349
    nullptr,               /* mayResolve */
350
    nullptr,               /* finalize */
351
    _constructor, /* call */
352
    nullptr,               /* hasInstance */
353
    _constructor, /* construct */
354
    nullptr,               /* trace */
355
};
356
357
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
358
  {
359
    "Function",
360
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
361
    &sInterfaceObjectClassOps,
362
    JS_NULL_CLASS_SPEC,
363
    JS_NULL_CLASS_EXT,
364
    &sInterfaceObjectClassObjectOps
365
  },
366
  eInterface,
367
  true,
368
  prototypes::id::FileReaderSync,
369
  PrototypeTraits<prototypes::id::FileReaderSync>::Depth,
370
  &sEmptyNativePropertyHooks,
371
  "function FileReaderSync() {\n    [native code]\n}",
372
  JS::GetRealmFunctionPrototype
373
};
374
375
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
376
  {
377
    "FileReaderSyncPrototype",
378
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
379
    JS_NULL_CLASS_OPS,
380
    JS_NULL_CLASS_SPEC,
381
    JS_NULL_CLASS_EXT,
382
    JS_NULL_OBJECT_OPS
383
  },
384
  eInterfacePrototype,
385
  false,
386
  prototypes::id::FileReaderSync,
387
  PrototypeTraits<prototypes::id::FileReaderSync>::Depth,
388
  &sEmptyNativePropertyHooks,
389
  "[object FileReaderSyncPrototype]",
390
  JS::GetRealmObjectPrototype
391
};
392
393
bool
394
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
395
0
{
396
0
  MOZ_ASSERT(!NS_IsMainThread(), "Why did we even get called?");
397
0
398
0
  const char* name = js::GetObjectClass(aObj)->name;
399
0
  if (strcmp(name, "DedicatedWorkerGlobalScope") && strcmp(name, "SharedWorkerGlobalScope")) {
400
0
    return false;
401
0
  }
402
0
403
0
  return true;
404
0
}
405
406
static const js::ClassOps sClassOps = {
407
  nullptr, /* addProperty */
408
  nullptr,               /* delProperty */
409
  nullptr,               /* enumerate */
410
  nullptr, /* newEnumerate */
411
  nullptr, /* resolve */
412
  nullptr, /* mayResolve */
413
  _finalize, /* finalize */
414
  nullptr, /* call */
415
  nullptr,               /* hasInstance */
416
  nullptr,               /* construct */
417
  nullptr, /* trace */
418
};
419
420
static const js::ClassExtension sClassExtension = {
421
  nullptr, /* weakmapKeyDelegateOp */
422
  nullptr /* objectMovedOp */
423
};
424
425
static const DOMJSClass sClass = {
426
  { "FileReaderSync",
427
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
428
    &sClassOps,
429
    JS_NULL_CLASS_SPEC,
430
    &sClassExtension,
431
    JS_NULL_OBJECT_OPS
432
  },
433
  { prototypes::id::FileReaderSync, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
434
  IsBaseOf<nsISupports, mozilla::dom::FileReaderSync >::value,
435
  &sEmptyNativePropertyHooks,
436
  FindAssociatedGlobalForNative<mozilla::dom::FileReaderSync>::Get,
437
  GetProtoObjectHandle,
438
  GetCCParticipant<mozilla::dom::FileReaderSync>::Get()
439
};
440
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
441
              "Must have the right minimal number of reserved slots.");
442
static_assert(1 >= 1,
443
              "Must have enough reserved slots.");
444
445
const JSClass*
446
GetJSClass()
447
0
{
448
0
  return sClass.ToJSClass();
449
0
}
450
451
bool
452
Wrap(JSContext* aCx, mozilla::dom::FileReaderSync* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
453
0
{
454
0
  MOZ_ASSERT(static_cast<mozilla::dom::FileReaderSync*>(aObject) ==
455
0
             reinterpret_cast<mozilla::dom::FileReaderSync*>(aObject),
456
0
             "Multiple inheritance for mozilla::dom::FileReaderSync is broken.");
457
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
458
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
459
0
460
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
461
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
462
0
  if (!canonicalProto) {
463
0
    return false;
464
0
  }
465
0
  JS::Rooted<JSObject*> proto(aCx);
466
0
  if (aGivenProto) {
467
0
    proto = aGivenProto;
468
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
469
0
    // coming in, we changed compartments to that of "parent" so may need
470
0
    // to wrap the proto here.
471
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
472
0
      if (!JS_WrapObject(aCx, &proto)) {
473
0
        return false;
474
0
      }
475
0
    }
476
0
  } else {
477
0
    proto = canonicalProto;
478
0
  }
479
0
480
0
  BindingJSObjectCreator<mozilla::dom::FileReaderSync> creator(aCx);
481
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
482
0
  if (!aReflector) {
483
0
    return false;
484
0
  }
485
0
486
0
487
0
488
0
  creator.InitializationSucceeded();
489
0
  return true;
490
0
}
491
492
void
493
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
494
0
{
495
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
496
0
  if (!parentProto) {
497
0
    return;
498
0
  }
499
0
500
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
501
0
  if (!constructorProto) {
502
0
    return;
503
0
  }
504
0
505
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FileReaderSync);
506
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FileReaderSync);
507
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
508
0
                              &sPrototypeClass.mBase, protoCache,
509
0
                              nullptr,
510
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
511
0
                              interfaceCache,
512
0
                              sNativeProperties.Upcast(),
513
0
                              nullptr,
514
0
                              "FileReaderSync", aDefineOnGlobal,
515
0
                              nullptr,
516
0
                              false);
517
0
}
518
519
JSObject*
520
GetConstructorObject(JSContext* aCx)
521
0
{
522
0
  return GetConstructorObjectHandle(aCx);
523
0
}
524
525
} // namespace FileReaderSync_Binding
526
527
528
529
} // namespace dom
530
} // namespace mozilla