Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/MediaKeySessionBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM MediaKeySession.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "EventHandlerBinding.h"
4
#include "EventTargetBinding.h"
5
#include "MediaKeySessionBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/MediaKeyError.h"
11
#include "mozilla/dom/MediaKeySession.h"
12
#include "mozilla/dom/MediaKeyStatusMap.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/Promise.h"
17
#include "mozilla/dom/ToJSValue.h"
18
#include "mozilla/dom/UnionConversions.h"
19
#include "mozilla/dom/UnionTypes.h"
20
#include "mozilla/dom/XrayExpandoClass.h"
21
22
namespace mozilla {
23
namespace dom {
24
25
namespace binding_detail {}; // Just to make sure it's known as a namespace
26
using namespace mozilla::dom::binding_detail;
27
28
29
namespace MediaKeySession_Binding {
30
31
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
32
              "Can't inherit from an interface with a different ownership model.");
33
34
MOZ_CAN_RUN_SCRIPT static bool
35
get_error(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
36
0
{
37
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeySession.error", DOM, cx);
38
0
39
0
  auto result(StrongOrRawPtr<mozilla::dom::MediaKeyError>(self->GetError()));
40
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
41
0
  if (!result) {
42
0
    args.rval().setNull();
43
0
    return true;
44
0
  }
45
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
46
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
47
0
    return false;
48
0
  }
49
0
  return true;
50
0
}
51
52
static const JSJitInfo error_getterinfo = {
53
  { (JSJitGetterOp)get_error },
54
  { prototypes::id::MediaKeySession },
55
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
56
  JSJitInfo::Getter,
57
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
58
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
59
  false,  /* isInfallible. False in setters. */
60
  false,  /* isMovable.  Not relevant for setters. */
61
  false, /* isEliminatable.  Not relevant for setters. */
62
  false, /* isAlwaysInSlot.  Only relevant for getters. */
63
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
64
  false,  /* isTypedMethod.  Only relevant for methods. */
65
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
66
};
67
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
68
static_assert(0 < 1, "There is no slot for us");
69
70
MOZ_CAN_RUN_SCRIPT static bool
71
get_sessionId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
72
0
{
73
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeySession.sessionId", DOM, cx);
74
0
75
0
  DOMString result;
76
0
  self->GetSessionId(result);
77
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
78
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
79
0
    return false;
80
0
  }
81
0
  return true;
82
0
}
83
84
static const JSJitInfo sessionId_getterinfo = {
85
  { (JSJitGetterOp)get_sessionId },
86
  { prototypes::id::MediaKeySession },
87
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
88
  JSJitInfo::Getter,
89
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
90
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
91
  false,  /* isInfallible. False in setters. */
92
  false,  /* isMovable.  Not relevant for setters. */
93
  false, /* isEliminatable.  Not relevant for setters. */
94
  false, /* isAlwaysInSlot.  Only relevant for getters. */
95
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
96
  false,  /* isTypedMethod.  Only relevant for methods. */
97
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
98
};
99
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
100
static_assert(0 < 1, "There is no slot for us");
101
102
MOZ_CAN_RUN_SCRIPT static bool
103
get_expiration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
104
0
{
105
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeySession.expiration", DOM, cx);
106
0
107
0
  double result(self->Expiration());
108
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
109
0
  args.rval().set(JS_NumberValue(double(result)));
110
0
  return true;
111
0
}
112
113
static const JSJitInfo expiration_getterinfo = {
114
  { (JSJitGetterOp)get_expiration },
115
  { prototypes::id::MediaKeySession },
116
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
117
  JSJitInfo::Getter,
118
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
119
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
120
  true,  /* isInfallible. False in setters. */
121
  false,  /* isMovable.  Not relevant for setters. */
122
  false, /* isEliminatable.  Not relevant for setters. */
123
  false, /* isAlwaysInSlot.  Only relevant for getters. */
124
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
125
  false,  /* isTypedMethod.  Only relevant for methods. */
126
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
127
};
128
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
129
static_assert(0 < 1, "There is no slot for us");
130
131
MOZ_CAN_RUN_SCRIPT static bool
132
get_closed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
133
0
{
134
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeySession.closed", DOM, cx);
135
0
136
0
  auto result(StrongOrRawPtr<Promise>(self->Closed()));
137
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
138
0
  if (!ToJSValue(cx, result, args.rval())) {
139
0
    return false;
140
0
  }
141
0
  return true;
142
0
}
143
144
MOZ_CAN_RUN_SCRIPT static bool
145
get_closed_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
146
0
{
147
0
  bool ok = get_closed(cx, obj, self, args);
148
0
  if (ok) {
149
0
    return true;
150
0
  }
151
0
  return ConvertExceptionToPromise(cx, args.rval());
152
0
}
153
154
static const JSJitInfo closed_getterinfo = {
155
  { (JSJitGetterOp)get_closed_promiseWrapper },
156
  { prototypes::id::MediaKeySession },
157
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
158
  JSJitInfo::Getter,
159
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
160
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
161
  false,  /* isInfallible. False in setters. */
162
  false,  /* isMovable.  Not relevant for setters. */
163
  false, /* isEliminatable.  Not relevant for setters. */
164
  false, /* isAlwaysInSlot.  Only relevant for getters. */
165
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
166
  false,  /* isTypedMethod.  Only relevant for methods. */
167
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
168
};
169
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
170
static_assert(0 < 1, "There is no slot for us");
171
172
MOZ_CAN_RUN_SCRIPT static bool
173
get_keyStatuses(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
174
0
{
175
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeySession.keyStatuses", DOM, cx);
176
0
177
0
  auto result(StrongOrRawPtr<mozilla::dom::MediaKeyStatusMap>(self->KeyStatuses()));
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 keyStatuses_getterinfo = {
187
  { (JSJitGetterOp)get_keyStatuses },
188
  { prototypes::id::MediaKeySession },
189
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
190
  JSJitInfo::Getter,
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
get_onkeystatuseschange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
206
0
{
207
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeySession.onkeystatuseschange", DOM, cx);
208
0
209
0
  RefPtr<EventHandlerNonNull> result(self->GetOnkeystatuseschange());
210
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
211
0
  if (result) {
212
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
213
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
214
0
      return false;
215
0
    }
216
0
    return true;
217
0
  } else {
218
0
    args.rval().setNull();
219
0
    return true;
220
0
  }
221
0
}
222
223
MOZ_CAN_RUN_SCRIPT static bool
224
set_onkeystatuseschange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitSetterCallArgs args)
225
0
{
226
0
  AUTO_PROFILER_LABEL_FAST("set MediaKeySession.onkeystatuseschange", DOM, cx);
227
0
228
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
229
0
  if (args[0].isObject()) {
230
0
    { // scope for tempRoot and tempGlobalRoot if needed
231
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
232
0
    }
233
0
  } else {
234
0
    arg0 = nullptr;
235
0
  }
236
0
  self->SetOnkeystatuseschange(Constify(arg0));
237
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
238
0
239
0
  return true;
240
0
}
241
242
static const JSJitInfo onkeystatuseschange_getterinfo = {
243
  { (JSJitGetterOp)get_onkeystatuseschange },
244
  { prototypes::id::MediaKeySession },
245
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
246
  JSJitInfo::Getter,
247
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
248
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
249
  false,  /* isInfallible. False in setters. */
250
  false,  /* isMovable.  Not relevant for setters. */
251
  false, /* isEliminatable.  Not relevant for setters. */
252
  false, /* isAlwaysInSlot.  Only relevant for getters. */
253
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
254
  false,  /* isTypedMethod.  Only relevant for methods. */
255
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
256
};
257
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
258
static_assert(0 < 1, "There is no slot for us");
259
static const JSJitInfo onkeystatuseschange_setterinfo = {
260
  { (JSJitGetterOp)set_onkeystatuseschange },
261
  { prototypes::id::MediaKeySession },
262
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
263
  JSJitInfo::Setter,
264
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
265
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
266
  false,  /* isInfallible. False in setters. */
267
  false,  /* isMovable.  Not relevant for setters. */
268
  false, /* isEliminatable.  Not relevant for setters. */
269
  false, /* isAlwaysInSlot.  Only relevant for getters. */
270
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
271
  false,  /* isTypedMethod.  Only relevant for methods. */
272
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
273
};
274
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
275
static_assert(0 < 1, "There is no slot for us");
276
277
MOZ_CAN_RUN_SCRIPT static bool
278
get_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
279
0
{
280
0
  AUTO_PROFILER_LABEL_FAST("get MediaKeySession.onmessage", DOM, cx);
281
0
282
0
  RefPtr<EventHandlerNonNull> result(self->GetOnmessage());
283
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
284
0
  if (result) {
285
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
286
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
287
0
      return false;
288
0
    }
289
0
    return true;
290
0
  } else {
291
0
    args.rval().setNull();
292
0
    return true;
293
0
  }
294
0
}
295
296
MOZ_CAN_RUN_SCRIPT static bool
297
set_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitSetterCallArgs args)
298
0
{
299
0
  AUTO_PROFILER_LABEL_FAST("set MediaKeySession.onmessage", DOM, cx);
300
0
301
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
302
0
  if (args[0].isObject()) {
303
0
    { // scope for tempRoot and tempGlobalRoot if needed
304
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
305
0
    }
306
0
  } else {
307
0
    arg0 = nullptr;
308
0
  }
309
0
  self->SetOnmessage(Constify(arg0));
310
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
311
0
312
0
  return true;
313
0
}
314
315
static const JSJitInfo onmessage_getterinfo = {
316
  { (JSJitGetterOp)get_onmessage },
317
  { prototypes::id::MediaKeySession },
318
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
319
  JSJitInfo::Getter,
320
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
321
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
322
  false,  /* isInfallible. False in setters. */
323
  false,  /* isMovable.  Not relevant for setters. */
324
  false, /* isEliminatable.  Not relevant for setters. */
325
  false, /* isAlwaysInSlot.  Only relevant for getters. */
326
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
327
  false,  /* isTypedMethod.  Only relevant for methods. */
328
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
329
};
330
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
331
static_assert(0 < 1, "There is no slot for us");
332
static const JSJitInfo onmessage_setterinfo = {
333
  { (JSJitGetterOp)set_onmessage },
334
  { prototypes::id::MediaKeySession },
335
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
336
  JSJitInfo::Setter,
337
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
338
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
339
  false,  /* isInfallible. False in setters. */
340
  false,  /* isMovable.  Not relevant for setters. */
341
  false, /* isEliminatable.  Not relevant for setters. */
342
  false, /* isAlwaysInSlot.  Only relevant for getters. */
343
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
344
  false,  /* isTypedMethod.  Only relevant for methods. */
345
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
346
};
347
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
348
static_assert(0 < 1, "There is no slot for us");
349
350
MOZ_CAN_RUN_SCRIPT static bool
351
generateRequest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
352
0
{
353
0
  AUTO_PROFILER_LABEL_FAST("MediaKeySession.generateRequest", DOM, cx);
354
0
355
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
356
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeySession.generateRequest");
357
0
  }
358
0
  binding_detail::FakeString arg0;
359
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
360
0
    return false;
361
0
  }
362
0
  ArrayBufferViewOrArrayBuffer arg1;
363
0
  ArrayBufferViewOrArrayBufferArgument arg1_holder(arg1);
364
0
  {
365
0
    bool done = false, failed = false, tryNext;
366
0
    if (args[1].isObject()) {
367
0
      done = (failed = !arg1_holder.TrySetToArrayBufferView(cx, args[1], tryNext, false)) || !tryNext ||
368
0
             (failed = !arg1_holder.TrySetToArrayBuffer(cx, args[1], tryNext, false)) || !tryNext;
369
0
370
0
    }
371
0
    if (failed) {
372
0
      return false;
373
0
    }
374
0
    if (!done) {
375
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of MediaKeySession.generateRequest", "ArrayBufferView, ArrayBuffer");
376
0
      return false;
377
0
    }
378
0
  }
379
0
  FastErrorResult rv;
380
0
  auto result(StrongOrRawPtr<Promise>(self->GenerateRequest(NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
381
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
382
0
    return false;
383
0
  }
384
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
385
0
  static_assert(!IsPointer<decltype(result)>::value,
386
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
387
0
  if (!ToJSValue(cx, result, args.rval())) {
388
0
    return false;
389
0
  }
390
0
  return true;
391
0
}
392
393
MOZ_CAN_RUN_SCRIPT static bool
394
generateRequest_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
395
0
{
396
0
  bool ok = generateRequest(cx, obj, self, args);
397
0
  if (ok) {
398
0
    return true;
399
0
  }
400
0
  return ConvertExceptionToPromise(cx, args.rval());
401
0
}
402
403
static const JSJitInfo generateRequest_methodinfo = {
404
  { (JSJitGetterOp)generateRequest_promiseWrapper },
405
  { prototypes::id::MediaKeySession },
406
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
407
  JSJitInfo::Method,
408
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
409
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
410
  false,  /* isInfallible. False in setters. */
411
  false,  /* isMovable.  Not relevant for setters. */
412
  false, /* isEliminatable.  Not relevant for setters. */
413
  false, /* isAlwaysInSlot.  Only relevant for getters. */
414
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
415
  false,  /* isTypedMethod.  Only relevant for methods. */
416
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
417
};
418
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
419
static_assert(0 < 1, "There is no slot for us");
420
421
MOZ_CAN_RUN_SCRIPT static bool
422
load(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
423
0
{
424
0
  AUTO_PROFILER_LABEL_FAST("MediaKeySession.load", DOM, cx);
425
0
426
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
427
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeySession.load");
428
0
  }
429
0
  binding_detail::FakeString arg0;
430
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
431
0
    return false;
432
0
  }
433
0
  FastErrorResult rv;
434
0
  auto result(StrongOrRawPtr<Promise>(self->Load(NonNullHelper(Constify(arg0)), rv)));
435
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
436
0
    return false;
437
0
  }
438
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
439
0
  static_assert(!IsPointer<decltype(result)>::value,
440
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
441
0
  if (!ToJSValue(cx, result, args.rval())) {
442
0
    return false;
443
0
  }
444
0
  return true;
445
0
}
446
447
MOZ_CAN_RUN_SCRIPT static bool
448
load_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
449
0
{
450
0
  bool ok = load(cx, obj, self, args);
451
0
  if (ok) {
452
0
    return true;
453
0
  }
454
0
  return ConvertExceptionToPromise(cx, args.rval());
455
0
}
456
457
static const JSJitInfo load_methodinfo = {
458
  { (JSJitGetterOp)load_promiseWrapper },
459
  { prototypes::id::MediaKeySession },
460
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
461
  JSJitInfo::Method,
462
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
463
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
464
  false,  /* isInfallible. False in setters. */
465
  false,  /* isMovable.  Not relevant for setters. */
466
  false, /* isEliminatable.  Not relevant for setters. */
467
  false, /* isAlwaysInSlot.  Only relevant for getters. */
468
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
469
  false,  /* isTypedMethod.  Only relevant for methods. */
470
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
471
};
472
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
473
static_assert(0 < 1, "There is no slot for us");
474
475
MOZ_CAN_RUN_SCRIPT static bool
476
update(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
477
0
{
478
0
  AUTO_PROFILER_LABEL_FAST("MediaKeySession.update", DOM, cx);
479
0
480
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
481
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeySession.update");
482
0
  }
483
0
  ArrayBufferViewOrArrayBuffer arg0;
484
0
  ArrayBufferViewOrArrayBufferArgument arg0_holder(arg0);
485
0
  {
486
0
    bool done = false, failed = false, tryNext;
487
0
    if (args[0].isObject()) {
488
0
      done = (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext ||
489
0
             (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext;
490
0
491
0
    }
492
0
    if (failed) {
493
0
      return false;
494
0
    }
495
0
    if (!done) {
496
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of MediaKeySession.update", "ArrayBufferView, ArrayBuffer");
497
0
      return false;
498
0
    }
499
0
  }
500
0
  FastErrorResult rv;
501
0
  auto result(StrongOrRawPtr<Promise>(self->Update(Constify(arg0), rv)));
502
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
503
0
    return false;
504
0
  }
505
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
506
0
  static_assert(!IsPointer<decltype(result)>::value,
507
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
508
0
  if (!ToJSValue(cx, result, args.rval())) {
509
0
    return false;
510
0
  }
511
0
  return true;
512
0
}
513
514
MOZ_CAN_RUN_SCRIPT static bool
515
update_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
516
0
{
517
0
  bool ok = update(cx, obj, self, args);
518
0
  if (ok) {
519
0
    return true;
520
0
  }
521
0
  return ConvertExceptionToPromise(cx, args.rval());
522
0
}
523
524
static const JSJitInfo update_methodinfo = {
525
  { (JSJitGetterOp)update_promiseWrapper },
526
  { prototypes::id::MediaKeySession },
527
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
528
  JSJitInfo::Method,
529
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
530
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
531
  false,  /* isInfallible. False in setters. */
532
  false,  /* isMovable.  Not relevant for setters. */
533
  false, /* isEliminatable.  Not relevant for setters. */
534
  false, /* isAlwaysInSlot.  Only relevant for getters. */
535
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
536
  false,  /* isTypedMethod.  Only relevant for methods. */
537
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
538
};
539
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
540
static_assert(0 < 1, "There is no slot for us");
541
542
MOZ_CAN_RUN_SCRIPT static bool
543
close(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
544
0
{
545
0
  AUTO_PROFILER_LABEL_FAST("MediaKeySession.close", DOM, cx);
546
0
547
0
  FastErrorResult rv;
548
0
  auto result(StrongOrRawPtr<Promise>(self->Close(rv)));
549
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
550
0
    return false;
551
0
  }
552
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
553
0
  static_assert(!IsPointer<decltype(result)>::value,
554
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
555
0
  if (!ToJSValue(cx, result, args.rval())) {
556
0
    return false;
557
0
  }
558
0
  return true;
559
0
}
560
561
MOZ_CAN_RUN_SCRIPT static bool
562
close_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
563
0
{
564
0
  bool ok = close(cx, obj, self, args);
565
0
  if (ok) {
566
0
    return true;
567
0
  }
568
0
  return ConvertExceptionToPromise(cx, args.rval());
569
0
}
570
571
static const JSJitInfo close_methodinfo = {
572
  { (JSJitGetterOp)close_promiseWrapper },
573
  { prototypes::id::MediaKeySession },
574
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
575
  JSJitInfo::Method,
576
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
577
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
578
  false,  /* isInfallible. False in setters. */
579
  false,  /* isMovable.  Not relevant for setters. */
580
  false, /* isEliminatable.  Not relevant for setters. */
581
  false, /* isAlwaysInSlot.  Only relevant for getters. */
582
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
583
  false,  /* isTypedMethod.  Only relevant for methods. */
584
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
585
};
586
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
587
static_assert(0 < 1, "There is no slot for us");
588
589
MOZ_CAN_RUN_SCRIPT static bool
590
remove(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
591
0
{
592
0
  AUTO_PROFILER_LABEL_FAST("MediaKeySession.remove", DOM, cx);
593
0
594
0
  FastErrorResult rv;
595
0
  auto result(StrongOrRawPtr<Promise>(self->Remove(rv)));
596
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
597
0
    return false;
598
0
  }
599
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
600
0
  static_assert(!IsPointer<decltype(result)>::value,
601
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
602
0
  if (!ToJSValue(cx, result, args.rval())) {
603
0
    return false;
604
0
  }
605
0
  return true;
606
0
}
607
608
MOZ_CAN_RUN_SCRIPT static bool
609
remove_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
610
0
{
611
0
  bool ok = remove(cx, obj, self, args);
612
0
  if (ok) {
613
0
    return true;
614
0
  }
615
0
  return ConvertExceptionToPromise(cx, args.rval());
616
0
}
617
618
static const JSJitInfo remove_methodinfo = {
619
  { (JSJitGetterOp)remove_promiseWrapper },
620
  { prototypes::id::MediaKeySession },
621
  { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
622
  JSJitInfo::Method,
623
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
624
  JSVAL_TYPE_OBJECT,  /* 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
static bool
637
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
638
0
{
639
0
  mozilla::dom::MediaKeySession* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeySession>(obj);
640
0
  // We don't want to preserve if we don't have a wrapper, and we
641
0
  // obviously can't preserve if we're not initialized.
642
0
  if (self && self->GetWrapperPreserveColor()) {
643
0
    PreserveWrapper(self);
644
0
  }
645
0
  return true;
646
0
}
647
648
static void
649
_finalize(js::FreeOp* fop, JSObject* obj)
650
0
{
651
0
  mozilla::dom::MediaKeySession* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeySession>(obj);
652
0
  if (self) {
653
0
    ClearWrapper(self, self, obj);
654
0
    AddForDeferredFinalization<mozilla::dom::MediaKeySession>(self);
655
0
  }
656
0
}
657
658
static size_t
659
_objectMoved(JSObject* obj, JSObject* old)
660
0
{
661
0
  mozilla::dom::MediaKeySession* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeySession>(obj);
662
0
  if (self) {
663
0
    UpdateWrapper(self, self, obj, old);
664
0
  }
665
0
666
0
  return 0;
667
0
}
668
669
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
670
#if defined(__clang__)
671
#pragma clang diagnostic push
672
#pragma clang diagnostic ignored "-Wmissing-braces"
673
#endif
674
static const JSFunctionSpec sMethods_specs[] = {
675
  JS_FNSPEC("generateRequest", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&generateRequest_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
676
  JS_FNSPEC("load", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&load_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
677
  JS_FNSPEC("update", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&update_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
678
  JS_FNSPEC("close", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&close_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
679
  JS_FNSPEC("remove", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&remove_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
680
  JS_FS_END
681
};
682
#if defined(__clang__)
683
#pragma clang diagnostic pop
684
#endif
685
686
687
static const Prefable<const JSFunctionSpec> sMethods[] = {
688
  { nullptr, &sMethods_specs[0] },
689
  { nullptr, nullptr }
690
};
691
692
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
693
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
694
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
695
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
696
697
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
698
#if defined(__clang__)
699
#pragma clang diagnostic push
700
#pragma clang diagnostic ignored "-Wmissing-braces"
701
#endif
702
static const JSPropertySpec sAttributes_specs[] = {
703
  { "error", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &error_getterinfo, nullptr, nullptr },
704
  { "sessionId", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sessionId_getterinfo, nullptr, nullptr },
705
  { "expiration", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &expiration_getterinfo, nullptr, nullptr },
706
  { "closed", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ConvertExceptionsToPromises>, &closed_getterinfo, nullptr, nullptr },
707
  { "keyStatuses", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &keyStatuses_getterinfo, nullptr, nullptr },
708
  { "onkeystatuseschange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onkeystatuseschange_getterinfo, GenericSetter<NormalThisPolicy>, &onkeystatuseschange_setterinfo },
709
  { "onmessage", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onmessage_getterinfo, GenericSetter<NormalThisPolicy>, &onmessage_setterinfo },
710
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
711
};
712
#if defined(__clang__)
713
#pragma clang diagnostic pop
714
#endif
715
716
717
static const Prefable<const JSPropertySpec> sAttributes[] = {
718
  { nullptr, &sAttributes_specs[0] },
719
  { nullptr, nullptr }
720
};
721
722
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
723
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
724
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
725
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
726
727
728
static uint16_t sNativeProperties_sortedPropertyIndices[12];
729
static PropertyInfo sNativeProperties_propertyInfos[12];
730
731
static const NativePropertiesN<2> sNativeProperties = {
732
  false, 0,
733
  false, 0,
734
  true,  0 /* sMethods */,
735
  true,  1 /* sAttributes */,
736
  false, 0,
737
  false, 0,
738
  false, 0,
739
  -1,
740
  12,
741
  sNativeProperties_sortedPropertyIndices,
742
  {
743
    { sMethods, &sNativeProperties_propertyInfos[0] },
744
    { sAttributes, &sNativeProperties_propertyInfos[5] }
745
  }
746
};
747
static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
748
    "We have a property info count that is oversized");
749
750
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
751
  {
752
    "Function",
753
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
754
    &sBoringInterfaceObjectClassClassOps,
755
    JS_NULL_CLASS_SPEC,
756
    JS_NULL_CLASS_EXT,
757
    &sInterfaceObjectClassObjectOps
758
  },
759
  eInterface,
760
  true,
761
  prototypes::id::MediaKeySession,
762
  PrototypeTraits<prototypes::id::MediaKeySession>::Depth,
763
  sNativePropertyHooks,
764
  "function MediaKeySession() {\n    [native code]\n}",
765
  EventTarget_Binding::GetConstructorObject
766
};
767
768
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
769
  {
770
    "MediaKeySessionPrototype",
771
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
772
    JS_NULL_CLASS_OPS,
773
    JS_NULL_CLASS_SPEC,
774
    JS_NULL_CLASS_EXT,
775
    JS_NULL_OBJECT_OPS
776
  },
777
  eInterfacePrototype,
778
  false,
779
  prototypes::id::MediaKeySession,
780
  PrototypeTraits<prototypes::id::MediaKeySession>::Depth,
781
  sNativePropertyHooks,
782
  "[object MediaKeySessionPrototype]",
783
  EventTarget_Binding::GetProtoObject
784
};
785
786
static const js::ClassOps sClassOps = {
787
  _addProperty, /* addProperty */
788
  nullptr,               /* delProperty */
789
  nullptr,               /* enumerate */
790
  nullptr, /* newEnumerate */
791
  nullptr, /* resolve */
792
  nullptr, /* mayResolve */
793
  _finalize, /* finalize */
794
  nullptr, /* call */
795
  nullptr,               /* hasInstance */
796
  nullptr,               /* construct */
797
  nullptr, /* trace */
798
};
799
800
static const js::ClassExtension sClassExtension = {
801
  nullptr, /* weakmapKeyDelegateOp */
802
  _objectMoved /* objectMovedOp */
803
};
804
805
static const DOMJSClass sClass = {
806
  { "MediaKeySession",
807
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
808
    &sClassOps,
809
    JS_NULL_CLASS_SPEC,
810
    &sClassExtension,
811
    JS_NULL_OBJECT_OPS
812
  },
813
  { prototypes::id::EventTarget, prototypes::id::MediaKeySession, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
814
  IsBaseOf<nsISupports, mozilla::dom::MediaKeySession >::value,
815
  sNativePropertyHooks,
816
  FindAssociatedGlobalForNative<mozilla::dom::MediaKeySession>::Get,
817
  GetProtoObjectHandle,
818
  GetCCParticipant<mozilla::dom::MediaKeySession>::Get()
819
};
820
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
821
              "Must have the right minimal number of reserved slots.");
822
static_assert(1 >= 1,
823
              "Must have enough reserved slots.");
824
825
const JSClass*
826
GetJSClass()
827
0
{
828
0
  return sClass.ToJSClass();
829
0
}
830
831
bool
832
Wrap(JSContext* aCx, mozilla::dom::MediaKeySession* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
833
0
{
834
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::MediaKeySession>::value,
835
0
                "Shouldn't have wrappercached things that are not refcounted.");
836
0
  MOZ_ASSERT(static_cast<mozilla::dom::MediaKeySession*>(aObject) ==
837
0
             reinterpret_cast<mozilla::dom::MediaKeySession*>(aObject),
838
0
             "Multiple inheritance for mozilla::dom::MediaKeySession is broken.");
839
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
840
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
841
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
842
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
843
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
844
0
  MOZ_ASSERT(!aCache->GetWrapper(),
845
0
             "You should probably not be using Wrap() directly; use "
846
0
             "GetOrCreateDOMReflector instead");
847
0
848
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
849
0
             "nsISupports must be on our primary inheritance chain");
850
0
851
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
852
0
  if (!global) {
853
0
    return false;
854
0
  }
855
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
856
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
857
0
858
0
  // That might have ended up wrapping us already, due to the wonders
859
0
  // of XBL.  Check for that, and bail out as needed.
860
0
  aReflector.set(aCache->GetWrapper());
861
0
  if (aReflector) {
862
#ifdef DEBUG
863
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
864
#endif // DEBUG
865
    return true;
866
0
  }
867
0
868
0
  JSAutoRealm ar(aCx, global);
869
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
870
0
  if (!canonicalProto) {
871
0
    return false;
872
0
  }
873
0
  JS::Rooted<JSObject*> proto(aCx);
874
0
  if (aGivenProto) {
875
0
    proto = aGivenProto;
876
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
877
0
    // coming in, we changed compartments to that of "parent" so may need
878
0
    // to wrap the proto here.
879
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
880
0
      if (!JS_WrapObject(aCx, &proto)) {
881
0
        return false;
882
0
      }
883
0
    }
884
0
  } else {
885
0
    proto = canonicalProto;
886
0
  }
887
0
888
0
  BindingJSObjectCreator<mozilla::dom::MediaKeySession> creator(aCx);
889
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
890
0
  if (!aReflector) {
891
0
    return false;
892
0
  }
893
0
894
0
  aCache->SetWrapper(aReflector);
895
0
  creator.InitializationSucceeded();
896
0
897
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
898
0
             aCache->GetWrapperPreserveColor() == aReflector);
899
0
  // If proto != canonicalProto, we have to preserve our wrapper;
900
0
  // otherwise we won't be able to properly recreate it later, since
901
0
  // we won't know what proto to use.  Note that we don't check
902
0
  // aGivenProto here, since it's entirely possible (and even
903
0
  // somewhat common) to have a non-null aGivenProto which is the
904
0
  // same as canonicalProto.
905
0
  if (proto != canonicalProto) {
906
0
    PreserveWrapper(aObject);
907
0
  }
908
0
909
0
  return true;
910
0
}
911
912
const NativePropertyHooks sNativePropertyHooks[] = { {
913
  nullptr,
914
  nullptr,
915
  nullptr,
916
  { sNativeProperties.Upcast(), nullptr },
917
  prototypes::id::MediaKeySession,
918
  constructors::id::MediaKeySession,
919
  EventTarget_Binding::sNativePropertyHooks,
920
  &DefaultXrayExpandoObjectClass
921
} };
922
923
void
924
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
925
0
{
926
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
927
0
  if (!parentProto) {
928
0
    return;
929
0
  }
930
0
931
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
932
0
  if (!constructorProto) {
933
0
    return;
934
0
  }
935
0
936
0
  static bool sIdsInited = false;
937
0
  if (!sIdsInited && NS_IsMainThread()) {
938
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
939
0
      return;
940
0
    }
941
0
    sIdsInited = true;
942
0
  }
943
0
944
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaKeySession);
945
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaKeySession);
946
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
947
0
                              &sPrototypeClass.mBase, protoCache,
948
0
                              nullptr,
949
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
950
0
                              interfaceCache,
951
0
                              sNativeProperties.Upcast(),
952
0
                              nullptr,
953
0
                              "MediaKeySession", aDefineOnGlobal,
954
0
                              nullptr,
955
0
                              false);
956
0
}
957
958
JSObject*
959
GetConstructorObject(JSContext* aCx)
960
0
{
961
0
  return GetConstructorObjectHandle(aCx);
962
0
}
963
964
} // namespace MediaKeySession_Binding
965
966
967
968
} // namespace dom
969
} // namespace mozilla