Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/NavigatorBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Navigator.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AddonManagerBinding.h"
4
#include "AtomList.h"
5
#include "DOMMediaStream.h"
6
#include "FetchBinding.h"
7
#include "MIDIOptionsBinding.h"
8
#include "MediaKeySystemAccessBinding.h"
9
#include "MediaStreamBinding.h"
10
#include "Navigator.h"
11
#include "NavigatorBinding.h"
12
#include "ServiceWorkerContainer.h"
13
#include "TCPSocket.h"
14
#include "TestJSImplGenBinding.h"
15
#include "WrapperFactory.h"
16
#include "XrayWrapper.h"
17
#include "mozilla/AddonManagerWebAPI.h"
18
#include "mozilla/OwningNonNull.h"
19
#include "mozilla/Preferences.h"
20
#include "mozilla/dom/BindingUtils.h"
21
#include "mozilla/dom/Clipboard.h"
22
#include "mozilla/dom/CredentialsContainer.h"
23
#include "mozilla/dom/DOMJSClass.h"
24
#include "mozilla/dom/DOMPrefs.h"
25
#include "mozilla/dom/Gamepad.h"
26
#include "mozilla/dom/GamepadServiceTest.h"
27
#include "mozilla/dom/MediaCapabilities.h"
28
#include "mozilla/dom/MediaDevices.h"
29
#include "mozilla/dom/MediaStreamError.h"
30
#include "mozilla/dom/NonRefcountedDOMObject.h"
31
#include "mozilla/dom/Nullable.h"
32
#include "mozilla/dom/Permissions.h"
33
#include "mozilla/dom/Presentation.h"
34
#include "mozilla/dom/PrimitiveConversions.h"
35
#include "mozilla/dom/Promise.h"
36
#include "mozilla/dom/ServiceWorkerContainer.h"
37
#include "mozilla/dom/StorageManager.h"
38
#include "mozilla/dom/TCPSocket.h"
39
#include "mozilla/dom/ToJSValue.h"
40
#include "mozilla/dom/UnionConversions.h"
41
#include "mozilla/dom/VRDisplay.h"
42
#include "mozilla/dom/VRServiceTest.h"
43
#include "mozilla/dom/XrayExpandoClass.h"
44
#include "mozilla/dom/network/Connection.h"
45
#include "nsContentUtils.h"
46
#include "nsGeolocation.h"
47
#include "nsGlobalWindowInner.h"
48
#include "nsIDocument.h"
49
#include "nsIVariant.h"
50
#include "nsMimeTypeArray.h"
51
#include "nsPluginArray.h"
52
53
namespace mozilla {
54
namespace dom {
55
56
namespace binding_detail {}; // Just to make sure it's known as a namespace
57
using namespace mozilla::dom::binding_detail;
58
59
60
void
61
NavigatorUserMediaSuccessCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, DOMMediaStream& stream, ErrorResult& aRv)
62
0
{
63
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
64
0
  JS::AutoValueVector argv(cx);
65
0
  if (!argv.resize(1)) {
66
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
67
0
    return;
68
0
  }
69
0
  unsigned argc = 1;
70
0
71
0
  do {
72
0
    if (!GetOrCreateDOMReflector(cx, stream, argv[0])) {
73
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
74
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
75
0
      return;
76
0
    }
77
0
    break;
78
0
  } while (false);
79
0
80
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
81
0
  if (!JS::Call(cx, aThisVal, callable,
82
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
83
0
    aRv.NoteJSContextException(cx);
84
0
    return;
85
0
  }
86
0
}
87
88
89
90
void
91
NavigatorUserMediaErrorCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, MediaStreamError& error, ErrorResult& aRv)
92
0
{
93
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
94
0
  JS::AutoValueVector argv(cx);
95
0
  if (!argv.resize(1)) {
96
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
97
0
    return;
98
0
  }
99
0
  unsigned argc = 1;
100
0
101
0
  do {
102
0
    if (!GetOrCreateDOMReflector(cx, error, argv[0])) {
103
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
104
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
105
0
      return;
106
0
    }
107
0
    break;
108
0
  } while (false);
109
0
110
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
111
0
  if (!JS::Call(cx, aThisVal, callable,
112
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
113
0
    aRv.NoteJSContextException(cx);
114
0
    return;
115
0
  }
116
0
}
117
118
119
120
void
121
MozGetUserMediaDevicesSuccessCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, nsIVariant* devices, ErrorResult& aRv)
122
0
{
123
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
124
0
  JS::AutoValueVector argv(cx);
125
0
  if (!argv.resize(1)) {
126
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
127
0
    return;
128
0
  }
129
0
  unsigned argc = 1;
130
0
131
0
  do {
132
0
    if (!devices) {
133
0
      argv[0].setNull();
134
0
      break;
135
0
    }
136
0
    if (!WrapObject(cx, devices, &NS_GET_IID(nsIVariant), argv[0])) {
137
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
138
0
      return;
139
0
    }
140
0
    break;
141
0
  } while (false);
142
0
143
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
144
0
  if (!JS::Call(cx, aThisVal, callable,
145
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
146
0
    aRv.NoteJSContextException(cx);
147
0
    return;
148
0
  }
149
0
}
150
151
152
153
namespace binding_detail {
154
} // namespace binding_detail
155
156
157
namespace binding_detail {
158
} // namespace binding_detail
159
160
161
namespace binding_detail {
162
} // namespace binding_detail
163
164
165
namespace Navigator_Binding {
166
167
MOZ_CAN_RUN_SCRIPT static bool
168
get_permissions(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
169
0
{
170
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.permissions", DOM, cx);
171
0
172
0
  FastErrorResult rv;
173
0
  auto result(StrongOrRawPtr<mozilla::dom::Permissions>(self->GetPermissions(rv)));
174
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
175
0
    return false;
176
0
  }
177
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
178
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
179
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
180
0
    return false;
181
0
  }
182
0
  return true;
183
0
}
184
185
static const JSJitInfo permissions_getterinfo = {
186
  { (JSJitGetterOp)get_permissions },
187
  { prototypes::id::Navigator },
188
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
189
  JSJitInfo::Getter,
190
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
191
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
192
  false,  /* isInfallible. False in setters. */
193
  false,  /* isMovable.  Not relevant for setters. */
194
  false, /* isEliminatable.  Not relevant for setters. */
195
  false, /* isAlwaysInSlot.  Only relevant for getters. */
196
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
197
  false,  /* isTypedMethod.  Only relevant for methods. */
198
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
199
};
200
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
201
static_assert(0 < 15, "There is no slot for us");
202
203
MOZ_CAN_RUN_SCRIPT static bool
204
get_mimeTypes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
205
0
{
206
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.mimeTypes", DOM, cx);
207
0
208
0
  FastErrorResult rv;
209
0
  auto result(StrongOrRawPtr<nsMimeTypeArray>(self->GetMimeTypes(rv)));
210
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
211
0
    return false;
212
0
  }
213
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
214
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
215
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
216
0
    return false;
217
0
  }
218
0
  return true;
219
0
}
220
221
static const JSJitInfo mimeTypes_getterinfo = {
222
  { (JSJitGetterOp)get_mimeTypes },
223
  { prototypes::id::Navigator },
224
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
225
  JSJitInfo::Getter,
226
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
227
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
228
  false,  /* isInfallible. False in setters. */
229
  false,  /* isMovable.  Not relevant for setters. */
230
  false, /* isEliminatable.  Not relevant for setters. */
231
  false, /* isAlwaysInSlot.  Only relevant for getters. */
232
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
233
  false,  /* isTypedMethod.  Only relevant for methods. */
234
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
235
};
236
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
237
static_assert(0 < 15, "There is no slot for us");
238
239
MOZ_CAN_RUN_SCRIPT static bool
240
get_plugins(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
241
0
{
242
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.plugins", DOM, cx);
243
0
244
0
  FastErrorResult rv;
245
0
  auto result(StrongOrRawPtr<nsPluginArray>(self->GetPlugins(rv)));
246
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
247
0
    return false;
248
0
  }
249
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
250
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
251
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
252
0
    return false;
253
0
  }
254
0
  return true;
255
0
}
256
257
static const JSJitInfo plugins_getterinfo = {
258
  { (JSJitGetterOp)get_plugins },
259
  { prototypes::id::Navigator },
260
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
261
  JSJitInfo::Getter,
262
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
263
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
264
  false,  /* isInfallible. False in setters. */
265
  false,  /* isMovable.  Not relevant for setters. */
266
  false, /* isEliminatable.  Not relevant for setters. */
267
  false, /* isAlwaysInSlot.  Only relevant for getters. */
268
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
269
  false,  /* isTypedMethod.  Only relevant for methods. */
270
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
271
};
272
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
273
static_assert(0 < 15, "There is no slot for us");
274
275
MOZ_CAN_RUN_SCRIPT static bool
276
get_doNotTrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
277
0
{
278
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.doNotTrack", DOM, cx);
279
0
280
0
  DOMString result;
281
0
  self->GetDoNotTrack(result);
282
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
283
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
284
0
    return false;
285
0
  }
286
0
  return true;
287
0
}
288
289
static const JSJitInfo doNotTrack_getterinfo = {
290
  { (JSJitGetterOp)get_doNotTrack },
291
  { prototypes::id::Navigator },
292
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
293
  JSJitInfo::Getter,
294
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
295
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
296
  false,  /* isInfallible. False in setters. */
297
  false,  /* isMovable.  Not relevant for setters. */
298
  false, /* isEliminatable.  Not relevant for setters. */
299
  false, /* isAlwaysInSlot.  Only relevant for getters. */
300
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
301
  false,  /* isTypedMethod.  Only relevant for methods. */
302
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
303
};
304
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
305
static_assert(0 < 15, "There is no slot for us");
306
307
MOZ_CAN_RUN_SCRIPT static bool
308
getBattery(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
309
0
{
310
0
  AUTO_PROFILER_LABEL_FAST("Navigator.getBattery", DOM, cx);
311
0
312
0
  FastErrorResult rv;
313
0
  auto result(StrongOrRawPtr<Promise>(self->GetBattery(rv)));
314
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
315
0
    return false;
316
0
  }
317
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
318
0
  if (!ToJSValue(cx, result, args.rval())) {
319
0
    return false;
320
0
  }
321
0
  return true;
322
0
}
323
324
MOZ_CAN_RUN_SCRIPT static bool
325
getBattery_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
326
0
{
327
0
  bool ok = getBattery(cx, obj, self, args);
328
0
  if (ok) {
329
0
    return true;
330
0
  }
331
0
  return ConvertExceptionToPromise(cx, args.rval());
332
0
}
333
334
static const JSJitInfo getBattery_methodinfo = {
335
  { (JSJitGetterOp)getBattery_promiseWrapper },
336
  { prototypes::id::Navigator },
337
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
338
  JSJitInfo::Method,
339
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
340
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
341
  false,  /* isInfallible. False in setters. */
342
  false,  /* isMovable.  Not relevant for setters. */
343
  false, /* isEliminatable.  Not relevant for setters. */
344
  false, /* isAlwaysInSlot.  Only relevant for getters. */
345
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
346
  false,  /* isTypedMethod.  Only relevant for methods. */
347
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
348
};
349
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
350
static_assert(0 < 15, "There is no slot for us");
351
352
MOZ_CAN_RUN_SCRIPT static bool
353
vibrate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
354
0
{
355
0
  AUTO_PROFILER_LABEL_FAST("Navigator.vibrate", DOM, cx);
356
0
357
0
  unsigned argcount = std::min(args.length(), 1u);
358
0
  switch (argcount) {
359
0
    case 1: {
360
0
      if (args[0].isObject()) {
361
0
        do {
362
0
          binding_detail::AutoSequence<uint32_t> arg0;
363
0
          JS::ForOfIterator iter(cx);
364
0
          if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
365
0
            return false;
366
0
          }
367
0
          if (!iter.valueIsIterable()) {
368
0
            break;
369
0
          }
370
0
          binding_detail::AutoSequence<uint32_t> &arr = arg0;
371
0
          JS::Rooted<JS::Value> temp(cx);
372
0
          while (true) {
373
0
            bool done;
374
0
            if (!iter.next(&temp, &done)) {
375
0
              return false;
376
0
            }
377
0
            if (done) {
378
0
              break;
379
0
            }
380
0
            uint32_t* slotPtr = arr.AppendElement(mozilla::fallible);
381
0
            if (!slotPtr) {
382
0
              JS_ReportOutOfMemory(cx);
383
0
              return false;
384
0
            }
385
0
            uint32_t& slot = *slotPtr;
386
0
            if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp, &slot)) {
387
0
              return false;
388
0
            }
389
0
          }
390
0
          bool result(self->Vibrate(Constify(arg0)));
391
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
392
0
          args.rval().setBoolean(result);
393
0
          return true;
394
0
        } while (false);
395
0
      }
396
0
      uint32_t arg0;
397
0
      if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
398
0
        return false;
399
0
      }
400
0
      bool result(self->Vibrate(arg0));
401
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
402
0
      args.rval().setBoolean(result);
403
0
      return true;
404
0
      break;
405
0
    }
406
0
    default: {
407
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.vibrate");
408
0
      break;
409
0
    }
410
0
  }
411
0
  MOZ_CRASH("We have an always-returning default case");
412
0
  return false;
413
0
}
414
415
static const JSJitInfo vibrate_methodinfo = {
416
  { (JSJitGetterOp)vibrate },
417
  { prototypes::id::Navigator },
418
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
419
  JSJitInfo::Method,
420
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
421
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
422
  false,  /* isInfallible. False in setters. */
423
  false,  /* isMovable.  Not relevant for setters. */
424
  false, /* isEliminatable.  Not relevant for setters. */
425
  false, /* isAlwaysInSlot.  Only relevant for getters. */
426
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
427
  false,  /* isTypedMethod.  Only relevant for methods. */
428
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
429
};
430
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
431
static_assert(0 < 15, "There is no slot for us");
432
433
MOZ_CAN_RUN_SCRIPT static bool
434
get_maxTouchPoints(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
435
0
{
436
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.maxTouchPoints", DOM, cx);
437
0
438
0
  int32_t result(self->MaxTouchPoints());
439
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
440
0
  args.rval().setInt32(int32_t(result));
441
0
  return true;
442
0
}
443
444
static const JSJitInfo maxTouchPoints_getterinfo = {
445
  { (JSJitGetterOp)get_maxTouchPoints },
446
  { prototypes::id::Navigator },
447
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
448
  JSJitInfo::Getter,
449
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
450
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
451
  true,  /* isInfallible. False in setters. */
452
  false,  /* isMovable.  Not relevant for setters. */
453
  false, /* isEliminatable.  Not relevant for setters. */
454
  false, /* isAlwaysInSlot.  Only relevant for getters. */
455
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
456
  false,  /* isTypedMethod.  Only relevant for methods. */
457
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
458
};
459
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
460
static_assert(0 < 15, "There is no slot for us");
461
462
MOZ_CAN_RUN_SCRIPT static bool
463
get_mediaCapabilities(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
464
0
{
465
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.mediaCapabilities", DOM, cx);
466
0
467
0
  auto result(StrongOrRawPtr<mozilla::dom::MediaCapabilities>(self->MediaCapabilities()));
468
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
469
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
470
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
471
0
    return false;
472
0
  }
473
0
  return true;
474
0
}
475
476
static const JSJitInfo mediaCapabilities_getterinfo = {
477
  { (JSJitGetterOp)get_mediaCapabilities },
478
  { prototypes::id::Navigator },
479
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
480
  JSJitInfo::Getter,
481
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
482
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
483
  false,  /* isInfallible. False in setters. */
484
  true,  /* isMovable.  Not relevant for setters. */
485
  true, /* isEliminatable.  Not relevant for setters. */
486
  false, /* isAlwaysInSlot.  Only relevant for getters. */
487
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
488
  false,  /* isTypedMethod.  Only relevant for methods. */
489
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
490
};
491
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
492
static_assert(0 < 15, "There is no slot for us");
493
494
MOZ_CAN_RUN_SCRIPT static bool
495
setVibrationPermission(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
496
0
{
497
0
  AUTO_PROFILER_LABEL_FAST("Navigator.setVibrationPermission", DOM, cx);
498
0
499
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
500
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.setVibrationPermission");
501
0
  }
502
0
  bool arg0;
503
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
504
0
    return false;
505
0
  }
506
0
  bool arg1;
507
0
  if (args.hasDefined(1)) {
508
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
509
0
      return false;
510
0
    }
511
0
  } else {
512
0
    arg1 = true;
513
0
  }
514
0
  self->SetVibrationPermission(arg0, arg1);
515
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
516
0
  args.rval().setUndefined();
517
0
  return true;
518
0
}
519
520
static const JSJitInfo setVibrationPermission_methodinfo = {
521
  { (JSJitGetterOp)setVibrationPermission },
522
  { prototypes::id::Navigator },
523
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
524
  JSJitInfo::Method,
525
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
526
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
527
  false,  /* isInfallible. False in setters. */
528
  false,  /* isMovable.  Not relevant for setters. */
529
  false, /* isEliminatable.  Not relevant for setters. */
530
  false, /* isAlwaysInSlot.  Only relevant for getters. */
531
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
532
  false,  /* isTypedMethod.  Only relevant for methods. */
533
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
534
};
535
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
536
static_assert(0 < 15, "There is no slot for us");
537
538
MOZ_CAN_RUN_SCRIPT static bool
539
get_oscpu(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
540
0
{
541
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.oscpu", DOM, cx);
542
0
543
0
  // Have to either root across the getter call or reget after.
544
0
  bool isXray;
545
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
546
0
  if (!slotStorage) {
547
0
    return false;
548
0
  }
549
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
550
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
551
0
  {
552
0
    // Scope for cachedVal
553
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
554
0
    if (!cachedVal.isUndefined()) {
555
0
      args.rval().set(cachedVal);
556
0
      // The cached value is in the compartment of slotStorage,
557
0
      // so wrap into the caller compartment as needed.
558
0
      if (MaybeWrapValue(cx, args.rval())) {
559
0
        return true;
560
0
      }
561
0
      return false;
562
0
    }
563
0
  }
564
0
565
0
  FastErrorResult rv;
566
0
  DOMString result;
567
0
  self->GetOscpu(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
568
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
569
0
    return false;
570
0
  }
571
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
572
0
  {
573
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
574
0
    JSAutoRealm ar(cx, conversionScope);
575
0
    do { // block we break out of when done wrapping
576
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
577
0
        return false;
578
0
      }
579
0
      break;
580
0
    } while (false);
581
0
  }
582
0
  { // And now store things in the realm of our slotStorage.
583
0
    JSAutoRealm ar(cx, slotStorage);
584
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
585
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
586
0
    if (!MaybeWrapValue(cx, &storedVal)) {
587
0
      return false;
588
0
    }
589
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
590
0
    if (!isXray) {
591
0
      // In the Xray case we don't need to do this, because getting the
592
0
      // expando object already preserved our wrapper.
593
0
      PreserveWrapper(self);
594
0
    }
595
0
  }
596
0
  // And now make sure args.rval() is in the caller realm.
597
0
  if (MaybeWrapValue(cx, args.rval())) {
598
0
    return true;
599
0
  }
600
0
  return false;
601
0
}
602
603
static const JSJitInfo oscpu_getterinfo = {
604
  { (JSJitGetterOp)get_oscpu },
605
  { prototypes::id::Navigator },
606
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
607
  JSJitInfo::Getter,
608
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
609
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
610
  false,  /* isInfallible. False in setters. */
611
  false,  /* isMovable.  Not relevant for setters. */
612
  false, /* isEliminatable.  Not relevant for setters. */
613
  false, /* isAlwaysInSlot.  Only relevant for getters. */
614
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
615
  false,  /* isTypedMethod.  Only relevant for methods. */
616
  (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
617
};
618
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
619
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 15, "There is no slot for us");
620
621
MOZ_CAN_RUN_SCRIPT static bool
622
get_vendor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
623
0
{
624
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.vendor", DOM, cx);
625
0
626
0
  DOMString result;
627
0
  self->GetVendor(result);
628
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
629
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
630
0
    return false;
631
0
  }
632
0
  return true;
633
0
}
634
635
static const JSJitInfo vendor_getterinfo = {
636
  { (JSJitGetterOp)get_vendor },
637
  { prototypes::id::Navigator },
638
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
639
  JSJitInfo::Getter,
640
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
641
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
642
  false,  /* isInfallible. False in setters. */
643
  false,  /* isMovable.  Not relevant for setters. */
644
  false, /* isEliminatable.  Not relevant for setters. */
645
  false, /* isAlwaysInSlot.  Only relevant for getters. */
646
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
647
  false,  /* isTypedMethod.  Only relevant for methods. */
648
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
649
};
650
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
651
static_assert(0 < 15, "There is no slot for us");
652
653
MOZ_CAN_RUN_SCRIPT static bool
654
get_vendorSub(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
655
0
{
656
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.vendorSub", DOM, cx);
657
0
658
0
  DOMString result;
659
0
  self->GetVendorSub(result);
660
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
661
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
662
0
    return false;
663
0
  }
664
0
  return true;
665
0
}
666
667
static const JSJitInfo vendorSub_getterinfo = {
668
  { (JSJitGetterOp)get_vendorSub },
669
  { prototypes::id::Navigator },
670
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
671
  JSJitInfo::Getter,
672
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
673
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
674
  false,  /* isInfallible. False in setters. */
675
  false,  /* isMovable.  Not relevant for setters. */
676
  false, /* isEliminatable.  Not relevant for setters. */
677
  false, /* isAlwaysInSlot.  Only relevant for getters. */
678
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
679
  false,  /* isTypedMethod.  Only relevant for methods. */
680
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
681
};
682
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
683
static_assert(0 < 15, "There is no slot for us");
684
685
MOZ_CAN_RUN_SCRIPT static bool
686
get_productSub(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
687
0
{
688
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.productSub", DOM, cx);
689
0
690
0
  DOMString result;
691
0
  self->GetProductSub(result);
692
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
693
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
694
0
    return false;
695
0
  }
696
0
  return true;
697
0
}
698
699
static const JSJitInfo productSub_getterinfo = {
700
  { (JSJitGetterOp)get_productSub },
701
  { prototypes::id::Navigator },
702
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
703
  JSJitInfo::Getter,
704
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
705
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
706
  false,  /* isInfallible. False in setters. */
707
  false,  /* isMovable.  Not relevant for setters. */
708
  false, /* isEliminatable.  Not relevant for setters. */
709
  false, /* isAlwaysInSlot.  Only relevant for getters. */
710
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
711
  false,  /* isTypedMethod.  Only relevant for methods. */
712
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
713
};
714
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
715
static_assert(0 < 15, "There is no slot for us");
716
717
MOZ_CAN_RUN_SCRIPT static bool
718
get_cookieEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
719
0
{
720
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.cookieEnabled", DOM, cx);
721
0
722
0
  bool result(self->CookieEnabled());
723
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
724
0
  args.rval().setBoolean(result);
725
0
  return true;
726
0
}
727
728
static const JSJitInfo cookieEnabled_getterinfo = {
729
  { (JSJitGetterOp)get_cookieEnabled },
730
  { prototypes::id::Navigator },
731
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
732
  JSJitInfo::Getter,
733
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
734
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
735
  true,  /* isInfallible. False in setters. */
736
  false,  /* isMovable.  Not relevant for setters. */
737
  false, /* isEliminatable.  Not relevant for setters. */
738
  false, /* isAlwaysInSlot.  Only relevant for getters. */
739
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
740
  false,  /* isTypedMethod.  Only relevant for methods. */
741
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
742
};
743
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
744
static_assert(0 < 15, "There is no slot for us");
745
746
MOZ_CAN_RUN_SCRIPT static bool
747
get_buildID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
748
0
{
749
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.buildID", DOM, cx);
750
0
751
0
  // Have to either root across the getter call or reget after.
752
0
  bool isXray;
753
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
754
0
  if (!slotStorage) {
755
0
    return false;
756
0
  }
757
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 1) : (DOM_INSTANCE_RESERVED_SLOTS + 1);
758
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
759
0
  {
760
0
    // Scope for cachedVal
761
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
762
0
    if (!cachedVal.isUndefined()) {
763
0
      args.rval().set(cachedVal);
764
0
      // The cached value is in the compartment of slotStorage,
765
0
      // so wrap into the caller compartment as needed.
766
0
      if (MaybeWrapValue(cx, args.rval())) {
767
0
        return true;
768
0
      }
769
0
      return false;
770
0
    }
771
0
  }
772
0
773
0
  FastErrorResult rv;
774
0
  DOMString result;
775
0
  self->GetBuildID(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
776
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
777
0
    return false;
778
0
  }
779
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
780
0
  {
781
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
782
0
    JSAutoRealm ar(cx, conversionScope);
783
0
    do { // block we break out of when done wrapping
784
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
785
0
        return false;
786
0
      }
787
0
      break;
788
0
    } while (false);
789
0
  }
790
0
  { // And now store things in the realm of our slotStorage.
791
0
    JSAutoRealm ar(cx, slotStorage);
792
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
793
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
794
0
    if (!MaybeWrapValue(cx, &storedVal)) {
795
0
      return false;
796
0
    }
797
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
798
0
    if (!isXray) {
799
0
      // In the Xray case we don't need to do this, because getting the
800
0
      // expando object already preserved our wrapper.
801
0
      PreserveWrapper(self);
802
0
    }
803
0
  }
804
0
  // And now make sure args.rval() is in the caller realm.
805
0
  if (MaybeWrapValue(cx, args.rval())) {
806
0
    return true;
807
0
  }
808
0
  return false;
809
0
}
810
811
static const JSJitInfo buildID_getterinfo = {
812
  { (JSJitGetterOp)get_buildID },
813
  { prototypes::id::Navigator },
814
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
815
  JSJitInfo::Getter,
816
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
817
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
818
  false,  /* isInfallible. False in setters. */
819
  false,  /* isMovable.  Not relevant for setters. */
820
  false, /* isEliminatable.  Not relevant for setters. */
821
  false, /* isAlwaysInSlot.  Only relevant for getters. */
822
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
823
  false,  /* isTypedMethod.  Only relevant for methods. */
824
  (DOM_INSTANCE_RESERVED_SLOTS + 1)   /* Reserved slot index, if we're stored in a slot, else 0. */
825
};
826
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 1) <= JSJitInfo::maxSlotIndex, "We won't fit");
827
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 1) < 15, "There is no slot for us");
828
829
MOZ_CAN_RUN_SCRIPT static bool
830
javaEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
831
0
{
832
0
  AUTO_PROFILER_LABEL_FAST("Navigator.javaEnabled", DOM, cx);
833
0
834
0
  bool result(self->JavaEnabled());
835
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
836
0
  args.rval().setBoolean(result);
837
0
  return true;
838
0
}
839
840
static const JSJitInfo::ArgType javaEnabled_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd };
841
static const JSTypedMethodJitInfo javaEnabled_methodinfo = {
842
  {
843
    { (JSJitGetterOp)javaEnabled },
844
    { prototypes::id::Navigator },
845
    { PrototypeTraits<prototypes::id::Navigator>::Depth },
846
    JSJitInfo::Method,
847
    JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
848
    JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
849
    true,  /* isInfallible. False in setters. */
850
    true,  /* isMovable.  Not relevant for setters. */
851
    true, /* isEliminatable.  Not relevant for setters. */
852
    false, /* isAlwaysInSlot.  Only relevant for getters. */
853
    false, /* isLazilyCachedInSlot.  Only relevant for getters. */
854
    true,  /* isTypedMethod.  Only relevant for methods. */
855
    0   /* Reserved slot index, if we're stored in a slot, else 0. */
856
  },
857
  javaEnabled_methodinfo_argTypes
858
};
859
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
860
static_assert(0 < 15, "There is no slot for us");
861
862
MOZ_CAN_RUN_SCRIPT static bool
863
addIdleObserver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
864
0
{
865
0
  AUTO_PROFILER_LABEL_FAST("Navigator.addIdleObserver", DOM, cx);
866
0
867
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
868
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.addIdleObserver");
869
0
  }
870
0
  RootedCallback<OwningNonNull<binding_detail::FastMozIdleObserver>> arg0(cx);
871
0
  if (args[0].isObject()) {
872
0
    { // scope for tempRoot and tempGlobalRoot if needed
873
0
      arg0 = new binding_detail::FastMozIdleObserver(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
874
0
    }
875
0
  } else {
876
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Navigator.addIdleObserver");
877
0
    return false;
878
0
  }
879
0
  FastErrorResult rv;
880
0
  self->AddIdleObserver(MOZ_KnownLive(NonNullHelper(arg0)), rv);
881
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
882
0
    return false;
883
0
  }
884
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
885
0
  args.rval().setUndefined();
886
0
  return true;
887
0
}
888
889
static const JSJitInfo addIdleObserver_methodinfo = {
890
  { (JSJitGetterOp)addIdleObserver },
891
  { prototypes::id::Navigator },
892
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
893
  JSJitInfo::Method,
894
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
895
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
896
  false,  /* isInfallible. False in setters. */
897
  false,  /* isMovable.  Not relevant for setters. */
898
  false, /* isEliminatable.  Not relevant for setters. */
899
  false, /* isAlwaysInSlot.  Only relevant for getters. */
900
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
901
  false,  /* isTypedMethod.  Only relevant for methods. */
902
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
903
};
904
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
905
static_assert(0 < 15, "There is no slot for us");
906
907
MOZ_CAN_RUN_SCRIPT static bool
908
removeIdleObserver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
909
0
{
910
0
  AUTO_PROFILER_LABEL_FAST("Navigator.removeIdleObserver", DOM, cx);
911
0
912
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
913
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.removeIdleObserver");
914
0
  }
915
0
  RootedCallback<OwningNonNull<binding_detail::FastMozIdleObserver>> arg0(cx);
916
0
  if (args[0].isObject()) {
917
0
    { // scope for tempRoot and tempGlobalRoot if needed
918
0
      arg0 = new binding_detail::FastMozIdleObserver(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
919
0
    }
920
0
  } else {
921
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Navigator.removeIdleObserver");
922
0
    return false;
923
0
  }
924
0
  FastErrorResult rv;
925
0
  self->RemoveIdleObserver(MOZ_KnownLive(NonNullHelper(arg0)), rv);
926
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
927
0
    return false;
928
0
  }
929
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
930
0
  args.rval().setUndefined();
931
0
  return true;
932
0
}
933
934
static const JSJitInfo removeIdleObserver_methodinfo = {
935
  { (JSJitGetterOp)removeIdleObserver },
936
  { prototypes::id::Navigator },
937
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
938
  JSJitInfo::Method,
939
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
940
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
941
  false,  /* isInfallible. False in setters. */
942
  false,  /* isMovable.  Not relevant for setters. */
943
  false, /* isEliminatable.  Not relevant for setters. */
944
  false, /* isAlwaysInSlot.  Only relevant for getters. */
945
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
946
  false,  /* isTypedMethod.  Only relevant for methods. */
947
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
948
};
949
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
950
static_assert(0 < 15, "There is no slot for us");
951
952
MOZ_CAN_RUN_SCRIPT static bool
953
get_connection(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
954
0
{
955
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.connection", DOM, cx);
956
0
957
0
  FastErrorResult rv;
958
0
  auto result(StrongOrRawPtr<mozilla::dom::network::Connection>(self->GetConnection(rv)));
959
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
960
0
    return false;
961
0
  }
962
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
963
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
964
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
965
0
    return false;
966
0
  }
967
0
  return true;
968
0
}
969
970
static const JSJitInfo connection_getterinfo = {
971
  { (JSJitGetterOp)get_connection },
972
  { prototypes::id::Navigator },
973
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
974
  JSJitInfo::Getter,
975
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
976
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
977
  false,  /* isInfallible. False in setters. */
978
  false,  /* isMovable.  Not relevant for setters. */
979
  false, /* isEliminatable.  Not relevant for setters. */
980
  false, /* isAlwaysInSlot.  Only relevant for getters. */
981
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
982
  false,  /* isTypedMethod.  Only relevant for methods. */
983
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
984
};
985
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
986
static_assert(0 < 15, "There is no slot for us");
987
988
MOZ_CAN_RUN_SCRIPT static bool
989
getGamepads(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
990
0
{
991
0
  AUTO_PROFILER_LABEL_FAST("Navigator.getGamepads", DOM, cx);
992
0
993
0
  FastErrorResult rv;
994
0
  nsTArray<StrongPtrForMember<mozilla::dom::Gamepad>::Type> result;
995
0
  self->GetGamepads(result, rv);
996
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
997
0
    return false;
998
0
  }
999
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1000
0
1001
0
  uint32_t length = result.Length();
1002
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1003
0
  if (!returnArray) {
1004
0
    return false;
1005
0
  }
1006
0
  // Scope for 'tmp'
1007
0
  {
1008
0
    JS::Rooted<JS::Value> tmp(cx);
1009
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1010
0
      // Control block to let us common up the JS_DefineElement calls when there
1011
0
      // are different ways to succeed at wrapping the object.
1012
0
      do {
1013
0
        if (!result[sequenceIdx0]) {
1014
0
          tmp.setNull();
1015
0
          break;
1016
0
        }
1017
0
        if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
1018
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
1019
0
          return false;
1020
0
        }
1021
0
        break;
1022
0
      } while (false);
1023
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1024
0
                            JSPROP_ENUMERATE)) {
1025
0
        return false;
1026
0
      }
1027
0
    }
1028
0
  }
1029
0
  args.rval().setObject(*returnArray);
1030
0
  return true;
1031
0
}
1032
1033
static const JSJitInfo getGamepads_methodinfo = {
1034
  { (JSJitGetterOp)getGamepads },
1035
  { prototypes::id::Navigator },
1036
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1037
  JSJitInfo::Method,
1038
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1039
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1040
  false,  /* isInfallible. False in setters. */
1041
  false,  /* isMovable.  Not relevant for setters. */
1042
  false, /* isEliminatable.  Not relevant for setters. */
1043
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1044
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1045
  false,  /* isTypedMethod.  Only relevant for methods. */
1046
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1047
};
1048
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1049
static_assert(0 < 15, "There is no slot for us");
1050
1051
MOZ_CAN_RUN_SCRIPT static bool
1052
requestGamepadServiceTest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1053
0
{
1054
0
  AUTO_PROFILER_LABEL_FAST("Navigator.requestGamepadServiceTest", DOM, cx);
1055
0
1056
0
  auto result(StrongOrRawPtr<mozilla::dom::GamepadServiceTest>(self->RequestGamepadServiceTest()));
1057
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1058
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1059
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1060
0
    return false;
1061
0
  }
1062
0
  return true;
1063
0
}
1064
1065
static const JSJitInfo requestGamepadServiceTest_methodinfo = {
1066
  { (JSJitGetterOp)requestGamepadServiceTest },
1067
  { prototypes::id::Navigator },
1068
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1069
  JSJitInfo::Method,
1070
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1071
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1072
  false,  /* isInfallible. False in setters. */
1073
  false,  /* isMovable.  Not relevant for setters. */
1074
  false, /* isEliminatable.  Not relevant for setters. */
1075
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1076
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1077
  false,  /* isTypedMethod.  Only relevant for methods. */
1078
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1079
};
1080
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1081
static_assert(0 < 15, "There is no slot for us");
1082
1083
MOZ_CAN_RUN_SCRIPT static bool
1084
getVRDisplays(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1085
0
{
1086
0
  AUTO_PROFILER_LABEL_FAST("Navigator.getVRDisplays", DOM, cx);
1087
0
1088
0
  FastErrorResult rv;
1089
0
  auto result(StrongOrRawPtr<Promise>(self->GetVRDisplays(rv)));
1090
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1091
0
    return false;
1092
0
  }
1093
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1094
0
  if (!ToJSValue(cx, result, args.rval())) {
1095
0
    return false;
1096
0
  }
1097
0
  return true;
1098
0
}
1099
1100
MOZ_CAN_RUN_SCRIPT static bool
1101
getVRDisplays_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1102
0
{
1103
0
  bool ok = getVRDisplays(cx, obj, self, args);
1104
0
  if (ok) {
1105
0
    return true;
1106
0
  }
1107
0
  return ConvertExceptionToPromise(cx, args.rval());
1108
0
}
1109
1110
static const JSJitInfo getVRDisplays_methodinfo = {
1111
  { (JSJitGetterOp)getVRDisplays_promiseWrapper },
1112
  { prototypes::id::Navigator },
1113
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1114
  JSJitInfo::Method,
1115
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1116
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1117
  false,  /* isInfallible. False in setters. */
1118
  false,  /* isMovable.  Not relevant for setters. */
1119
  false, /* isEliminatable.  Not relevant for setters. */
1120
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1121
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1122
  false,  /* isTypedMethod.  Only relevant for methods. */
1123
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1124
};
1125
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1126
static_assert(0 < 15, "There is no slot for us");
1127
1128
MOZ_CAN_RUN_SCRIPT static bool
1129
get_activeVRDisplays(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1130
0
{
1131
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.activeVRDisplays", DOM, cx);
1132
0
1133
0
  // Have to either root across the getter call or reget after.
1134
0
  bool isXray;
1135
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
1136
0
  if (!slotStorage) {
1137
0
    return false;
1138
0
  }
1139
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 2) : (DOM_INSTANCE_RESERVED_SLOTS + 2);
1140
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1141
0
  {
1142
0
    // Scope for cachedVal
1143
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1144
0
    if (!cachedVal.isUndefined()) {
1145
0
      args.rval().set(cachedVal);
1146
0
      // The cached value is in the compartment of slotStorage,
1147
0
      // so wrap into the caller compartment as needed.
1148
0
      if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
1149
0
        return true;
1150
0
      }
1151
0
      return false;
1152
0
    }
1153
0
  }
1154
0
1155
0
  nsTArray<StrongPtrForMember<mozilla::dom::VRDisplay>::Type> result;
1156
0
  self->GetActiveVRDisplays(result);
1157
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1158
0
  {
1159
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
1160
0
    JSAutoRealm ar(cx, conversionScope);
1161
0
    do { // block we break out of when done wrapping
1162
0
1163
0
      uint32_t length = result.Length();
1164
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1165
0
      if (!returnArray) {
1166
0
        return false;
1167
0
      }
1168
0
      // Scope for 'tmp'
1169
0
      {
1170
0
        JS::Rooted<JS::Value> tmp(cx);
1171
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1172
0
          // Control block to let us common up the JS_DefineElement calls when there
1173
0
          // are different ways to succeed at wrapping the object.
1174
0
          do {
1175
0
            if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
1176
0
              MOZ_ASSERT(JS_IsExceptionPending(cx));
1177
0
              return false;
1178
0
            }
1179
0
            break;
1180
0
          } while (false);
1181
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1182
0
                                JSPROP_ENUMERATE)) {
1183
0
            return false;
1184
0
          }
1185
0
        }
1186
0
      }
1187
0
      args.rval().setObject(*returnArray);
1188
0
      break;
1189
0
    } while (false);
1190
0
    JS::Rooted<JSObject*> rvalObj(cx, &args.rval().toObject());
1191
0
    if (!JS_FreezeObject(cx, rvalObj)) {
1192
0
      return false;
1193
0
    }
1194
0
  }
1195
0
  { // And now store things in the realm of our slotStorage.
1196
0
    JSAutoRealm ar(cx, slotStorage);
1197
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1198
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1199
0
    if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
1200
0
      return false;
1201
0
    }
1202
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1203
0
    if (!isXray) {
1204
0
      // In the Xray case we don't need to do this, because getting the
1205
0
      // expando object already preserved our wrapper.
1206
0
      PreserveWrapper(self);
1207
0
    }
1208
0
  }
1209
0
  // And now make sure args.rval() is in the caller realm.
1210
0
  if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
1211
0
    return true;
1212
0
  }
1213
0
  return false;
1214
0
}
1215
1216
static const JSJitInfo activeVRDisplays_getterinfo = {
1217
  { (JSJitGetterOp)get_activeVRDisplays },
1218
  { prototypes::id::Navigator },
1219
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1220
  JSJitInfo::Getter,
1221
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1222
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1223
  false,  /* isInfallible. False in setters. */
1224
  true,  /* isMovable.  Not relevant for setters. */
1225
  true, /* isEliminatable.  Not relevant for setters. */
1226
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1227
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
1228
  false,  /* isTypedMethod.  Only relevant for methods. */
1229
  (DOM_INSTANCE_RESERVED_SLOTS + 2)   /* Reserved slot index, if we're stored in a slot, else 0. */
1230
};
1231
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 2) <= JSJitInfo::maxSlotIndex, "We won't fit");
1232
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 2) < 15, "There is no slot for us");
1233
1234
MOZ_CAN_RUN_SCRIPT static bool
1235
get_isWebVRContentDetected(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1236
0
{
1237
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.isWebVRContentDetected", DOM, cx);
1238
0
1239
0
  bool result(self->IsWebVRContentDetected());
1240
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1241
0
  args.rval().setBoolean(result);
1242
0
  return true;
1243
0
}
1244
1245
static const JSJitInfo isWebVRContentDetected_getterinfo = {
1246
  { (JSJitGetterOp)get_isWebVRContentDetected },
1247
  { prototypes::id::Navigator },
1248
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1249
  JSJitInfo::Getter,
1250
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1251
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1252
  true,  /* isInfallible. False in setters. */
1253
  false,  /* isMovable.  Not relevant for setters. */
1254
  false, /* isEliminatable.  Not relevant for setters. */
1255
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1256
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1257
  false,  /* isTypedMethod.  Only relevant for methods. */
1258
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1259
};
1260
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1261
static_assert(0 < 15, "There is no slot for us");
1262
1263
MOZ_CAN_RUN_SCRIPT static bool
1264
get_isWebVRContentPresenting(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1265
0
{
1266
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.isWebVRContentPresenting", DOM, cx);
1267
0
1268
0
  bool result(self->IsWebVRContentPresenting());
1269
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1270
0
  args.rval().setBoolean(result);
1271
0
  return true;
1272
0
}
1273
1274
static const JSJitInfo isWebVRContentPresenting_getterinfo = {
1275
  { (JSJitGetterOp)get_isWebVRContentPresenting },
1276
  { prototypes::id::Navigator },
1277
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1278
  JSJitInfo::Getter,
1279
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1280
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1281
  true,  /* isInfallible. False in setters. */
1282
  false,  /* isMovable.  Not relevant for setters. */
1283
  false, /* isEliminatable.  Not relevant for setters. */
1284
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1285
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1286
  false,  /* isTypedMethod.  Only relevant for methods. */
1287
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1288
};
1289
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1290
static_assert(0 < 15, "There is no slot for us");
1291
1292
MOZ_CAN_RUN_SCRIPT static bool
1293
requestVRPresentation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1294
0
{
1295
0
  AUTO_PROFILER_LABEL_FAST("Navigator.requestVRPresentation", DOM, cx);
1296
0
1297
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1298
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.requestVRPresentation");
1299
0
  }
1300
0
  NonNull<mozilla::dom::VRDisplay> arg0;
1301
0
  if (args[0].isObject()) {
1302
0
    {
1303
0
      nsresult rv = UnwrapObject<prototypes::id::VRDisplay, mozilla::dom::VRDisplay>(args[0], arg0);
1304
0
      if (NS_FAILED(rv)) {
1305
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Navigator.requestVRPresentation", "VRDisplay");
1306
0
        return false;
1307
0
      }
1308
0
    }
1309
0
  } else {
1310
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Navigator.requestVRPresentation");
1311
0
    return false;
1312
0
  }
1313
0
  self->RequestVRPresentation(MOZ_KnownLive(NonNullHelper(arg0)));
1314
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1315
0
  args.rval().setUndefined();
1316
0
  return true;
1317
0
}
1318
1319
static const JSJitInfo requestVRPresentation_methodinfo = {
1320
  { (JSJitGetterOp)requestVRPresentation },
1321
  { prototypes::id::Navigator },
1322
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1323
  JSJitInfo::Method,
1324
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1325
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1326
  false,  /* isInfallible. False in setters. */
1327
  false,  /* isMovable.  Not relevant for setters. */
1328
  false, /* isEliminatable.  Not relevant for setters. */
1329
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1330
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1331
  false,  /* isTypedMethod.  Only relevant for methods. */
1332
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1333
};
1334
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1335
static_assert(0 < 15, "There is no slot for us");
1336
1337
MOZ_CAN_RUN_SCRIPT static bool
1338
requestVRServiceTest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1339
0
{
1340
0
  AUTO_PROFILER_LABEL_FAST("Navigator.requestVRServiceTest", DOM, cx);
1341
0
1342
0
  auto result(StrongOrRawPtr<mozilla::dom::VRServiceTest>(self->RequestVRServiceTest()));
1343
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1344
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1345
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1346
0
    return false;
1347
0
  }
1348
0
  return true;
1349
0
}
1350
1351
static const JSJitInfo requestVRServiceTest_methodinfo = {
1352
  { (JSJitGetterOp)requestVRServiceTest },
1353
  { prototypes::id::Navigator },
1354
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1355
  JSJitInfo::Method,
1356
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1357
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1358
  false,  /* isInfallible. False in setters. */
1359
  false,  /* isMovable.  Not relevant for setters. */
1360
  false, /* isEliminatable.  Not relevant for setters. */
1361
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1362
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1363
  false,  /* isTypedMethod.  Only relevant for methods. */
1364
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1365
};
1366
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1367
static_assert(0 < 15, "There is no slot for us");
1368
1369
MOZ_CAN_RUN_SCRIPT static bool
1370
requestMIDIAccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1371
0
{
1372
0
  AUTO_PROFILER_LABEL_FAST("Navigator.requestMIDIAccess", DOM, cx);
1373
0
1374
0
  binding_detail::FastMIDIOptions arg0;
1375
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of Navigator.requestMIDIAccess", false)) {
1376
0
    return false;
1377
0
  }
1378
0
  FastErrorResult rv;
1379
0
  auto result(StrongOrRawPtr<Promise>(self->RequestMIDIAccess(Constify(arg0), rv)));
1380
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1381
0
    return false;
1382
0
  }
1383
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1384
0
  if (!ToJSValue(cx, result, args.rval())) {
1385
0
    return false;
1386
0
  }
1387
0
  return true;
1388
0
}
1389
1390
MOZ_CAN_RUN_SCRIPT static bool
1391
requestMIDIAccess_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1392
0
{
1393
0
  bool ok = requestMIDIAccess(cx, obj, self, args);
1394
0
  if (ok) {
1395
0
    return true;
1396
0
  }
1397
0
  return ConvertExceptionToPromise(cx, args.rval());
1398
0
}
1399
1400
static const JSJitInfo requestMIDIAccess_methodinfo = {
1401
  { (JSJitGetterOp)requestMIDIAccess_promiseWrapper },
1402
  { prototypes::id::Navigator },
1403
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1404
  JSJitInfo::Method,
1405
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1406
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1407
  false,  /* isInfallible. False in setters. */
1408
  false,  /* isMovable.  Not relevant for setters. */
1409
  false, /* isEliminatable.  Not relevant for setters. */
1410
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1411
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1412
  false,  /* isTypedMethod.  Only relevant for methods. */
1413
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1414
};
1415
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1416
static_assert(0 < 15, "There is no slot for us");
1417
1418
MOZ_CAN_RUN_SCRIPT static bool
1419
get_mediaDevices(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1420
0
{
1421
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.mediaDevices", DOM, cx);
1422
0
1423
0
  FastErrorResult rv;
1424
0
  auto result(StrongOrRawPtr<mozilla::dom::MediaDevices>(self->GetMediaDevices(rv)));
1425
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1426
0
    return false;
1427
0
  }
1428
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1429
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1430
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1431
0
    return false;
1432
0
  }
1433
0
  return true;
1434
0
}
1435
1436
static const JSJitInfo mediaDevices_getterinfo = {
1437
  { (JSJitGetterOp)get_mediaDevices },
1438
  { prototypes::id::Navigator },
1439
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1440
  JSJitInfo::Getter,
1441
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1442
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1443
  false,  /* isInfallible. False in setters. */
1444
  false,  /* isMovable.  Not relevant for setters. */
1445
  false, /* isEliminatable.  Not relevant for setters. */
1446
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1447
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1448
  false,  /* isTypedMethod.  Only relevant for methods. */
1449
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1450
};
1451
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1452
static_assert(0 < 15, "There is no slot for us");
1453
1454
MOZ_CAN_RUN_SCRIPT static bool
1455
mozGetUserMedia(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1456
0
{
1457
0
  AUTO_PROFILER_LABEL_FAST("Navigator.mozGetUserMedia", DOM, cx);
1458
0
1459
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
1460
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.mozGetUserMedia");
1461
0
  }
1462
0
  DeprecationWarning(cx, obj, nsIDocument::eNavigatorGetUserMedia);
1463
0
  binding_detail::FastMediaStreamConstraints arg0;
1464
0
  if (!arg0.Init(cx, args[0],  "Argument 1 of Navigator.mozGetUserMedia", false)) {
1465
0
    return false;
1466
0
  }
1467
0
  RootedCallback<OwningNonNull<binding_detail::FastNavigatorUserMediaSuccessCallback>> arg1(cx);
1468
0
  if (args[1].isObject()) {
1469
0
    if (JS::IsCallable(&args[1].toObject())) {
1470
0
    { // scope for tempRoot and tempGlobalRoot if needed
1471
0
      arg1 = new binding_detail::FastNavigatorUserMediaSuccessCallback(&args[1].toObject(), JS::CurrentGlobalOrNull(cx));
1472
0
    }
1473
0
    } else {
1474
0
      ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of Navigator.mozGetUserMedia");
1475
0
      return false;
1476
0
    }
1477
0
  } else {
1478
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Navigator.mozGetUserMedia");
1479
0
    return false;
1480
0
  }
1481
0
  RootedCallback<OwningNonNull<binding_detail::FastNavigatorUserMediaErrorCallback>> arg2(cx);
1482
0
  if (args[2].isObject()) {
1483
0
    if (JS::IsCallable(&args[2].toObject())) {
1484
0
    { // scope for tempRoot and tempGlobalRoot if needed
1485
0
      arg2 = new binding_detail::FastNavigatorUserMediaErrorCallback(&args[2].toObject(), JS::CurrentGlobalOrNull(cx));
1486
0
    }
1487
0
    } else {
1488
0
      ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 3 of Navigator.mozGetUserMedia");
1489
0
      return false;
1490
0
    }
1491
0
  } else {
1492
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 3 of Navigator.mozGetUserMedia");
1493
0
    return false;
1494
0
  }
1495
0
  FastErrorResult rv;
1496
0
  self->MozGetUserMedia(Constify(arg0), NonNullHelper(arg1), NonNullHelper(arg2), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
1497
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1498
0
    return false;
1499
0
  }
1500
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1501
0
  args.rval().setUndefined();
1502
0
  return true;
1503
0
}
1504
1505
static const JSJitInfo mozGetUserMedia_methodinfo = {
1506
  { (JSJitGetterOp)mozGetUserMedia },
1507
  { prototypes::id::Navigator },
1508
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1509
  JSJitInfo::Method,
1510
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1511
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1512
  false,  /* isInfallible. False in setters. */
1513
  false,  /* isMovable.  Not relevant for setters. */
1514
  false, /* isEliminatable.  Not relevant for setters. */
1515
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1516
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1517
  false,  /* isTypedMethod.  Only relevant for methods. */
1518
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1519
};
1520
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1521
static_assert(0 < 15, "There is no slot for us");
1522
1523
MOZ_CAN_RUN_SCRIPT static bool
1524
mozGetUserMediaDevices(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1525
0
{
1526
0
  AUTO_PROFILER_LABEL_FAST("Navigator.mozGetUserMediaDevices", DOM, cx);
1527
0
1528
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
1529
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.mozGetUserMediaDevices");
1530
0
  }
1531
0
  binding_detail::FastMediaStreamConstraints arg0;
1532
0
  if (!arg0.Init(cx, args[0],  "Argument 1 of Navigator.mozGetUserMediaDevices", false)) {
1533
0
    return false;
1534
0
  }
1535
0
  RootedCallback<OwningNonNull<binding_detail::FastMozGetUserMediaDevicesSuccessCallback>> arg1(cx);
1536
0
  if (args[1].isObject()) {
1537
0
    if (JS::IsCallable(&args[1].toObject())) {
1538
0
    { // scope for tempRoot and tempGlobalRoot if needed
1539
0
      arg1 = new binding_detail::FastMozGetUserMediaDevicesSuccessCallback(&args[1].toObject(), JS::CurrentGlobalOrNull(cx));
1540
0
    }
1541
0
    } else {
1542
0
      ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of Navigator.mozGetUserMediaDevices");
1543
0
      return false;
1544
0
    }
1545
0
  } else {
1546
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Navigator.mozGetUserMediaDevices");
1547
0
    return false;
1548
0
  }
1549
0
  RootedCallback<OwningNonNull<binding_detail::FastNavigatorUserMediaErrorCallback>> arg2(cx);
1550
0
  if (args[2].isObject()) {
1551
0
    if (JS::IsCallable(&args[2].toObject())) {
1552
0
    { // scope for tempRoot and tempGlobalRoot if needed
1553
0
      arg2 = new binding_detail::FastNavigatorUserMediaErrorCallback(&args[2].toObject(), JS::CurrentGlobalOrNull(cx));
1554
0
    }
1555
0
    } else {
1556
0
      ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 3 of Navigator.mozGetUserMediaDevices");
1557
0
      return false;
1558
0
    }
1559
0
  } else {
1560
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 3 of Navigator.mozGetUserMediaDevices");
1561
0
    return false;
1562
0
  }
1563
0
  uint64_t arg3;
1564
0
  if (args.hasDefined(3)) {
1565
0
    if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[3], &arg3)) {
1566
0
      return false;
1567
0
    }
1568
0
  } else {
1569
0
    arg3 = 0ULL;
1570
0
  }
1571
0
  binding_detail::FakeString arg4;
1572
0
  if (args.hasDefined(4)) {
1573
0
    if (!ConvertJSValueToString(cx, args[4], eStringify, eStringify, arg4)) {
1574
0
      return false;
1575
0
    }
1576
0
  } else {
1577
0
    static const char16_t data[] = { 0 };
1578
0
    arg4.Rebind(data, ArrayLength(data) - 1);
1579
0
  }
1580
0
  FastErrorResult rv;
1581
0
  self->MozGetUserMediaDevices(Constify(arg0), NonNullHelper(arg1), NonNullHelper(arg2), arg3, NonNullHelper(Constify(arg4)), rv);
1582
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1583
0
    return false;
1584
0
  }
1585
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1586
0
  args.rval().setUndefined();
1587
0
  return true;
1588
0
}
1589
1590
static const JSJitInfo mozGetUserMediaDevices_methodinfo = {
1591
  { (JSJitGetterOp)mozGetUserMediaDevices },
1592
  { prototypes::id::Navigator },
1593
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1594
  JSJitInfo::Method,
1595
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1596
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1597
  false,  /* isInfallible. False in setters. */
1598
  false,  /* isMovable.  Not relevant for setters. */
1599
  false, /* isEliminatable.  Not relevant for setters. */
1600
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1601
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1602
  false,  /* isTypedMethod.  Only relevant for methods. */
1603
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1604
};
1605
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1606
static_assert(0 < 15, "There is no slot for us");
1607
1608
MOZ_CAN_RUN_SCRIPT static bool
1609
get_serviceWorker(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1610
0
{
1611
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.serviceWorker", DOM, cx);
1612
0
1613
0
  auto result(StrongOrRawPtr<mozilla::dom::ServiceWorkerContainer>(self->ServiceWorker()));
1614
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1615
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1616
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1617
0
    return false;
1618
0
  }
1619
0
  return true;
1620
0
}
1621
1622
static const JSJitInfo serviceWorker_getterinfo = {
1623
  { (JSJitGetterOp)get_serviceWorker },
1624
  { prototypes::id::Navigator },
1625
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1626
  JSJitInfo::Getter,
1627
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
1628
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1629
  false,  /* isInfallible. False in setters. */
1630
  true,  /* isMovable.  Not relevant for setters. */
1631
  true, /* isEliminatable.  Not relevant for setters. */
1632
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1633
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1634
  false,  /* isTypedMethod.  Only relevant for methods. */
1635
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1636
};
1637
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1638
static_assert(0 < 15, "There is no slot for us");
1639
1640
MOZ_CAN_RUN_SCRIPT static bool
1641
sendBeacon(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1642
0
{
1643
0
  AUTO_PROFILER_LABEL_FAST("Navigator.sendBeacon", DOM, cx);
1644
0
1645
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1646
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.sendBeacon");
1647
0
  }
1648
0
  binding_detail::FakeString arg0;
1649
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1650
0
    return false;
1651
0
  }
1652
0
  Nullable<BlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString > arg1;
1653
0
  Maybe<BlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVStringArgument> arg1_holder;
1654
0
  if (!(args.hasDefined(1)) || args[1].isNullOrUndefined()) {
1655
0
    arg1.SetNull();
1656
0
  } else {
1657
0
    arg1_holder.emplace(arg1.SetValue());
1658
0
    {
1659
0
      bool done = false, failed = false, tryNext;
1660
0
      if (args[1].isObject()) {
1661
0
        done = (failed = !arg1_holder.ref().TrySetToBlob(cx, args[1], tryNext, false)) || !tryNext ||
1662
0
               (failed = !arg1_holder.ref().TrySetToArrayBufferView(cx, args[1], tryNext, false)) || !tryNext ||
1663
0
               (failed = !arg1_holder.ref().TrySetToArrayBuffer(cx, args[1], tryNext, false)) || !tryNext ||
1664
0
               (failed = !arg1_holder.ref().TrySetToFormData(cx, args[1], tryNext, false)) || !tryNext ||
1665
0
               (failed = !arg1_holder.ref().TrySetToURLSearchParams(cx, args[1], tryNext, false)) || !tryNext;
1666
0
1667
0
      }
1668
0
      if (!done) {
1669
0
        do {
1670
0
          done = (failed = !arg1_holder.ref().TrySetToUSVString(cx, args[1], tryNext)) || !tryNext;
1671
0
          break;
1672
0
        } while (false);
1673
0
      }
1674
0
      if (failed) {
1675
0
        return false;
1676
0
      }
1677
0
      if (!done) {
1678
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of Navigator.sendBeacon", "Blob, ArrayBufferView, ArrayBuffer, FormData, URLSearchParams");
1679
0
        return false;
1680
0
      }
1681
0
    }
1682
0
  }
1683
0
  FastErrorResult rv;
1684
0
  bool result(self->SendBeacon(NonNullHelper(Constify(arg0)), Constify(arg1), rv));
1685
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1686
0
    return false;
1687
0
  }
1688
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1689
0
  args.rval().setBoolean(result);
1690
0
  return true;
1691
0
}
1692
1693
static const JSJitInfo sendBeacon_methodinfo = {
1694
  { (JSJitGetterOp)sendBeacon },
1695
  { prototypes::id::Navigator },
1696
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1697
  JSJitInfo::Method,
1698
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1699
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1700
  false,  /* isInfallible. False in setters. */
1701
  false,  /* isMovable.  Not relevant for setters. */
1702
  false, /* isEliminatable.  Not relevant for setters. */
1703
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1704
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1705
  false,  /* isTypedMethod.  Only relevant for methods. */
1706
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1707
};
1708
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1709
static_assert(0 < 15, "There is no slot for us");
1710
1711
MOZ_CAN_RUN_SCRIPT static bool
1712
get_presentation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1713
0
{
1714
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.presentation", DOM, cx);
1715
0
1716
0
  FastErrorResult rv;
1717
0
  auto result(StrongOrRawPtr<mozilla::dom::Presentation>(self->GetPresentation(rv)));
1718
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1719
0
    return false;
1720
0
  }
1721
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1722
0
  if (!result) {
1723
0
    args.rval().setNull();
1724
0
    return true;
1725
0
  }
1726
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1727
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1728
0
    return false;
1729
0
  }
1730
0
  return true;
1731
0
}
1732
1733
static const JSJitInfo presentation_getterinfo = {
1734
  { (JSJitGetterOp)get_presentation },
1735
  { prototypes::id::Navigator },
1736
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1737
  JSJitInfo::Getter,
1738
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
1739
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1740
  false,  /* isInfallible. False in setters. */
1741
  false,  /* isMovable.  Not relevant for setters. */
1742
  false, /* isEliminatable.  Not relevant for setters. */
1743
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1744
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1745
  false,  /* isTypedMethod.  Only relevant for methods. */
1746
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1747
};
1748
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1749
static_assert(0 < 15, "There is no slot for us");
1750
1751
MOZ_CAN_RUN_SCRIPT static bool
1752
get_mozTCPSocket(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1753
0
{
1754
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.mozTCPSocket", DOM, cx);
1755
0
1756
0
  auto result(StrongOrRawPtr<mozilla::dom::LegacyMozTCPSocket>(self->MozTCPSocket()));
1757
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1758
0
  static_assert(!IsPointer<decltype(result)>::value,
1759
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1760
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
1761
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1762
0
    return false;
1763
0
  }
1764
0
  return true;
1765
0
}
1766
1767
static const JSJitInfo mozTCPSocket_getterinfo = {
1768
  { (JSJitGetterOp)get_mozTCPSocket },
1769
  { prototypes::id::Navigator },
1770
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1771
  JSJitInfo::Getter,
1772
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1773
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1774
  false,  /* isInfallible. False in setters. */
1775
  false,  /* isMovable.  Not relevant for setters. */
1776
  false, /* isEliminatable.  Not relevant for setters. */
1777
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1778
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1779
  false,  /* isTypedMethod.  Only relevant for methods. */
1780
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1781
};
1782
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1783
static_assert(0 < 15, "There is no slot for us");
1784
1785
MOZ_CAN_RUN_SCRIPT static bool
1786
requestMediaKeySystemAccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1787
0
{
1788
0
  AUTO_PROFILER_LABEL_FAST("Navigator.requestMediaKeySystemAccess", DOM, cx);
1789
0
1790
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
1791
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.requestMediaKeySystemAccess");
1792
0
  }
1793
0
  binding_detail::FakeString arg0;
1794
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1795
0
    return false;
1796
0
  }
1797
0
  binding_detail::AutoSequence<MediaKeySystemConfiguration> arg1;
1798
0
  if (args[1].isObject()) {
1799
0
    JS::ForOfIterator iter(cx);
1800
0
    if (!iter.init(args[1], JS::ForOfIterator::AllowNonIterable)) {
1801
0
      return false;
1802
0
    }
1803
0
    if (!iter.valueIsIterable()) {
1804
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of Navigator.requestMediaKeySystemAccess");
1805
0
      return false;
1806
0
    }
1807
0
    binding_detail::AutoSequence<MediaKeySystemConfiguration> &arr = arg1;
1808
0
    JS::Rooted<JS::Value> temp(cx);
1809
0
    while (true) {
1810
0
      bool done;
1811
0
      if (!iter.next(&temp, &done)) {
1812
0
        return false;
1813
0
      }
1814
0
      if (done) {
1815
0
        break;
1816
0
      }
1817
0
      MediaKeySystemConfiguration* slotPtr = arr.AppendElement(mozilla::fallible);
1818
0
      if (!slotPtr) {
1819
0
        JS_ReportOutOfMemory(cx);
1820
0
        return false;
1821
0
      }
1822
0
      MediaKeySystemConfiguration& slot = *slotPtr;
1823
0
      if (!slot.Init(cx, temp,  "Element of argument 2 of Navigator.requestMediaKeySystemAccess", false)) {
1824
0
        return false;
1825
0
      }
1826
0
    }
1827
0
  } else {
1828
0
    ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of Navigator.requestMediaKeySystemAccess");
1829
0
    return false;
1830
0
  }
1831
0
  FastErrorResult rv;
1832
0
  auto result(StrongOrRawPtr<Promise>(self->RequestMediaKeySystemAccess(NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
1833
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1834
0
    return false;
1835
0
  }
1836
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1837
0
  static_assert(!IsPointer<decltype(result)>::value,
1838
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1839
0
  if (!ToJSValue(cx, result, args.rval())) {
1840
0
    return false;
1841
0
  }
1842
0
  return true;
1843
0
}
1844
1845
MOZ_CAN_RUN_SCRIPT static bool
1846
requestMediaKeySystemAccess_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
1847
0
{
1848
0
  bool ok = requestMediaKeySystemAccess(cx, obj, self, args);
1849
0
  if (ok) {
1850
0
    return true;
1851
0
  }
1852
0
  return ConvertExceptionToPromise(cx, args.rval());
1853
0
}
1854
1855
static const JSJitInfo requestMediaKeySystemAccess_methodinfo = {
1856
  { (JSJitGetterOp)requestMediaKeySystemAccess_promiseWrapper },
1857
  { prototypes::id::Navigator },
1858
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1859
  JSJitInfo::Method,
1860
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1861
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1862
  false,  /* isInfallible. False in setters. */
1863
  false,  /* isMovable.  Not relevant for setters. */
1864
  false, /* isEliminatable.  Not relevant for setters. */
1865
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1866
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1867
  false,  /* isTypedMethod.  Only relevant for methods. */
1868
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1869
};
1870
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1871
static_assert(0 < 15, "There is no slot for us");
1872
1873
MOZ_CAN_RUN_SCRIPT static bool
1874
get_credentials(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1875
0
{
1876
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.credentials", DOM, cx);
1877
0
1878
0
  auto result(StrongOrRawPtr<mozilla::dom::CredentialsContainer>(self->Credentials()));
1879
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1880
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1881
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1882
0
    return false;
1883
0
  }
1884
0
  return true;
1885
0
}
1886
1887
static const JSJitInfo credentials_getterinfo = {
1888
  { (JSJitGetterOp)get_credentials },
1889
  { prototypes::id::Navigator },
1890
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1891
  JSJitInfo::Getter,
1892
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
1893
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1894
  false,  /* isInfallible. False in setters. */
1895
  true,  /* isMovable.  Not relevant for setters. */
1896
  true, /* isEliminatable.  Not relevant for setters. */
1897
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1898
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1899
  false,  /* isTypedMethod.  Only relevant for methods. */
1900
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1901
};
1902
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1903
static_assert(0 < 15, "There is no slot for us");
1904
1905
MOZ_CAN_RUN_SCRIPT static bool
1906
get_clipboard(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1907
0
{
1908
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.clipboard", DOM, cx);
1909
0
1910
0
  auto result(StrongOrRawPtr<mozilla::dom::Clipboard>(self->Clipboard()));
1911
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1912
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1913
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1914
0
    return false;
1915
0
  }
1916
0
  return true;
1917
0
}
1918
1919
static const JSJitInfo clipboard_getterinfo = {
1920
  { (JSJitGetterOp)get_clipboard },
1921
  { prototypes::id::Navigator },
1922
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1923
  JSJitInfo::Getter,
1924
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
1925
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1926
  false,  /* isInfallible. False in setters. */
1927
  true,  /* isMovable.  Not relevant for setters. */
1928
  true, /* isEliminatable.  Not relevant for setters. */
1929
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1930
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1931
  false,  /* isTypedMethod.  Only relevant for methods. */
1932
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1933
};
1934
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1935
static_assert(0 < 15, "There is no slot for us");
1936
1937
MOZ_CAN_RUN_SCRIPT static bool
1938
get_mozAddonManager(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
1939
0
{
1940
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.mozAddonManager", DOM, cx);
1941
0
1942
0
  // Have to either root across the getter call or reget after.
1943
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
1944
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
1945
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 3);
1946
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1947
0
  {
1948
0
    // Scope for cachedVal
1949
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1950
0
    if (!cachedVal.isUndefined()) {
1951
0
      args.rval().set(cachedVal);
1952
0
      // The cached value is in the compartment of slotStorage,
1953
0
      // so wrap into the caller compartment as needed.
1954
0
      if (MaybeWrapValue(cx, args.rval())) {
1955
0
        return true;
1956
0
      }
1957
0
      return false;
1958
0
    }
1959
0
  }
1960
0
1961
0
  FastErrorResult rv;
1962
0
  auto result(StrongOrRawPtr<mozilla::dom::AddonManager>(AddonManager_Binding::ConstructNavigatorObject(cx, slotStorage, rv)));
1963
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1964
0
    return false;
1965
0
  }
1966
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1967
0
  {
1968
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
1969
0
    JSAutoRealm ar(cx, conversionScope);
1970
0
    do { // block we break out of when done wrapping
1971
0
      if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1972
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
1973
0
        return false;
1974
0
      }
1975
0
      break;
1976
0
    } while (false);
1977
0
  }
1978
0
  { // And now store things in the realm of our slotStorage.
1979
0
    JSAutoRealm ar(cx, slotStorage);
1980
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1981
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1982
0
    if (!MaybeWrapValue(cx, &storedVal)) {
1983
0
      return false;
1984
0
    }
1985
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1986
0
    PreserveWrapper(self);
1987
0
  }
1988
0
  // And now make sure args.rval() is in the caller realm.
1989
0
  if (MaybeWrapValue(cx, args.rval())) {
1990
0
    return true;
1991
0
  }
1992
0
  return false;
1993
0
}
1994
1995
static const JSJitInfo mozAddonManager_getterinfo = {
1996
  { (JSJitGetterOp)get_mozAddonManager },
1997
  { prototypes::id::Navigator },
1998
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
1999
  JSJitInfo::Getter,
2000
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2001
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2002
  false,  /* isInfallible. False in setters. */
2003
  false,  /* isMovable.  Not relevant for setters. */
2004
  false, /* isEliminatable.  Not relevant for setters. */
2005
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2006
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2007
  false,  /* isTypedMethod.  Only relevant for methods. */
2008
  (DOM_INSTANCE_RESERVED_SLOTS + 3)   /* Reserved slot index, if we're stored in a slot, else 0. */
2009
};
2010
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 3) <= JSJitInfo::maxSlotIndex, "We won't fit");
2011
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 3) < 15, "There is no slot for us");
2012
2013
MOZ_CAN_RUN_SCRIPT static bool
2014
get_webdriver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2015
0
{
2016
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.webdriver", DOM, cx);
2017
0
2018
0
  bool result(self->Webdriver());
2019
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2020
0
  args.rval().setBoolean(result);
2021
0
  return true;
2022
0
}
2023
2024
static const JSJitInfo webdriver_getterinfo = {
2025
  { (JSJitGetterOp)get_webdriver },
2026
  { prototypes::id::Navigator },
2027
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2028
  JSJitInfo::Getter,
2029
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2030
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
2031
  true,  /* isInfallible. False in setters. */
2032
  false,  /* isMovable.  Not relevant for setters. */
2033
  false, /* isEliminatable.  Not relevant for setters. */
2034
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2035
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2036
  false,  /* isTypedMethod.  Only relevant for methods. */
2037
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2038
};
2039
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2040
static_assert(0 < 15, "There is no slot for us");
2041
2042
MOZ_CAN_RUN_SCRIPT static bool
2043
get_hardwareConcurrency(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2044
0
{
2045
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.hardwareConcurrency", DOM, cx);
2046
0
2047
0
  uint64_t result(self->HardwareConcurrency());
2048
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2049
0
  args.rval().set(JS_NumberValue(double(result)));
2050
0
  return true;
2051
0
}
2052
2053
static const JSJitInfo hardwareConcurrency_getterinfo = {
2054
  { (JSJitGetterOp)get_hardwareConcurrency },
2055
  { prototypes::id::Navigator },
2056
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2057
  JSJitInfo::Getter,
2058
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2059
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2060
  true,  /* isInfallible. False in setters. */
2061
  false,  /* isMovable.  Not relevant for setters. */
2062
  false, /* isEliminatable.  Not relevant for setters. */
2063
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2064
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2065
  false,  /* isTypedMethod.  Only relevant for methods. */
2066
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2067
};
2068
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2069
static_assert(0 < 15, "There is no slot for us");
2070
2071
MOZ_CAN_RUN_SCRIPT static bool
2072
registerProtocolHandler(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
2073
0
{
2074
0
  AUTO_PROFILER_LABEL_FAST("Navigator.registerProtocolHandler", DOM, cx);
2075
0
2076
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
2077
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.registerProtocolHandler");
2078
0
  }
2079
0
  binding_detail::FakeString arg0;
2080
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
2081
0
    return false;
2082
0
  }
2083
0
  binding_detail::FakeString arg1;
2084
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
2085
0
    return false;
2086
0
  }
2087
0
  binding_detail::FakeString arg2;
2088
0
  if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
2089
0
    return false;
2090
0
  }
2091
0
  FastErrorResult rv;
2092
0
  self->RegisterProtocolHandler(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv);
2093
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2094
0
    return false;
2095
0
  }
2096
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2097
0
  args.rval().setUndefined();
2098
0
  return true;
2099
0
}
2100
2101
static const JSJitInfo registerProtocolHandler_methodinfo = {
2102
  { (JSJitGetterOp)registerProtocolHandler },
2103
  { prototypes::id::Navigator },
2104
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2105
  JSJitInfo::Method,
2106
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2107
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2108
  false,  /* isInfallible. False in setters. */
2109
  false,  /* isMovable.  Not relevant for setters. */
2110
  false, /* isEliminatable.  Not relevant for setters. */
2111
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2112
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2113
  false,  /* isTypedMethod.  Only relevant for methods. */
2114
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2115
};
2116
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2117
static_assert(0 < 15, "There is no slot for us");
2118
2119
MOZ_CAN_RUN_SCRIPT static bool
2120
registerContentHandler(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
2121
0
{
2122
0
  AUTO_PROFILER_LABEL_FAST("Navigator.registerContentHandler", DOM, cx);
2123
0
2124
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
2125
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Navigator.registerContentHandler");
2126
0
  }
2127
0
  binding_detail::FakeString arg0;
2128
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
2129
0
    return false;
2130
0
  }
2131
0
  binding_detail::FakeString arg1;
2132
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
2133
0
    return false;
2134
0
  }
2135
0
  binding_detail::FakeString arg2;
2136
0
  if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
2137
0
    return false;
2138
0
  }
2139
0
  FastErrorResult rv;
2140
0
  self->RegisterContentHandler(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv);
2141
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2142
0
    return false;
2143
0
  }
2144
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2145
0
  args.rval().setUndefined();
2146
0
  return true;
2147
0
}
2148
2149
static const JSJitInfo registerContentHandler_methodinfo = {
2150
  { (JSJitGetterOp)registerContentHandler },
2151
  { prototypes::id::Navigator },
2152
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2153
  JSJitInfo::Method,
2154
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2155
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2156
  false,  /* isInfallible. False in setters. */
2157
  false,  /* isMovable.  Not relevant for setters. */
2158
  false, /* isEliminatable.  Not relevant for setters. */
2159
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2160
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2161
  false,  /* isTypedMethod.  Only relevant for methods. */
2162
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2163
};
2164
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2165
static_assert(0 < 15, "There is no slot for us");
2166
2167
MOZ_CAN_RUN_SCRIPT static bool
2168
get_geolocation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2169
0
{
2170
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.geolocation", DOM, cx);
2171
0
2172
0
  FastErrorResult rv;
2173
0
  auto result(StrongOrRawPtr<mozilla::dom::Geolocation>(self->GetGeolocation(rv)));
2174
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2175
0
    return false;
2176
0
  }
2177
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2178
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
2179
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
2180
0
    return false;
2181
0
  }
2182
0
  return true;
2183
0
}
2184
2185
static const JSJitInfo geolocation_getterinfo = {
2186
  { (JSJitGetterOp)get_geolocation },
2187
  { prototypes::id::Navigator },
2188
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2189
  JSJitInfo::Getter,
2190
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2191
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2192
  false,  /* isInfallible. False in setters. */
2193
  false,  /* isMovable.  Not relevant for setters. */
2194
  false, /* isEliminatable.  Not relevant for setters. */
2195
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2196
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2197
  false,  /* isTypedMethod.  Only relevant for methods. */
2198
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2199
};
2200
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2201
static_assert(0 < 15, "There is no slot for us");
2202
2203
MOZ_CAN_RUN_SCRIPT static bool
2204
get_appCodeName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2205
0
{
2206
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.appCodeName", DOM, cx);
2207
0
2208
0
  // Have to either root across the getter call or reget after.
2209
0
  bool isXray;
2210
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2211
0
  if (!slotStorage) {
2212
0
    return false;
2213
0
  }
2214
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 6) : (DOM_INSTANCE_RESERVED_SLOTS + 6);
2215
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2216
0
  {
2217
0
    // Scope for cachedVal
2218
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2219
0
    if (!cachedVal.isUndefined()) {
2220
0
      args.rval().set(cachedVal);
2221
0
      // The cached value is in the compartment of slotStorage,
2222
0
      // so wrap into the caller compartment as needed.
2223
0
      if (MaybeWrapValue(cx, args.rval())) {
2224
0
        return true;
2225
0
      }
2226
0
      return false;
2227
0
    }
2228
0
  }
2229
0
2230
0
  FastErrorResult rv;
2231
0
  DOMString result;
2232
0
  self->GetAppCodeName(result, rv);
2233
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2234
0
    return false;
2235
0
  }
2236
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2237
0
  {
2238
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2239
0
    JSAutoRealm ar(cx, conversionScope);
2240
0
    do { // block we break out of when done wrapping
2241
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2242
0
        return false;
2243
0
      }
2244
0
      break;
2245
0
    } while (false);
2246
0
  }
2247
0
  { // And now store things in the realm of our slotStorage.
2248
0
    JSAutoRealm ar(cx, slotStorage);
2249
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2250
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2251
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2252
0
      return false;
2253
0
    }
2254
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2255
0
    if (!isXray) {
2256
0
      // In the Xray case we don't need to do this, because getting the
2257
0
      // expando object already preserved our wrapper.
2258
0
      PreserveWrapper(self);
2259
0
    }
2260
0
  }
2261
0
  // And now make sure args.rval() is in the caller realm.
2262
0
  if (MaybeWrapValue(cx, args.rval())) {
2263
0
    return true;
2264
0
  }
2265
0
  return false;
2266
0
}
2267
2268
static const JSJitInfo appCodeName_getterinfo = {
2269
  { (JSJitGetterOp)get_appCodeName },
2270
  { prototypes::id::Navigator },
2271
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2272
  JSJitInfo::Getter,
2273
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2274
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2275
  false,  /* isInfallible. False in setters. */
2276
  false,  /* isMovable.  Not relevant for setters. */
2277
  false, /* isEliminatable.  Not relevant for setters. */
2278
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2279
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2280
  false,  /* isTypedMethod.  Only relevant for methods. */
2281
  (DOM_INSTANCE_RESERVED_SLOTS + 6)   /* Reserved slot index, if we're stored in a slot, else 0. */
2282
};
2283
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 6) <= JSJitInfo::maxSlotIndex, "We won't fit");
2284
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 6) < 15, "There is no slot for us");
2285
2286
MOZ_CAN_RUN_SCRIPT static bool
2287
get_appName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2288
0
{
2289
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.appName", DOM, cx);
2290
0
2291
0
  // Have to either root across the getter call or reget after.
2292
0
  bool isXray;
2293
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2294
0
  if (!slotStorage) {
2295
0
    return false;
2296
0
  }
2297
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 7) : (DOM_INSTANCE_RESERVED_SLOTS + 7);
2298
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2299
0
  {
2300
0
    // Scope for cachedVal
2301
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2302
0
    if (!cachedVal.isUndefined()) {
2303
0
      args.rval().set(cachedVal);
2304
0
      // The cached value is in the compartment of slotStorage,
2305
0
      // so wrap into the caller compartment as needed.
2306
0
      if (MaybeWrapValue(cx, args.rval())) {
2307
0
        return true;
2308
0
      }
2309
0
      return false;
2310
0
    }
2311
0
  }
2312
0
2313
0
  DOMString result;
2314
0
  self->GetAppName(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem);
2315
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2316
0
  {
2317
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2318
0
    JSAutoRealm ar(cx, conversionScope);
2319
0
    do { // block we break out of when done wrapping
2320
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2321
0
        return false;
2322
0
      }
2323
0
      break;
2324
0
    } while (false);
2325
0
  }
2326
0
  { // And now store things in the realm of our slotStorage.
2327
0
    JSAutoRealm ar(cx, slotStorage);
2328
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2329
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2330
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2331
0
      return false;
2332
0
    }
2333
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2334
0
    if (!isXray) {
2335
0
      // In the Xray case we don't need to do this, because getting the
2336
0
      // expando object already preserved our wrapper.
2337
0
      PreserveWrapper(self);
2338
0
    }
2339
0
  }
2340
0
  // And now make sure args.rval() is in the caller realm.
2341
0
  if (MaybeWrapValue(cx, args.rval())) {
2342
0
    return true;
2343
0
  }
2344
0
  return false;
2345
0
}
2346
2347
static const JSJitInfo appName_getterinfo = {
2348
  { (JSJitGetterOp)get_appName },
2349
  { prototypes::id::Navigator },
2350
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2351
  JSJitInfo::Getter,
2352
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2353
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2354
  false,  /* isInfallible. False in setters. */
2355
  true,  /* isMovable.  Not relevant for setters. */
2356
  true, /* isEliminatable.  Not relevant for setters. */
2357
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2358
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2359
  false,  /* isTypedMethod.  Only relevant for methods. */
2360
  (DOM_INSTANCE_RESERVED_SLOTS + 7)   /* Reserved slot index, if we're stored in a slot, else 0. */
2361
};
2362
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 7) <= JSJitInfo::maxSlotIndex, "We won't fit");
2363
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 7) < 15, "There is no slot for us");
2364
2365
MOZ_CAN_RUN_SCRIPT static bool
2366
get_appVersion(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2367
0
{
2368
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.appVersion", DOM, cx);
2369
0
2370
0
  // Have to either root across the getter call or reget after.
2371
0
  bool isXray;
2372
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2373
0
  if (!slotStorage) {
2374
0
    return false;
2375
0
  }
2376
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 8) : (DOM_INSTANCE_RESERVED_SLOTS + 8);
2377
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2378
0
  {
2379
0
    // Scope for cachedVal
2380
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2381
0
    if (!cachedVal.isUndefined()) {
2382
0
      args.rval().set(cachedVal);
2383
0
      // The cached value is in the compartment of slotStorage,
2384
0
      // so wrap into the caller compartment as needed.
2385
0
      if (MaybeWrapValue(cx, args.rval())) {
2386
0
        return true;
2387
0
      }
2388
0
      return false;
2389
0
    }
2390
0
  }
2391
0
2392
0
  FastErrorResult rv;
2393
0
  DOMString result;
2394
0
  self->GetAppVersion(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
2395
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2396
0
    return false;
2397
0
  }
2398
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2399
0
  {
2400
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2401
0
    JSAutoRealm ar(cx, conversionScope);
2402
0
    do { // block we break out of when done wrapping
2403
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2404
0
        return false;
2405
0
      }
2406
0
      break;
2407
0
    } while (false);
2408
0
  }
2409
0
  { // And now store things in the realm of our slotStorage.
2410
0
    JSAutoRealm ar(cx, slotStorage);
2411
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2412
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2413
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2414
0
      return false;
2415
0
    }
2416
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2417
0
    if (!isXray) {
2418
0
      // In the Xray case we don't need to do this, because getting the
2419
0
      // expando object already preserved our wrapper.
2420
0
      PreserveWrapper(self);
2421
0
    }
2422
0
  }
2423
0
  // And now make sure args.rval() is in the caller realm.
2424
0
  if (MaybeWrapValue(cx, args.rval())) {
2425
0
    return true;
2426
0
  }
2427
0
  return false;
2428
0
}
2429
2430
static const JSJitInfo appVersion_getterinfo = {
2431
  { (JSJitGetterOp)get_appVersion },
2432
  { prototypes::id::Navigator },
2433
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2434
  JSJitInfo::Getter,
2435
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2436
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2437
  false,  /* isInfallible. False in setters. */
2438
  false,  /* isMovable.  Not relevant for setters. */
2439
  false, /* isEliminatable.  Not relevant for setters. */
2440
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2441
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2442
  false,  /* isTypedMethod.  Only relevant for methods. */
2443
  (DOM_INSTANCE_RESERVED_SLOTS + 8)   /* Reserved slot index, if we're stored in a slot, else 0. */
2444
};
2445
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 8) <= JSJitInfo::maxSlotIndex, "We won't fit");
2446
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 8) < 15, "There is no slot for us");
2447
2448
MOZ_CAN_RUN_SCRIPT static bool
2449
get_platform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2450
0
{
2451
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.platform", DOM, cx);
2452
0
2453
0
  // Have to either root across the getter call or reget after.
2454
0
  bool isXray;
2455
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2456
0
  if (!slotStorage) {
2457
0
    return false;
2458
0
  }
2459
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 9) : (DOM_INSTANCE_RESERVED_SLOTS + 9);
2460
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2461
0
  {
2462
0
    // Scope for cachedVal
2463
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2464
0
    if (!cachedVal.isUndefined()) {
2465
0
      args.rval().set(cachedVal);
2466
0
      // The cached value is in the compartment of slotStorage,
2467
0
      // so wrap into the caller compartment as needed.
2468
0
      if (MaybeWrapValue(cx, args.rval())) {
2469
0
        return true;
2470
0
      }
2471
0
      return false;
2472
0
    }
2473
0
  }
2474
0
2475
0
  FastErrorResult rv;
2476
0
  DOMString result;
2477
0
  self->GetPlatform(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
2478
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2479
0
    return false;
2480
0
  }
2481
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2482
0
  {
2483
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2484
0
    JSAutoRealm ar(cx, conversionScope);
2485
0
    do { // block we break out of when done wrapping
2486
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2487
0
        return false;
2488
0
      }
2489
0
      break;
2490
0
    } while (false);
2491
0
  }
2492
0
  { // And now store things in the realm of our slotStorage.
2493
0
    JSAutoRealm ar(cx, slotStorage);
2494
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2495
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2496
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2497
0
      return false;
2498
0
    }
2499
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2500
0
    if (!isXray) {
2501
0
      // In the Xray case we don't need to do this, because getting the
2502
0
      // expando object already preserved our wrapper.
2503
0
      PreserveWrapper(self);
2504
0
    }
2505
0
  }
2506
0
  // And now make sure args.rval() is in the caller realm.
2507
0
  if (MaybeWrapValue(cx, args.rval())) {
2508
0
    return true;
2509
0
  }
2510
0
  return false;
2511
0
}
2512
2513
static const JSJitInfo platform_getterinfo = {
2514
  { (JSJitGetterOp)get_platform },
2515
  { prototypes::id::Navigator },
2516
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2517
  JSJitInfo::Getter,
2518
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2519
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2520
  false,  /* isInfallible. False in setters. */
2521
  false,  /* isMovable.  Not relevant for setters. */
2522
  false, /* isEliminatable.  Not relevant for setters. */
2523
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2524
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2525
  false,  /* isTypedMethod.  Only relevant for methods. */
2526
  (DOM_INSTANCE_RESERVED_SLOTS + 9)   /* Reserved slot index, if we're stored in a slot, else 0. */
2527
};
2528
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 9) <= JSJitInfo::maxSlotIndex, "We won't fit");
2529
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 9) < 15, "There is no slot for us");
2530
2531
MOZ_CAN_RUN_SCRIPT static bool
2532
get_userAgent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2533
0
{
2534
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.userAgent", DOM, cx);
2535
0
2536
0
  // Have to either root across the getter call or reget after.
2537
0
  bool isXray;
2538
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2539
0
  if (!slotStorage) {
2540
0
    return false;
2541
0
  }
2542
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 10) : (DOM_INSTANCE_RESERVED_SLOTS + 10);
2543
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2544
0
  {
2545
0
    // Scope for cachedVal
2546
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2547
0
    if (!cachedVal.isUndefined()) {
2548
0
      args.rval().set(cachedVal);
2549
0
      // The cached value is in the compartment of slotStorage,
2550
0
      // so wrap into the caller compartment as needed.
2551
0
      if (MaybeWrapValue(cx, args.rval())) {
2552
0
        return true;
2553
0
      }
2554
0
      return false;
2555
0
    }
2556
0
  }
2557
0
2558
0
  FastErrorResult rv;
2559
0
  DOMString result;
2560
0
  self->GetUserAgent(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
2561
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2562
0
    return false;
2563
0
  }
2564
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2565
0
  {
2566
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2567
0
    JSAutoRealm ar(cx, conversionScope);
2568
0
    do { // block we break out of when done wrapping
2569
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2570
0
        return false;
2571
0
      }
2572
0
      break;
2573
0
    } while (false);
2574
0
  }
2575
0
  { // And now store things in the realm of our slotStorage.
2576
0
    JSAutoRealm ar(cx, slotStorage);
2577
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2578
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2579
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2580
0
      return false;
2581
0
    }
2582
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2583
0
    if (!isXray) {
2584
0
      // In the Xray case we don't need to do this, because getting the
2585
0
      // expando object already preserved our wrapper.
2586
0
      PreserveWrapper(self);
2587
0
    }
2588
0
  }
2589
0
  // And now make sure args.rval() is in the caller realm.
2590
0
  if (MaybeWrapValue(cx, args.rval())) {
2591
0
    return true;
2592
0
  }
2593
0
  return false;
2594
0
}
2595
2596
static const JSJitInfo userAgent_getterinfo = {
2597
  { (JSJitGetterOp)get_userAgent },
2598
  { prototypes::id::Navigator },
2599
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2600
  JSJitInfo::Getter,
2601
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2602
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2603
  false,  /* isInfallible. False in setters. */
2604
  false,  /* isMovable.  Not relevant for setters. */
2605
  false, /* isEliminatable.  Not relevant for setters. */
2606
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2607
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2608
  false,  /* isTypedMethod.  Only relevant for methods. */
2609
  (DOM_INSTANCE_RESERVED_SLOTS + 10)   /* Reserved slot index, if we're stored in a slot, else 0. */
2610
};
2611
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 10) <= JSJitInfo::maxSlotIndex, "We won't fit");
2612
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 10) < 15, "There is no slot for us");
2613
2614
MOZ_CAN_RUN_SCRIPT static bool
2615
get_product(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2616
0
{
2617
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.product", DOM, cx);
2618
0
2619
0
  // Have to either root across the getter call or reget after.
2620
0
  bool isXray;
2621
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2622
0
  if (!slotStorage) {
2623
0
    return false;
2624
0
  }
2625
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 11) : (DOM_INSTANCE_RESERVED_SLOTS + 11);
2626
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2627
0
  {
2628
0
    // Scope for cachedVal
2629
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2630
0
    if (!cachedVal.isUndefined()) {
2631
0
      args.rval().set(cachedVal);
2632
0
      // The cached value is in the compartment of slotStorage,
2633
0
      // so wrap into the caller compartment as needed.
2634
0
      if (MaybeWrapValue(cx, args.rval())) {
2635
0
        return true;
2636
0
      }
2637
0
      return false;
2638
0
    }
2639
0
  }
2640
0
2641
0
  DOMString result;
2642
0
  self->GetProduct(result);
2643
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2644
0
  {
2645
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2646
0
    JSAutoRealm ar(cx, conversionScope);
2647
0
    do { // block we break out of when done wrapping
2648
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2649
0
        return false;
2650
0
      }
2651
0
      break;
2652
0
    } while (false);
2653
0
  }
2654
0
  { // And now store things in the realm of our slotStorage.
2655
0
    JSAutoRealm ar(cx, slotStorage);
2656
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2657
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2658
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2659
0
      return false;
2660
0
    }
2661
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2662
0
    if (!isXray) {
2663
0
      // In the Xray case we don't need to do this, because getting the
2664
0
      // expando object already preserved our wrapper.
2665
0
      PreserveWrapper(self);
2666
0
    }
2667
0
  }
2668
0
  // And now make sure args.rval() is in the caller realm.
2669
0
  if (MaybeWrapValue(cx, args.rval())) {
2670
0
    return true;
2671
0
  }
2672
0
  return false;
2673
0
}
2674
2675
static const JSJitInfo product_getterinfo = {
2676
  { (JSJitGetterOp)get_product },
2677
  { prototypes::id::Navigator },
2678
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2679
  JSJitInfo::Getter,
2680
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2681
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2682
  false,  /* isInfallible. False in setters. */
2683
  true,  /* isMovable.  Not relevant for setters. */
2684
  true, /* isEliminatable.  Not relevant for setters. */
2685
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2686
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2687
  false,  /* isTypedMethod.  Only relevant for methods. */
2688
  (DOM_INSTANCE_RESERVED_SLOTS + 11)   /* Reserved slot index, if we're stored in a slot, else 0. */
2689
};
2690
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 11) <= JSJitInfo::maxSlotIndex, "We won't fit");
2691
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 11) < 15, "There is no slot for us");
2692
2693
MOZ_CAN_RUN_SCRIPT static bool
2694
taintEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, const JSJitMethodCallArgs& args)
2695
0
{
2696
0
  AUTO_PROFILER_LABEL_FAST("Navigator.taintEnabled", DOM, cx);
2697
0
2698
0
  bool result(self->TaintEnabled());
2699
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2700
0
  args.rval().setBoolean(result);
2701
0
  return true;
2702
0
}
2703
2704
static const JSJitInfo taintEnabled_methodinfo = {
2705
  { (JSJitGetterOp)taintEnabled },
2706
  { prototypes::id::Navigator },
2707
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2708
  JSJitInfo::Method,
2709
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2710
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
2711
  true,  /* isInfallible. False in setters. */
2712
  false,  /* isMovable.  Not relevant for setters. */
2713
  false, /* isEliminatable.  Not relevant for setters. */
2714
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2715
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2716
  false,  /* isTypedMethod.  Only relevant for methods. */
2717
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2718
};
2719
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2720
static_assert(0 < 15, "There is no slot for us");
2721
2722
MOZ_CAN_RUN_SCRIPT static bool
2723
get_language(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2724
0
{
2725
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.language", DOM, cx);
2726
0
2727
0
  // Have to either root across the getter call or reget after.
2728
0
  bool isXray;
2729
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2730
0
  if (!slotStorage) {
2731
0
    return false;
2732
0
  }
2733
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 12) : (DOM_INSTANCE_RESERVED_SLOTS + 12);
2734
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2735
0
  {
2736
0
    // Scope for cachedVal
2737
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2738
0
    if (!cachedVal.isUndefined()) {
2739
0
      args.rval().set(cachedVal);
2740
0
      // The cached value is in the compartment of slotStorage,
2741
0
      // so wrap into the caller compartment as needed.
2742
0
      if (MaybeWrapValue(cx, args.rval())) {
2743
0
        return true;
2744
0
      }
2745
0
      return false;
2746
0
    }
2747
0
  }
2748
0
2749
0
  DOMString result;
2750
0
  self->GetLanguage(result);
2751
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2752
0
  {
2753
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2754
0
    JSAutoRealm ar(cx, conversionScope);
2755
0
    do { // block we break out of when done wrapping
2756
0
      if (!xpc::StringToJsval(cx, result, args.rval())) {
2757
0
        return false;
2758
0
      }
2759
0
      break;
2760
0
    } while (false);
2761
0
  }
2762
0
  { // And now store things in the realm of our slotStorage.
2763
0
    JSAutoRealm ar(cx, slotStorage);
2764
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2765
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2766
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2767
0
      return false;
2768
0
    }
2769
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2770
0
    if (!isXray) {
2771
0
      // In the Xray case we don't need to do this, because getting the
2772
0
      // expando object already preserved our wrapper.
2773
0
      PreserveWrapper(self);
2774
0
    }
2775
0
  }
2776
0
  // And now make sure args.rval() is in the caller realm.
2777
0
  if (MaybeWrapValue(cx, args.rval())) {
2778
0
    return true;
2779
0
  }
2780
0
  return false;
2781
0
}
2782
2783
static const JSJitInfo language_getterinfo = {
2784
  { (JSJitGetterOp)get_language },
2785
  { prototypes::id::Navigator },
2786
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2787
  JSJitInfo::Getter,
2788
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2789
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2790
  false,  /* isInfallible. False in setters. */
2791
  true,  /* isMovable.  Not relevant for setters. */
2792
  true, /* isEliminatable.  Not relevant for setters. */
2793
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2794
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2795
  false,  /* isTypedMethod.  Only relevant for methods. */
2796
  (DOM_INSTANCE_RESERVED_SLOTS + 12)   /* Reserved slot index, if we're stored in a slot, else 0. */
2797
};
2798
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 12) <= JSJitInfo::maxSlotIndex, "We won't fit");
2799
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 12) < 15, "There is no slot for us");
2800
2801
MOZ_CAN_RUN_SCRIPT static bool
2802
get_languages(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2803
0
{
2804
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.languages", DOM, cx);
2805
0
2806
0
  // Have to either root across the getter call or reget after.
2807
0
  bool isXray;
2808
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
2809
0
  if (!slotStorage) {
2810
0
    return false;
2811
0
  }
2812
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 13) : (DOM_INSTANCE_RESERVED_SLOTS + 13);
2813
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2814
0
  {
2815
0
    // Scope for cachedVal
2816
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2817
0
    if (!cachedVal.isUndefined()) {
2818
0
      args.rval().set(cachedVal);
2819
0
      // The cached value is in the compartment of slotStorage,
2820
0
      // so wrap into the caller compartment as needed.
2821
0
      if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
2822
0
        return true;
2823
0
      }
2824
0
      return false;
2825
0
    }
2826
0
  }
2827
0
2828
0
  nsTArray<nsString> result;
2829
0
  self->GetLanguages(result);
2830
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2831
0
  {
2832
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2833
0
    JSAutoRealm ar(cx, conversionScope);
2834
0
    do { // block we break out of when done wrapping
2835
0
2836
0
      uint32_t length = result.Length();
2837
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
2838
0
      if (!returnArray) {
2839
0
        return false;
2840
0
      }
2841
0
      // Scope for 'tmp'
2842
0
      {
2843
0
        JS::Rooted<JS::Value> tmp(cx);
2844
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2845
0
          // Control block to let us common up the JS_DefineElement calls when there
2846
0
          // are different ways to succeed at wrapping the object.
2847
0
          do {
2848
0
            if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
2849
0
              return false;
2850
0
            }
2851
0
            break;
2852
0
          } while (false);
2853
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2854
0
                                JSPROP_ENUMERATE)) {
2855
0
            return false;
2856
0
          }
2857
0
        }
2858
0
      }
2859
0
      args.rval().setObject(*returnArray);
2860
0
      break;
2861
0
    } while (false);
2862
0
    JS::Rooted<JSObject*> rvalObj(cx, &args.rval().toObject());
2863
0
    if (!JS_FreezeObject(cx, rvalObj)) {
2864
0
      return false;
2865
0
    }
2866
0
  }
2867
0
  { // And now store things in the realm of our slotStorage.
2868
0
    JSAutoRealm ar(cx, slotStorage);
2869
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2870
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2871
0
    if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
2872
0
      return false;
2873
0
    }
2874
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2875
0
    if (!isXray) {
2876
0
      // In the Xray case we don't need to do this, because getting the
2877
0
      // expando object already preserved our wrapper.
2878
0
      PreserveWrapper(self);
2879
0
    }
2880
0
  }
2881
0
  // And now make sure args.rval() is in the caller realm.
2882
0
  if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
2883
0
    return true;
2884
0
  }
2885
0
  return false;
2886
0
}
2887
2888
static const JSJitInfo languages_getterinfo = {
2889
  { (JSJitGetterOp)get_languages },
2890
  { prototypes::id::Navigator },
2891
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2892
  JSJitInfo::Getter,
2893
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2894
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2895
  false,  /* isInfallible. False in setters. */
2896
  true,  /* isMovable.  Not relevant for setters. */
2897
  true, /* isEliminatable.  Not relevant for setters. */
2898
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2899
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2900
  false,  /* isTypedMethod.  Only relevant for methods. */
2901
  (DOM_INSTANCE_RESERVED_SLOTS + 13)   /* Reserved slot index, if we're stored in a slot, else 0. */
2902
};
2903
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 13) <= JSJitInfo::maxSlotIndex, "We won't fit");
2904
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 13) < 15, "There is no slot for us");
2905
2906
MOZ_CAN_RUN_SCRIPT static bool
2907
get_onLine(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2908
0
{
2909
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.onLine", DOM, cx);
2910
0
2911
0
  bool result(self->OnLine());
2912
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2913
0
  args.rval().setBoolean(result);
2914
0
  return true;
2915
0
}
2916
2917
static const JSJitInfo onLine_getterinfo = {
2918
  { (JSJitGetterOp)get_onLine },
2919
  { prototypes::id::Navigator },
2920
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2921
  JSJitInfo::Getter,
2922
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2923
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
2924
  true,  /* isInfallible. False in setters. */
2925
  false,  /* isMovable.  Not relevant for setters. */
2926
  false, /* isEliminatable.  Not relevant for setters. */
2927
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2928
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2929
  false,  /* isTypedMethod.  Only relevant for methods. */
2930
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2931
};
2932
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2933
static_assert(0 < 15, "There is no slot for us");
2934
2935
MOZ_CAN_RUN_SCRIPT static bool
2936
get_storage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Navigator* self, JSJitGetterCallArgs args)
2937
0
{
2938
0
  AUTO_PROFILER_LABEL_FAST("get Navigator.storage", DOM, cx);
2939
0
2940
0
  auto result(StrongOrRawPtr<mozilla::dom::StorageManager>(self->Storage()));
2941
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2942
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
2943
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
2944
0
    return false;
2945
0
  }
2946
0
  return true;
2947
0
}
2948
2949
static const JSJitInfo storage_getterinfo = {
2950
  { (JSJitGetterOp)get_storage },
2951
  { prototypes::id::Navigator },
2952
  { PrototypeTraits<prototypes::id::Navigator>::Depth },
2953
  JSJitInfo::Getter,
2954
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2955
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2956
  false,  /* isInfallible. False in setters. */
2957
  false,  /* isMovable.  Not relevant for setters. */
2958
  false, /* isEliminatable.  Not relevant for setters. */
2959
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2960
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2961
  false,  /* isTypedMethod.  Only relevant for methods. */
2962
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2963
};
2964
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2965
static_assert(0 < 15, "There is no slot for us");
2966
2967
static bool
2968
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
2969
0
{
2970
0
  mozilla::dom::Navigator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Navigator>(obj);
2971
0
  // We don't want to preserve if we don't have a wrapper, and we
2972
0
  // obviously can't preserve if we're not initialized.
2973
0
  if (self && self->GetWrapperPreserveColor()) {
2974
0
    PreserveWrapper(self);
2975
0
  }
2976
0
  return true;
2977
0
}
2978
2979
static void
2980
_finalize(js::FreeOp* fop, JSObject* obj)
2981
0
{
2982
0
  mozilla::dom::Navigator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Navigator>(obj);
2983
0
  if (self) {
2984
0
    ClearWrapper(self, self, obj);
2985
0
    AddForDeferredFinalization<mozilla::dom::Navigator>(self);
2986
0
  }
2987
0
}
2988
2989
static size_t
2990
_objectMoved(JSObject* obj, JSObject* old)
2991
0
{
2992
0
  mozilla::dom::Navigator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Navigator>(obj);
2993
0
  if (self) {
2994
0
    UpdateWrapper(self, self, obj, old);
2995
0
  }
2996
0
2997
0
  return 0;
2998
0
}
2999
3000
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3001
#if defined(__clang__)
3002
#pragma clang diagnostic push
3003
#pragma clang diagnostic ignored "-Wmissing-braces"
3004
#endif
3005
static const JSFunctionSpec sMethods_specs[] = {
3006
  JS_FNSPEC("vibrate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vibrate_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3007
  JS_FNSPEC("javaEnabled", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&javaEnabled_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3008
  JS_FS_END,
3009
  JS_FNSPEC("getGamepads", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getGamepads_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3010
  JS_FS_END,
3011
  JS_FNSPEC("requestGamepadServiceTest", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&requestGamepadServiceTest_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3012
  JS_FS_END,
3013
  JS_FNSPEC("getVRDisplays", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&getVRDisplays_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3014
  JS_FS_END,
3015
  JS_FNSPEC("requestVRServiceTest", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&requestVRServiceTest_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3016
  JS_FS_END,
3017
  JS_FNSPEC("requestMIDIAccess", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&requestMIDIAccess_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3018
  JS_FS_END,
3019
  JS_FNSPEC("mozGetUserMedia", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&mozGetUserMedia_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
3020
  JS_FS_END,
3021
  JS_FNSPEC("sendBeacon", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&sendBeacon_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3022
  JS_FS_END,
3023
  JS_FNSPEC("requestMediaKeySystemAccess", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&requestMediaKeySystemAccess_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
3024
  JS_FS_END,
3025
  JS_FNSPEC("registerProtocolHandler", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&registerProtocolHandler_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
3026
  JS_FS_END,
3027
  JS_FNSPEC("registerContentHandler", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&registerContentHandler_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
3028
  JS_FS_END,
3029
  JS_FNSPEC("taintEnabled", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&taintEnabled_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3030
  JS_FS_END
3031
};
3032
#if defined(__clang__)
3033
#pragma clang diagnostic pop
3034
#endif
3035
3036
// Can't be const because the pref-enabled boolean needs to be writable
3037
static PrefableDisablers sMethods_disablers3 = {
3038
  true, false, 0, nullptr
3039
};
3040
3041
// Can't be const because the pref-enabled boolean needs to be writable
3042
static PrefableDisablers sMethods_disablers5 = {
3043
  true, false, 0, nullptr
3044
};
3045
3046
// Can't be const because the pref-enabled boolean needs to be writable
3047
static PrefableDisablers sMethods_disablers7 = {
3048
  true, false, 0, nullptr
3049
};
3050
3051
// Can't be const because the pref-enabled boolean needs to be writable
3052
static PrefableDisablers sMethods_disablers9 = {
3053
  true, false, 0, nullptr
3054
};
3055
3056
// Can't be const because the pref-enabled boolean needs to be writable
3057
static PrefableDisablers sMethods_disablers11 = {
3058
  true, false, 0, nullptr
3059
};
3060
3061
// Can't be const because the pref-enabled boolean needs to be writable
3062
static PrefableDisablers sMethods_disablers13 = {
3063
  true, false, 0, &Navigator::HasUserMediaSupport
3064
};
3065
3066
// Can't be const because the pref-enabled boolean needs to be writable
3067
static PrefableDisablers sMethods_disablers15 = {
3068
  true, false, 0, nullptr
3069
};
3070
3071
// Can't be const because the pref-enabled boolean needs to be writable
3072
static PrefableDisablers sMethods_disablers19 = {
3073
  true, false, 0, &nsGlobalWindowInner::RegisterProtocolHandlerAllowedForContext
3074
};
3075
3076
// Can't be const because the pref-enabled boolean needs to be writable
3077
static PrefableDisablers sMethods_disablers21 = {
3078
  true, false, 0, nullptr
3079
};
3080
3081
static const Prefable<const JSFunctionSpec> sMethods[] = {
3082
  { nullptr, &sMethods_specs[0] },
3083
  { &sMethods_disablers3, &sMethods_specs[3] },
3084
  { &sMethods_disablers5, &sMethods_specs[5] },
3085
  { &sMethods_disablers7, &sMethods_specs[7] },
3086
  { &sMethods_disablers9, &sMethods_specs[9] },
3087
  { &sMethods_disablers11, &sMethods_specs[11] },
3088
  { &sMethods_disablers13, &sMethods_specs[13] },
3089
  { &sMethods_disablers15, &sMethods_specs[15] },
3090
  { nullptr, &sMethods_specs[17] },
3091
  { &sMethods_disablers19, &sMethods_specs[19] },
3092
  { &sMethods_disablers21, &sMethods_specs[21] },
3093
  { nullptr, &sMethods_specs[23] },
3094
  { nullptr, nullptr }
3095
};
3096
3097
static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3098
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3099
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3100
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3101
3102
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3103
#if defined(__clang__)
3104
#pragma clang diagnostic push
3105
#pragma clang diagnostic ignored "-Wmissing-braces"
3106
#endif
3107
static const JSFunctionSpec sChromeMethods_specs[] = {
3108
  JS_FNSPEC("getBattery", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&getBattery_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3109
  JS_FS_END,
3110
  JS_FNSPEC("setVibrationPermission", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setVibrationPermission_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3111
  JS_FNSPEC("addIdleObserver", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addIdleObserver_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3112
  JS_FNSPEC("removeIdleObserver", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeIdleObserver_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3113
  JS_FS_END,
3114
  JS_FNSPEC("requestVRPresentation", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&requestVRPresentation_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3115
  JS_FS_END,
3116
  JS_FNSPEC("mozGetUserMediaDevices", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&mozGetUserMediaDevices_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
3117
  JS_FS_END
3118
};
3119
#if defined(__clang__)
3120
#pragma clang diagnostic pop
3121
#endif
3122
3123
// Can't be const because the pref-enabled boolean needs to be writable
3124
static PrefableDisablers sChromeMethods_disablers0 = {
3125
  true, false, 0, nullptr
3126
};
3127
3128
// Can't be const because the pref-enabled boolean needs to be writable
3129
static PrefableDisablers sChromeMethods_disablers6 = {
3130
  true, false, 0, nullptr
3131
};
3132
3133
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
3134
  { &sChromeMethods_disablers0, &sChromeMethods_specs[0] },
3135
  { nullptr, &sChromeMethods_specs[2] },
3136
  { &sChromeMethods_disablers6, &sChromeMethods_specs[6] },
3137
  { nullptr, &sChromeMethods_specs[8] },
3138
  { nullptr, nullptr }
3139
};
3140
3141
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3142
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3143
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3144
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3145
3146
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3147
#if defined(__clang__)
3148
#pragma clang diagnostic push
3149
#pragma clang diagnostic ignored "-Wmissing-braces"
3150
#endif
3151
static const JSPropertySpec sAttributes_specs[] = {
3152
  { "permissions", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &permissions_getterinfo, nullptr, nullptr },
3153
  { "mimeTypes", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mimeTypes_getterinfo, nullptr, nullptr },
3154
  { "plugins", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &plugins_getterinfo, nullptr, nullptr },
3155
  { "doNotTrack", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &doNotTrack_getterinfo, nullptr, nullptr },
3156
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3157
  { "maxTouchPoints", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &maxTouchPoints_getterinfo, nullptr, nullptr },
3158
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3159
  { "mediaCapabilities", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mediaCapabilities_getterinfo, nullptr, nullptr },
3160
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3161
  { "oscpu", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &oscpu_getterinfo, nullptr, nullptr },
3162
  { "vendor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &vendor_getterinfo, nullptr, nullptr },
3163
  { "vendorSub", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &vendorSub_getterinfo, nullptr, nullptr },
3164
  { "productSub", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &productSub_getterinfo, nullptr, nullptr },
3165
  { "cookieEnabled", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &cookieEnabled_getterinfo, nullptr, nullptr },
3166
  { "buildID", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &buildID_getterinfo, nullptr, nullptr },
3167
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3168
  { "connection", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &connection_getterinfo, nullptr, nullptr },
3169
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3170
  { "activeVRDisplays", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &activeVRDisplays_getterinfo, nullptr, nullptr },
3171
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3172
  { "mediaDevices", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mediaDevices_getterinfo, nullptr, nullptr },
3173
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3174
  { "serviceWorker", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &serviceWorker_getterinfo, nullptr, nullptr },
3175
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3176
  { "presentation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &presentation_getterinfo, nullptr, nullptr },
3177
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3178
  { "mozTCPSocket", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozTCPSocket_getterinfo, nullptr, nullptr },
3179
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3180
  { "credentials", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &credentials_getterinfo, nullptr, nullptr },
3181
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3182
  { "clipboard", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clipboard_getterinfo, nullptr, nullptr },
3183
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3184
  { "mozAddonManager", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozAddonManager_getterinfo, nullptr, nullptr },
3185
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3186
  { "webdriver", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &webdriver_getterinfo, nullptr, nullptr },
3187
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3188
  { "hardwareConcurrency", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hardwareConcurrency_getterinfo, nullptr, nullptr },
3189
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3190
  { "geolocation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &geolocation_getterinfo, nullptr, nullptr },
3191
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3192
  { "appCodeName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &appCodeName_getterinfo, nullptr, nullptr },
3193
  { "appName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &appName_getterinfo, nullptr, nullptr },
3194
  { "appVersion", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &appVersion_getterinfo, nullptr, nullptr },
3195
  { "platform", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &platform_getterinfo, nullptr, nullptr },
3196
  { "userAgent", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &userAgent_getterinfo, nullptr, nullptr },
3197
  { "product", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &product_getterinfo, nullptr, nullptr },
3198
  { "language", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &language_getterinfo, nullptr, nullptr },
3199
  { "languages", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &languages_getterinfo, nullptr, nullptr },
3200
  { "onLine", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onLine_getterinfo, nullptr, nullptr },
3201
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
3202
  { "storage", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &storage_getterinfo, nullptr, nullptr },
3203
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
3204
};
3205
#if defined(__clang__)
3206
#pragma clang diagnostic pop
3207
#endif
3208
3209
// Can't be const because the pref-enabled boolean needs to be writable
3210
static PrefableDisablers sAttributes_disablers5 = {
3211
  true, false, 0, nullptr
3212
};
3213
3214
// Can't be const because the pref-enabled boolean needs to be writable
3215
static PrefableDisablers sAttributes_disablers7 = {
3216
  true, false, 0, &mozilla::dom::MediaCapabilities::Enabled
3217
};
3218
3219
// Can't be const because the pref-enabled boolean needs to be writable
3220
static PrefableDisablers sAttributes_disablers16 = {
3221
  true, false, 0, nullptr
3222
};
3223
3224
// Can't be const because the pref-enabled boolean needs to be writable
3225
static PrefableDisablers sAttributes_disablers18 = {
3226
  true, false, 0, nullptr
3227
};
3228
3229
// Can't be const because the pref-enabled boolean needs to be writable
3230
static PrefableDisablers sAttributes_disablers20 = {
3231
  true, false, 0, &Navigator::HasUserMediaSupport
3232
};
3233
3234
// Can't be const because the pref-enabled boolean needs to be writable
3235
static PrefableDisablers sAttributes_disablers22 = {
3236
  true, false, 0, &ServiceWorkerContainer::IsEnabled
3237
};
3238
3239
// Can't be const because the pref-enabled boolean needs to be writable
3240
static PrefableDisablers sAttributes_disablers24 = {
3241
  true, false, 0, nullptr
3242
};
3243
3244
// Can't be const because the pref-enabled boolean needs to be writable
3245
static PrefableDisablers sAttributes_disablers26 = {
3246
  true, false, 0, &mozilla::dom::TCPSocket::ShouldTCPSocketExist
3247
};
3248
3249
// Can't be const because the pref-enabled boolean needs to be writable
3250
static PrefableDisablers sAttributes_disablers28 = {
3251
  true, true, 0, nullptr
3252
};
3253
3254
// Can't be const because the pref-enabled boolean needs to be writable
3255
static PrefableDisablers sAttributes_disablers30 = {
3256
  true, true, 0, nullptr
3257
};
3258
3259
// Can't be const because the pref-enabled boolean needs to be writable
3260
static PrefableDisablers sAttributes_disablers32 = {
3261
  true, false, 0, &mozilla::AddonManagerWebAPI::IsAPIEnabled
3262
};
3263
3264
// Can't be const because the pref-enabled boolean needs to be writable
3265
static PrefableDisablers sAttributes_disablers34 = {
3266
  true, false, 0, nullptr
3267
};
3268
3269
// Can't be const because the pref-enabled boolean needs to be writable
3270
static PrefableDisablers sAttributes_disablers38 = {
3271
  true, false, 0, nullptr
3272
};
3273
3274
// Can't be const because the pref-enabled boolean needs to be writable
3275
static PrefableDisablers sAttributes_disablers50 = {
3276
  true, true, 0, &mozilla::dom::DOMPrefs::dom_storageManager_enabled
3277
};
3278
3279
static const Prefable<const JSPropertySpec> sAttributes[] = {
3280
  { nullptr, &sAttributes_specs[0] },
3281
  { &sAttributes_disablers5, &sAttributes_specs[5] },
3282
  { &sAttributes_disablers7, &sAttributes_specs[7] },
3283
  { nullptr, &sAttributes_specs[9] },
3284
  { &sAttributes_disablers16, &sAttributes_specs[16] },
3285
  { &sAttributes_disablers18, &sAttributes_specs[18] },
3286
  { &sAttributes_disablers20, &sAttributes_specs[20] },
3287
  { &sAttributes_disablers22, &sAttributes_specs[22] },
3288
  { &sAttributes_disablers24, &sAttributes_specs[24] },
3289
  { &sAttributes_disablers26, &sAttributes_specs[26] },
3290
  { &sAttributes_disablers28, &sAttributes_specs[28] },
3291
  { &sAttributes_disablers30, &sAttributes_specs[30] },
3292
  { &sAttributes_disablers32, &sAttributes_specs[32] },
3293
  { &sAttributes_disablers34, &sAttributes_specs[34] },
3294
  { nullptr, &sAttributes_specs[36] },
3295
  { &sAttributes_disablers38, &sAttributes_specs[38] },
3296
  { nullptr, &sAttributes_specs[40] },
3297
  { &sAttributes_disablers50, &sAttributes_specs[50] },
3298
  { nullptr, nullptr }
3299
};
3300
3301
static_assert(18 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3302
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3303
static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3304
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3305
3306
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3307
#if defined(__clang__)
3308
#pragma clang diagnostic push
3309
#pragma clang diagnostic ignored "-Wmissing-braces"
3310
#endif
3311
static const JSPropertySpec sChromeAttributes_specs[] = {
3312
  { "isWebVRContentDetected", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isWebVRContentDetected_getterinfo, nullptr, nullptr },
3313
  { "isWebVRContentPresenting", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isWebVRContentPresenting_getterinfo, nullptr, nullptr },
3314
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
3315
};
3316
#if defined(__clang__)
3317
#pragma clang diagnostic pop
3318
#endif
3319
3320
// Can't be const because the pref-enabled boolean needs to be writable
3321
static PrefableDisablers sChromeAttributes_disablers0 = {
3322
  true, false, 0, nullptr
3323
};
3324
3325
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
3326
  { &sChromeAttributes_disablers0, &sChromeAttributes_specs[0] },
3327
  { nullptr, nullptr }
3328
};
3329
3330
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3331
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3332
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3333
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3334
3335
3336
static uint16_t sNativeProperties_sortedPropertyIndices[47];
3337
static PropertyInfo sNativeProperties_propertyInfos[47];
3338
3339
static const NativePropertiesN<2> sNativeProperties = {
3340
  false, 0,
3341
  false, 0,
3342
  true,  0 /* sMethods */,
3343
  true,  1 /* sAttributes */,
3344
  false, 0,
3345
  false, 0,
3346
  false, 0,
3347
  -1,
3348
  47,
3349
  sNativeProperties_sortedPropertyIndices,
3350
  {
3351
    { sMethods, &sNativeProperties_propertyInfos[0] },
3352
    { sAttributes, &sNativeProperties_propertyInfos[13] }
3353
  }
3354
};
3355
static_assert(47 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
3356
    "We have a property info count that is oversized");
3357
3358
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[8];
3359
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[8];
3360
3361
static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
3362
  false, 0,
3363
  false, 0,
3364
  true,  0 /* sChromeMethods */,
3365
  true,  1 /* sChromeAttributes */,
3366
  false, 0,
3367
  false, 0,
3368
  false, 0,
3369
  -1,
3370
  8,
3371
  sChromeOnlyNativeProperties_sortedPropertyIndices,
3372
  {
3373
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
3374
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[6] }
3375
  }
3376
};
3377
static_assert(8 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
3378
    "We have a property info count that is oversized");
3379
3380
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
3381
  {
3382
    "Function",
3383
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
3384
    &sBoringInterfaceObjectClassClassOps,
3385
    JS_NULL_CLASS_SPEC,
3386
    JS_NULL_CLASS_EXT,
3387
    &sInterfaceObjectClassObjectOps
3388
  },
3389
  eInterface,
3390
  true,
3391
  prototypes::id::Navigator,
3392
  PrototypeTraits<prototypes::id::Navigator>::Depth,
3393
  sNativePropertyHooks,
3394
  "function Navigator() {\n    [native code]\n}",
3395
  JS::GetRealmFunctionPrototype
3396
};
3397
3398
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
3399
  {
3400
    "NavigatorPrototype",
3401
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
3402
    JS_NULL_CLASS_OPS,
3403
    JS_NULL_CLASS_SPEC,
3404
    JS_NULL_CLASS_EXT,
3405
    JS_NULL_OBJECT_OPS
3406
  },
3407
  eInterfacePrototype,
3408
  false,
3409
  prototypes::id::Navigator,
3410
  PrototypeTraits<prototypes::id::Navigator>::Depth,
3411
  sNativePropertyHooks,
3412
  "[object NavigatorPrototype]",
3413
  JS::GetRealmObjectPrototype
3414
};
3415
3416
static const js::ClassOps sClassOps = {
3417
  _addProperty, /* addProperty */
3418
  nullptr,               /* delProperty */
3419
  nullptr,               /* enumerate */
3420
  nullptr, /* newEnumerate */
3421
  nullptr, /* resolve */
3422
  nullptr, /* mayResolve */
3423
  _finalize, /* finalize */
3424
  nullptr, /* call */
3425
  nullptr,               /* hasInstance */
3426
  nullptr,               /* construct */
3427
  nullptr, /* trace */
3428
};
3429
3430
static const js::ClassExtension sClassExtension = {
3431
  nullptr, /* weakmapKeyDelegateOp */
3432
  _objectMoved /* objectMovedOp */
3433
};
3434
3435
static const DOMJSClass sClass = {
3436
  { "Navigator",
3437
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(15),
3438
    &sClassOps,
3439
    JS_NULL_CLASS_SPEC,
3440
    &sClassExtension,
3441
    JS_NULL_OBJECT_OPS
3442
  },
3443
  { prototypes::id::Navigator, 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 },
3444
  IsBaseOf<nsISupports, mozilla::dom::Navigator >::value,
3445
  sNativePropertyHooks,
3446
  FindAssociatedGlobalForNative<mozilla::dom::Navigator>::Get,
3447
  GetProtoObjectHandle,
3448
  GetCCParticipant<mozilla::dom::Navigator>::Get()
3449
};
3450
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
3451
              "Must have the right minimal number of reserved slots.");
3452
static_assert(15 >= 15,
3453
              "Must have enough reserved slots.");
3454
3455
const JSClass*
3456
GetJSClass()
3457
0
{
3458
0
  return sClass.ToJSClass();
3459
0
}
3460
3461
bool
3462
Wrap(JSContext* aCx, mozilla::dom::Navigator* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
3463
0
{
3464
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::Navigator>::value,
3465
0
                "Shouldn't have wrappercached things that are not refcounted.");
3466
0
  MOZ_ASSERT(static_cast<mozilla::dom::Navigator*>(aObject) ==
3467
0
             reinterpret_cast<mozilla::dom::Navigator*>(aObject),
3468
0
             "Multiple inheritance for mozilla::dom::Navigator is broken.");
3469
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
3470
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
3471
0
  MOZ_ASSERT(!aCache->GetWrapper(),
3472
0
             "You should probably not be using Wrap() directly; use "
3473
0
             "GetOrCreateDOMReflector instead");
3474
0
3475
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
3476
0
             "nsISupports must be on our primary inheritance chain");
3477
0
3478
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
3479
0
  if (!global) {
3480
0
    return false;
3481
0
  }
3482
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
3483
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
3484
0
3485
0
  // That might have ended up wrapping us already, due to the wonders
3486
0
  // of XBL.  Check for that, and bail out as needed.
3487
0
  aReflector.set(aCache->GetWrapper());
3488
0
  if (aReflector) {
3489
#ifdef DEBUG
3490
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
3491
#endif // DEBUG
3492
    return true;
3493
0
  }
3494
0
3495
0
  JSAutoRealm ar(aCx, global);
3496
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
3497
0
  if (!canonicalProto) {
3498
0
    return false;
3499
0
  }
3500
0
  JS::Rooted<JSObject*> proto(aCx);
3501
0
  if (aGivenProto) {
3502
0
    proto = aGivenProto;
3503
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
3504
0
    // coming in, we changed compartments to that of "parent" so may need
3505
0
    // to wrap the proto here.
3506
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
3507
0
      if (!JS_WrapObject(aCx, &proto)) {
3508
0
        return false;
3509
0
      }
3510
0
    }
3511
0
  } else {
3512
0
    proto = canonicalProto;
3513
0
  }
3514
0
3515
0
  BindingJSObjectCreator<mozilla::dom::Navigator> creator(aCx);
3516
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
3517
0
  if (!aReflector) {
3518
0
    return false;
3519
0
  }
3520
0
3521
0
  aCache->SetWrapper(aReflector);
3522
0
  creator.InitializationSucceeded();
3523
0
3524
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
3525
0
             aCache->GetWrapperPreserveColor() == aReflector);
3526
0
  // If proto != canonicalProto, we have to preserve our wrapper;
3527
0
  // otherwise we won't be able to properly recreate it later, since
3528
0
  // we won't know what proto to use.  Note that we don't check
3529
0
  // aGivenProto here, since it's entirely possible (and even
3530
0
  // somewhat common) to have a non-null aGivenProto which is the
3531
0
  // same as canonicalProto.
3532
0
  if (proto != canonicalProto) {
3533
0
    PreserveWrapper(aObject);
3534
0
  }
3535
0
3536
0
  return true;
3537
0
}
3538
3539
// This may allocate too many slots, because we only really need
3540
// slots for our non-interface-typed members that we cache.  But
3541
// allocating slots only for those would make the slot index
3542
// computations much more complicated, so let's do this the simple
3543
// way for now.
3544
DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 14);
3545
3546
const NativePropertyHooks sNativePropertyHooks[] = { {
3547
  nullptr,
3548
  nullptr,
3549
  nullptr,
3550
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
3551
  prototypes::id::Navigator,
3552
  constructors::id::Navigator,
3553
  nullptr,
3554
  &sXrayExpandoObjectClass
3555
} };
3556
3557
void
3558
ClearCachedActiveVRDisplaysValue(mozilla::dom::Navigator* aObject)
3559
0
{
3560
0
  JSObject* obj;
3561
0
  obj = aObject->GetWrapper();
3562
0
  if (!obj) {
3563
0
    return;
3564
0
  }
3565
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 2), JS::UndefinedValue());
3566
0
  xpc::ClearXrayExpandoSlots(obj, (xpc::JSSLOT_EXPANDO_COUNT + 2));
3567
0
}
3568
3569
void
3570
ClearCachedUserAgentValue(mozilla::dom::Navigator* aObject)
3571
0
{
3572
0
  JSObject* obj;
3573
0
  obj = aObject->GetWrapper();
3574
0
  if (!obj) {
3575
0
    return;
3576
0
  }
3577
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 10), JS::UndefinedValue());
3578
0
  xpc::ClearXrayExpandoSlots(obj, (xpc::JSSLOT_EXPANDO_COUNT + 10));
3579
0
}
3580
3581
void
3582
ClearCachedLanguageValue(mozilla::dom::Navigator* aObject)
3583
0
{
3584
0
  JSObject* obj;
3585
0
  obj = aObject->GetWrapper();
3586
0
  if (!obj) {
3587
0
    return;
3588
0
  }
3589
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 12), JS::UndefinedValue());
3590
0
  xpc::ClearXrayExpandoSlots(obj, (xpc::JSSLOT_EXPANDO_COUNT + 12));
3591
0
}
3592
3593
void
3594
ClearCachedLanguagesValue(mozilla::dom::Navigator* aObject)
3595
0
{
3596
0
  JSObject* obj;
3597
0
  obj = aObject->GetWrapper();
3598
0
  if (!obj) {
3599
0
    return;
3600
0
  }
3601
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 13), JS::UndefinedValue());
3602
0
  xpc::ClearXrayExpandoSlots(obj, (xpc::JSSLOT_EXPANDO_COUNT + 13));
3603
0
}
3604
3605
void
3606
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
3607
0
{
3608
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
3609
0
  if (!parentProto) {
3610
0
    return;
3611
0
  }
3612
0
3613
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
3614
0
  if (!constructorProto) {
3615
0
    return;
3616
0
  }
3617
0
3618
0
  static bool sIdsInited = false;
3619
0
  if (!sIdsInited && NS_IsMainThread()) {
3620
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
3621
0
      return;
3622
0
    }
3623
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
3624
0
      return;
3625
0
    }
3626
0
    sIdsInited = true;
3627
0
  }
3628
0
3629
0
  static bool sPrefCachesInited = false;
3630
0
  if (!sPrefCachesInited && NS_IsMainThread()) {
3631
0
    sPrefCachesInited = true;
3632
0
    Preferences::AddBoolVarCache(&sMethods[1].disablers->enabled, "dom.gamepad.enabled");
3633
0
    Preferences::AddBoolVarCache(&sMethods[2].disablers->enabled, "dom.gamepad.test.enabled");
3634
0
    Preferences::AddBoolVarCache(&sMethods[3].disablers->enabled, "dom.vr.enabled");
3635
0
    Preferences::AddBoolVarCache(&sMethods[4].disablers->enabled, "dom.vr.test.enabled");
3636
0
    Preferences::AddBoolVarCache(&sMethods[5].disablers->enabled, "dom.webmidi.enabled");
3637
0
    Preferences::AddBoolVarCache(&sMethods[7].disablers->enabled, "beacon.enabled");
3638
0
    Preferences::AddBoolVarCache(&sMethods[10].disablers->enabled, "dom.registerContentHandler.enabled");
3639
0
    Preferences::AddBoolVarCache(&sChromeMethods[0].disablers->enabled, "dom.battery.enabled");
3640
0
    Preferences::AddBoolVarCache(&sChromeMethods[2].disablers->enabled, "dom.vr.enabled");
3641
0
    Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "dom.w3c_pointer_events.enabled");
3642
0
    Preferences::AddBoolVarCache(&sAttributes[4].disablers->enabled, "dom.netinfo.enabled");
3643
0
    Preferences::AddBoolVarCache(&sAttributes[5].disablers->enabled, "dom.vr.enabled");
3644
0
    Preferences::AddBoolVarCache(&sAttributes[8].disablers->enabled, "dom.presentation.enabled");
3645
0
    Preferences::AddBoolVarCache(&sAttributes[10].disablers->enabled, "security.webauth.webauthn");
3646
0
    Preferences::AddBoolVarCache(&sAttributes[11].disablers->enabled, "dom.events.asyncClipboard");
3647
0
    Preferences::AddBoolVarCache(&sAttributes[13].disablers->enabled, "dom.webdriver.enabled");
3648
0
    Preferences::AddBoolVarCache(&sAttributes[15].disablers->enabled, "geo.enabled");
3649
0
    Preferences::AddBoolVarCache(&sChromeAttributes[0].disablers->enabled, "dom.vr.enabled");
3650
0
  }
3651
0
3652
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Navigator);
3653
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Navigator);
3654
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
3655
0
                              &sPrototypeClass.mBase, protoCache,
3656
0
                              nullptr,
3657
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
3658
0
                              interfaceCache,
3659
0
                              sNativeProperties.Upcast(),
3660
0
                              sChromeOnlyNativeProperties.Upcast(),
3661
0
                              "Navigator", aDefineOnGlobal,
3662
0
                              nullptr,
3663
0
                              false);
3664
0
}
3665
3666
JSObject*
3667
GetConstructorObject(JSContext* aCx)
3668
0
{
3669
0
  return GetConstructorObjectHandle(aCx);
3670
0
}
3671
3672
} // namespace Navigator_Binding
3673
3674
3675
3676
void
3677
MozIdleObserver::Onidle(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
3678
0
{
3679
0
  CallSetup s(this, aRv, "MozIdleObserver.onidle", aExceptionHandling, aRealm);
3680
0
  JSContext* cx = s.GetContext();
3681
0
  if (!cx) {
3682
0
    MOZ_ASSERT(aRv.Failed());
3683
0
    return;
3684
0
  }
3685
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
3686
0
3687
0
  JS::Rooted<JS::Value> callable(cx);
3688
0
  MozIdleObserverAtoms* atomsCache = GetAtomCache<MozIdleObserverAtoms>(cx);
3689
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
3690
0
      !GetCallableProperty(cx, atomsCache->onidle_id, &callable)) {
3691
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
3692
0
    return;
3693
0
  }
3694
0
  JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
3695
0
  if (!JS::Call(cx, thisValue, callable,
3696
0
                JS::HandleValueArray::empty(), &rval)) {
3697
0
    aRv.NoteJSContextException(cx);
3698
0
    return;
3699
0
  }
3700
0
}
3701
3702
void
3703
MozIdleObserver::Onactive(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
3704
0
{
3705
0
  CallSetup s(this, aRv, "MozIdleObserver.onactive", aExceptionHandling, aRealm);
3706
0
  JSContext* cx = s.GetContext();
3707
0
  if (!cx) {
3708
0
    MOZ_ASSERT(aRv.Failed());
3709
0
    return;
3710
0
  }
3711
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
3712
0
3713
0
  JS::Rooted<JS::Value> callable(cx);
3714
0
  MozIdleObserverAtoms* atomsCache = GetAtomCache<MozIdleObserverAtoms>(cx);
3715
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
3716
0
      !GetCallableProperty(cx, atomsCache->onactive_id, &callable)) {
3717
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
3718
0
    return;
3719
0
  }
3720
0
  JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback));
3721
0
  if (!JS::Call(cx, thisValue, callable,
3722
0
                JS::HandleValueArray::empty(), &rval)) {
3723
0
    aRv.NoteJSContextException(cx);
3724
0
    return;
3725
0
  }
3726
0
}
3727
3728
bool
3729
MozIdleObserver::InitIds(JSContext* cx, MozIdleObserverAtoms* atomsCache)
3730
0
{
3731
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
3732
0
3733
0
  // Initialize these in reverse order so that any failure leaves the first one
3734
0
  // uninitialized.
3735
0
  if (!atomsCache->onactive_id.init(cx, "onactive") ||
3736
0
      !atomsCache->onidle_id.init(cx, "onidle") ||
3737
0
      !atomsCache->time_id.init(cx, "time")) {
3738
0
    return false;
3739
0
  }
3740
0
  return true;
3741
0
}
3742
3743
3744
uint32_t
3745
MozIdleObserver::GetTime(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
3746
0
{
3747
0
  CallSetup s(this, aRv, "MozIdleObserver.time", aExceptionHandling, aRealm);
3748
0
  JSContext* cx = s.GetContext();
3749
0
  if (!cx) {
3750
0
    MOZ_ASSERT(aRv.Failed());
3751
0
    return uint32_t(0);
3752
0
  }
3753
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
3754
0
3755
0
  JS::Rooted<JSObject *> callback(cx, mCallback);
3756
0
  MozIdleObserverAtoms* atomsCache = GetAtomCache<MozIdleObserverAtoms>(cx);
3757
0
  if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
3758
0
      !JS_GetPropertyById(cx, callback, atomsCache->time_id, &rval)) {
3759
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
3760
0
    return uint32_t(0);
3761
0
  }
3762
0
  uint32_t rvalDecl;
3763
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, rval, &rvalDecl)) {
3764
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
3765
0
    return uint32_t(0);
3766
0
  }
3767
0
  return rvalDecl;
3768
0
}
3769
3770
3771
namespace binding_detail {
3772
} // namespace binding_detail
3773
3774
3775
} // namespace dom
3776
} // namespace mozilla