Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/ConsoleBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Console.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "ConsoleBinding.h"
5
#include "WrapperFactory.h"
6
#include "jsapi.h"
7
#include "mozilla/FloatingPoint.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/UseCounter.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/Console.h"
12
#include "mozilla/dom/ConsoleInstance.h"
13
#include "mozilla/dom/DOMJSClass.h"
14
#include "mozilla/dom/NonRefcountedDOMObject.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/ScriptSettings.h"
17
#include "mozilla/dom/SimpleGlobalObject.h"
18
#include "mozilla/dom/UnionConversions.h"
19
#include "mozilla/dom/XrayExpandoClass.h"
20
#include "nsContentUtils.h"
21
22
namespace mozilla {
23
namespace dom {
24
25
namespace binding_detail {}; // Just to make sure it's known as a namespace
26
using namespace mozilla::dom::binding_detail;
27
28
29
namespace ConsoleLogLevelValues {
30
extern const EnumEntry strings[19] = {
31
  {"All", 3},
32
  {"Debug", 5},
33
  {"Log", 3},
34
  {"Info", 4},
35
  {"Clear", 5},
36
  {"Trace", 5},
37
  {"TimeLog", 7},
38
  {"TimeEnd", 7},
39
  {"Time", 4},
40
  {"Group", 5},
41
  {"GroupEnd", 8},
42
  {"Profile", 7},
43
  {"ProfileEnd", 10},
44
  {"Dir", 3},
45
  {"Dirxml", 6},
46
  {"Warn", 4},
47
  {"Error", 5},
48
  {"Off", 3},
49
  { nullptr, 0 }
50
};
51
} // namespace ConsoleLogLevelValues
52
53
bool
54
ToJSValue(JSContext* aCx, ConsoleLogLevel aArgument, JS::MutableHandle<JS::Value> aValue)
55
0
{
56
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ConsoleLogLevelValues::strings));
57
0
  JSString* resultStr =
58
0
    JS_NewStringCopyN(aCx, ConsoleLogLevelValues::strings[uint32_t(aArgument)].value,
59
0
                      ConsoleLogLevelValues::strings[uint32_t(aArgument)].length);
60
0
  if (!resultStr) {
61
0
    return false;
62
0
  }
63
0
  aValue.setString(resultStr);
64
0
  return true;
65
0
}
66
67
68
namespace ConsoleLevelValues {
69
extern const EnumEntry strings[4] = {
70
  {"log", 3},
71
  {"warning", 7},
72
  {"error", 5},
73
  { nullptr, 0 }
74
};
75
} // namespace ConsoleLevelValues
76
77
bool
78
ToJSValue(JSContext* aCx, ConsoleLevel aArgument, JS::MutableHandle<JS::Value> aValue)
79
0
{
80
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ConsoleLevelValues::strings));
81
0
  JSString* resultStr =
82
0
    JS_NewStringCopyN(aCx, ConsoleLevelValues::strings[uint32_t(aArgument)].value,
83
0
                      ConsoleLevelValues::strings[uint32_t(aArgument)].length);
84
0
  if (!resultStr) {
85
0
    return false;
86
0
  }
87
0
  aValue.setString(resultStr);
88
0
  return true;
89
0
}
90
91
92
93
ConsoleCounter::ConsoleCounter()
94
0
{
95
0
  // Safe to pass a null context if we pass a null value
96
0
  Init(nullptr, JS::NullHandleValue);
97
0
}
98
99
100
101
bool
102
ConsoleCounter::InitIds(JSContext* cx, ConsoleCounterAtoms* atomsCache)
103
0
{
104
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
105
0
106
0
  // Initialize these in reverse order so that any failure leaves the first one
107
0
  // uninitialized.
108
0
  if (!atomsCache->label_id.init(cx, "label") ||
109
0
      !atomsCache->count_id.init(cx, "count")) {
110
0
    return false;
111
0
  }
112
0
  return true;
113
0
}
114
115
bool
116
ConsoleCounter::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
117
0
{
118
0
  // Passing a null JSContext is OK only if we're initing from null,
119
0
  // Since in that case we will not have to do any property gets
120
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
121
0
  // checkers by static analysis tools
122
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
123
0
  ConsoleCounterAtoms* atomsCache = nullptr;
124
0
  if (cx) {
125
0
    atomsCache = GetAtomCache<ConsoleCounterAtoms>(cx);
126
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
127
0
      return false;
128
0
    }
129
0
  }
130
0
131
0
  if (!IsConvertibleToDictionary(val)) {
132
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
133
0
  }
134
0
135
0
  bool isNull = val.isNullOrUndefined();
136
0
  // We only need these if !isNull, in which case we have |cx|.
137
0
  Maybe<JS::Rooted<JSObject *> > object;
138
0
  Maybe<JS::Rooted<JS::Value> > temp;
139
0
  if (!isNull) {
140
0
    MOZ_ASSERT(cx);
141
0
    object.emplace(cx, &val.toObject());
142
0
    temp.emplace(cx);
143
0
  }
144
0
  if (!isNull) {
145
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->count_id, temp.ptr())) {
146
0
      return false;
147
0
    }
148
0
  }
149
0
  if (!isNull && !temp->isUndefined()) {
150
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mCount)) {
151
0
      return false;
152
0
    }
153
0
  } else {
154
0
    mCount = 0U;
155
0
  }
156
0
  mIsAnyMemberPresent = true;
157
0
158
0
  if (!isNull) {
159
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->label_id, temp.ptr())) {
160
0
      return false;
161
0
    }
162
0
  }
163
0
  if (!isNull && !temp->isUndefined()) {
164
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mLabel)) {
165
0
      return false;
166
0
    }
167
0
  } else {
168
0
    static const char16_t data[] = { 0 };
169
0
    mLabel.Rebind(data, ArrayLength(data) - 1);
170
0
  }
171
0
  mIsAnyMemberPresent = true;
172
0
  return true;
173
0
}
174
175
bool
176
ConsoleCounter::Init(const nsAString& aJSON)
177
0
{
178
0
  AutoJSAPI jsapi;
179
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
180
0
  if (!cleanGlobal) {
181
0
    return false;
182
0
  }
183
0
  if (!jsapi.Init(cleanGlobal)) {
184
0
    return false;
185
0
  }
186
0
  JSContext* cx = jsapi.cx();
187
0
  JS::Rooted<JS::Value> json(cx);
188
0
  bool ok = ParseJSON(cx, aJSON, &json);
189
0
  NS_ENSURE_TRUE(ok, false);
190
0
  return Init(cx, json);
191
0
}
192
193
bool
194
ConsoleCounter::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
195
0
{
196
0
  ConsoleCounterAtoms* atomsCache = GetAtomCache<ConsoleCounterAtoms>(cx);
197
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
198
0
    return false;
199
0
  }
200
0
201
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
202
0
  if (!obj) {
203
0
    return false;
204
0
  }
205
0
  rval.set(JS::ObjectValue(*obj));
206
0
207
0
  do {
208
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
209
0
    JS::Rooted<JS::Value> temp(cx);
210
0
    uint32_t const & currentValue = mCount;
211
0
    temp.setNumber(currentValue);
212
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->count_id, temp, JSPROP_ENUMERATE)) {
213
0
      return false;
214
0
    }
215
0
    break;
216
0
  } while(false);
217
0
218
0
  do {
219
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
220
0
    JS::Rooted<JS::Value> temp(cx);
221
0
    nsString const & currentValue = mLabel;
222
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
223
0
      return false;
224
0
    }
225
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->label_id, temp, JSPROP_ENUMERATE)) {
226
0
      return false;
227
0
    }
228
0
    break;
229
0
  } while(false);
230
0
231
0
  return true;
232
0
}
233
234
bool
235
ConsoleCounter::ToJSON(nsAString& aJSON) const
236
0
{
237
0
  AutoJSAPI jsapi;
238
0
  jsapi.Init();
239
0
  JSContext *cx = jsapi.cx();
240
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
241
0
  // because we'll only be creating objects, in ways that have no
242
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
243
0
  // which likewise guarantees no side-effects for the sorts of
244
0
  // things we will pass it.
245
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
246
0
  JS::Rooted<JS::Value> val(cx);
247
0
  if (!ToObjectInternal(cx, &val)) {
248
0
    return false;
249
0
  }
250
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
251
0
  return StringifyToJSON(cx, obj, aJSON);
252
0
}
253
254
void
255
ConsoleCounter::TraceDictionary(JSTracer* trc)
256
0
{
257
0
}
258
259
ConsoleCounter&
260
ConsoleCounter::operator=(const ConsoleCounter& aOther)
261
0
{
262
0
  DictionaryBase::operator=(aOther);
263
0
  mCount = aOther.mCount;
264
0
  mLabel = aOther.mLabel;
265
0
  return *this;
266
0
}
267
268
namespace binding_detail {
269
} // namespace binding_detail
270
271
272
273
ConsoleCounterError::ConsoleCounterError()
274
0
{
275
0
  // Safe to pass a null context if we pass a null value
276
0
  Init(nullptr, JS::NullHandleValue);
277
0
}
278
279
280
281
bool
282
ConsoleCounterError::InitIds(JSContext* cx, ConsoleCounterErrorAtoms* atomsCache)
283
0
{
284
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
285
0
286
0
  // Initialize these in reverse order so that any failure leaves the first one
287
0
  // uninitialized.
288
0
  if (!atomsCache->label_id.init(cx, "label") ||
289
0
      !atomsCache->error_id.init(cx, "error")) {
290
0
    return false;
291
0
  }
292
0
  return true;
293
0
}
294
295
bool
296
ConsoleCounterError::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
297
0
{
298
0
  // Passing a null JSContext is OK only if we're initing from null,
299
0
  // Since in that case we will not have to do any property gets
300
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
301
0
  // checkers by static analysis tools
302
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
303
0
  ConsoleCounterErrorAtoms* atomsCache = nullptr;
304
0
  if (cx) {
305
0
    atomsCache = GetAtomCache<ConsoleCounterErrorAtoms>(cx);
306
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
307
0
      return false;
308
0
    }
309
0
  }
310
0
311
0
  if (!IsConvertibleToDictionary(val)) {
312
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
313
0
  }
314
0
315
0
  bool isNull = val.isNullOrUndefined();
316
0
  // We only need these if !isNull, in which case we have |cx|.
317
0
  Maybe<JS::Rooted<JSObject *> > object;
318
0
  Maybe<JS::Rooted<JS::Value> > temp;
319
0
  if (!isNull) {
320
0
    MOZ_ASSERT(cx);
321
0
    object.emplace(cx, &val.toObject());
322
0
    temp.emplace(cx);
323
0
  }
324
0
  if (!isNull) {
325
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->error_id, temp.ptr())) {
326
0
      return false;
327
0
    }
328
0
  }
329
0
  if (!isNull && !temp->isUndefined()) {
330
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mError)) {
331
0
      return false;
332
0
    }
333
0
  } else {
334
0
    static const char16_t data[] = { 0 };
335
0
    mError.Rebind(data, ArrayLength(data) - 1);
336
0
  }
337
0
  mIsAnyMemberPresent = true;
338
0
339
0
  if (!isNull) {
340
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->label_id, temp.ptr())) {
341
0
      return false;
342
0
    }
343
0
  }
344
0
  if (!isNull && !temp->isUndefined()) {
345
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mLabel)) {
346
0
      return false;
347
0
    }
348
0
  } else {
349
0
    static const char16_t data[] = { 0 };
350
0
    mLabel.Rebind(data, ArrayLength(data) - 1);
351
0
  }
352
0
  mIsAnyMemberPresent = true;
353
0
  return true;
354
0
}
355
356
bool
357
ConsoleCounterError::Init(const nsAString& aJSON)
358
0
{
359
0
  AutoJSAPI jsapi;
360
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
361
0
  if (!cleanGlobal) {
362
0
    return false;
363
0
  }
364
0
  if (!jsapi.Init(cleanGlobal)) {
365
0
    return false;
366
0
  }
367
0
  JSContext* cx = jsapi.cx();
368
0
  JS::Rooted<JS::Value> json(cx);
369
0
  bool ok = ParseJSON(cx, aJSON, &json);
370
0
  NS_ENSURE_TRUE(ok, false);
371
0
  return Init(cx, json);
372
0
}
373
374
bool
375
ConsoleCounterError::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
376
0
{
377
0
  ConsoleCounterErrorAtoms* atomsCache = GetAtomCache<ConsoleCounterErrorAtoms>(cx);
378
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
379
0
    return false;
380
0
  }
381
0
382
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
383
0
  if (!obj) {
384
0
    return false;
385
0
  }
386
0
  rval.set(JS::ObjectValue(*obj));
387
0
388
0
  do {
389
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
390
0
    JS::Rooted<JS::Value> temp(cx);
391
0
    nsString const & currentValue = mError;
392
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
393
0
      return false;
394
0
    }
395
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->error_id, temp, JSPROP_ENUMERATE)) {
396
0
      return false;
397
0
    }
398
0
    break;
399
0
  } while(false);
400
0
401
0
  do {
402
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
403
0
    JS::Rooted<JS::Value> temp(cx);
404
0
    nsString const & currentValue = mLabel;
405
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
406
0
      return false;
407
0
    }
408
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->label_id, temp, JSPROP_ENUMERATE)) {
409
0
      return false;
410
0
    }
411
0
    break;
412
0
  } while(false);
413
0
414
0
  return true;
415
0
}
416
417
bool
418
ConsoleCounterError::ToJSON(nsAString& aJSON) const
419
0
{
420
0
  AutoJSAPI jsapi;
421
0
  jsapi.Init();
422
0
  JSContext *cx = jsapi.cx();
423
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
424
0
  // because we'll only be creating objects, in ways that have no
425
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
426
0
  // which likewise guarantees no side-effects for the sorts of
427
0
  // things we will pass it.
428
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
429
0
  JS::Rooted<JS::Value> val(cx);
430
0
  if (!ToObjectInternal(cx, &val)) {
431
0
    return false;
432
0
  }
433
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
434
0
  return StringifyToJSON(cx, obj, aJSON);
435
0
}
436
437
void
438
ConsoleCounterError::TraceDictionary(JSTracer* trc)
439
0
{
440
0
}
441
442
ConsoleCounterError&
443
ConsoleCounterError::operator=(const ConsoleCounterError& aOther)
444
0
{
445
0
  DictionaryBase::operator=(aOther);
446
0
  mError = aOther.mError;
447
0
  mLabel = aOther.mLabel;
448
0
  return *this;
449
0
}
450
451
namespace binding_detail {
452
} // namespace binding_detail
453
454
455
456
ConsoleInstanceOptions::ConsoleInstanceOptions()
457
0
{
458
0
  // Safe to pass a null context if we pass a null value
459
0
  Init(nullptr, JS::NullHandleValue);
460
0
}
461
462
463
bool
464
ConsoleInstanceOptions::InitIds(JSContext* cx, ConsoleInstanceOptionsAtoms* atomsCache)
465
0
{
466
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
467
0
468
0
  // Initialize these in reverse order so that any failure leaves the first one
469
0
  // uninitialized.
470
0
  if (!atomsCache->prefix_id.init(cx, "prefix") ||
471
0
      !atomsCache->maxLogLevelPref_id.init(cx, "maxLogLevelPref") ||
472
0
      !atomsCache->maxLogLevel_id.init(cx, "maxLogLevel") ||
473
0
      !atomsCache->innerID_id.init(cx, "innerID") ||
474
0
      !atomsCache->dump_id.init(cx, "dump") ||
475
0
      !atomsCache->consoleID_id.init(cx, "consoleID")) {
476
0
    return false;
477
0
  }
478
0
  return true;
479
0
}
480
481
bool
482
ConsoleInstanceOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
483
0
{
484
0
  // Passing a null JSContext is OK only if we're initing from null,
485
0
  // Since in that case we will not have to do any property gets
486
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
487
0
  // checkers by static analysis tools
488
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
489
0
  ConsoleInstanceOptionsAtoms* atomsCache = nullptr;
490
0
  if (cx) {
491
0
    atomsCache = GetAtomCache<ConsoleInstanceOptionsAtoms>(cx);
492
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
493
0
      return false;
494
0
    }
495
0
  }
496
0
497
0
  if (!IsConvertibleToDictionary(val)) {
498
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
499
0
  }
500
0
501
0
  bool isNull = val.isNullOrUndefined();
502
0
  // We only need these if !isNull, in which case we have |cx|.
503
0
  Maybe<JS::Rooted<JSObject *> > object;
504
0
  Maybe<JS::Rooted<JS::Value> > temp;
505
0
  if (!isNull) {
506
0
    MOZ_ASSERT(cx);
507
0
    object.emplace(cx, &val.toObject());
508
0
    temp.emplace(cx);
509
0
  }
510
0
  if (!isNull) {
511
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->consoleID_id, temp.ptr())) {
512
0
      return false;
513
0
    }
514
0
  }
515
0
  if (!isNull && !temp->isUndefined()) {
516
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mConsoleID)) {
517
0
      return false;
518
0
    }
519
0
  } else {
520
0
    static const char16_t data[] = { 0 };
521
0
    mConsoleID.Rebind(data, ArrayLength(data) - 1);
522
0
  }
523
0
  mIsAnyMemberPresent = true;
524
0
525
0
  if (!isNull) {
526
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->dump_id, temp.ptr())) {
527
0
      return false;
528
0
    }
529
0
  }
530
0
  if (!isNull && !temp->isUndefined()) {
531
0
    mDump.Construct();
532
0
    if (temp.ref().isObject()) {
533
0
      if (JS::IsCallable(&temp.ref().toObject())) {
534
0
      { // scope for tempRoot and tempGlobalRoot if needed
535
0
        JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject());
536
0
        JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
537
0
        (mDump.Value()) = new ConsoleInstanceDumpCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
538
0
      }
539
0
      } else {
540
0
        ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "'dump' member of ConsoleInstanceOptions");
541
0
        return false;
542
0
      }
543
0
    } else {
544
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'dump' member of ConsoleInstanceOptions");
545
0
      return false;
546
0
    }
547
0
    mIsAnyMemberPresent = true;
548
0
  }
549
0
550
0
  if (!isNull) {
551
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->innerID_id, temp.ptr())) {
552
0
      return false;
553
0
    }
554
0
  }
555
0
  if (!isNull && !temp->isUndefined()) {
556
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mInnerID)) {
557
0
      return false;
558
0
    }
559
0
  } else {
560
0
    static const char16_t data[] = { 0 };
561
0
    mInnerID.Rebind(data, ArrayLength(data) - 1);
562
0
  }
563
0
  mIsAnyMemberPresent = true;
564
0
565
0
  if (!isNull) {
566
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->maxLogLevel_id, temp.ptr())) {
567
0
      return false;
568
0
    }
569
0
  }
570
0
  if (!isNull && !temp->isUndefined()) {
571
0
    mMaxLogLevel.Construct();
572
0
    {
573
0
      int index;
574
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), ConsoleLogLevelValues::strings, "ConsoleLogLevel", "'maxLogLevel' member of ConsoleInstanceOptions", &index)) {
575
0
        return false;
576
0
      }
577
0
      MOZ_ASSERT(index >= 0);
578
0
      (mMaxLogLevel.Value()) = static_cast<ConsoleLogLevel>(index);
579
0
    }
580
0
    mIsAnyMemberPresent = true;
581
0
  }
582
0
583
0
  if (!isNull) {
584
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->maxLogLevelPref_id, temp.ptr())) {
585
0
      return false;
586
0
    }
587
0
  }
588
0
  if (!isNull && !temp->isUndefined()) {
589
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mMaxLogLevelPref)) {
590
0
      return false;
591
0
    }
592
0
  } else {
593
0
    static const char16_t data[] = { 0 };
594
0
    mMaxLogLevelPref.Rebind(data, ArrayLength(data) - 1);
595
0
  }
596
0
  mIsAnyMemberPresent = true;
597
0
598
0
  if (!isNull) {
599
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->prefix_id, temp.ptr())) {
600
0
      return false;
601
0
    }
602
0
  }
603
0
  if (!isNull && !temp->isUndefined()) {
604
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPrefix)) {
605
0
      return false;
606
0
    }
607
0
  } else {
608
0
    static const char16_t data[] = { 0 };
609
0
    mPrefix.Rebind(data, ArrayLength(data) - 1);
610
0
  }
611
0
  mIsAnyMemberPresent = true;
612
0
  return true;
613
0
}
614
615
bool
616
ConsoleInstanceOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
617
0
{
618
0
  ConsoleInstanceOptionsAtoms* atomsCache = GetAtomCache<ConsoleInstanceOptionsAtoms>(cx);
619
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
620
0
    return false;
621
0
  }
622
0
623
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
624
0
  if (!obj) {
625
0
    return false;
626
0
  }
627
0
  rval.set(JS::ObjectValue(*obj));
628
0
629
0
  do {
630
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
631
0
    JS::Rooted<JS::Value> temp(cx);
632
0
    nsString const & currentValue = mConsoleID;
633
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
634
0
      return false;
635
0
    }
636
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->consoleID_id, temp, JSPROP_ENUMERATE)) {
637
0
      return false;
638
0
    }
639
0
    break;
640
0
  } while(false);
641
0
642
0
  if (mDump.WasPassed()) {
643
0
    do {
644
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
645
0
      JS::Rooted<JS::Value> temp(cx);
646
0
      OwningNonNull<ConsoleInstanceDumpCallback> const & currentValue = mDump.InternalValue();
647
0
      temp.setObjectOrNull(GetCallbackFromCallbackObject(cx, currentValue));
648
0
      if (!MaybeWrapObjectValue(cx, &temp)) {
649
0
        return false;
650
0
      }
651
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->dump_id, temp, JSPROP_ENUMERATE)) {
652
0
        return false;
653
0
      }
654
0
      break;
655
0
    } while(false);
656
0
  }
657
0
658
0
  do {
659
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
660
0
    JS::Rooted<JS::Value> temp(cx);
661
0
    nsString const & currentValue = mInnerID;
662
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
663
0
      return false;
664
0
    }
665
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->innerID_id, temp, JSPROP_ENUMERATE)) {
666
0
      return false;
667
0
    }
668
0
    break;
669
0
  } while(false);
670
0
671
0
  if (mMaxLogLevel.WasPassed()) {
672
0
    do {
673
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
674
0
      JS::Rooted<JS::Value> temp(cx);
675
0
      ConsoleLogLevel const & currentValue = mMaxLogLevel.InternalValue();
676
0
      if (!ToJSValue(cx, currentValue, &temp)) {
677
0
        return false;
678
0
      }
679
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->maxLogLevel_id, temp, JSPROP_ENUMERATE)) {
680
0
        return false;
681
0
      }
682
0
      break;
683
0
    } while(false);
684
0
  }
685
0
686
0
  do {
687
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
688
0
    JS::Rooted<JS::Value> temp(cx);
689
0
    nsString const & currentValue = mMaxLogLevelPref;
690
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
691
0
      return false;
692
0
    }
693
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->maxLogLevelPref_id, temp, JSPROP_ENUMERATE)) {
694
0
      return false;
695
0
    }
696
0
    break;
697
0
  } while(false);
698
0
699
0
  do {
700
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
701
0
    JS::Rooted<JS::Value> temp(cx);
702
0
    nsString const & currentValue = mPrefix;
703
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
704
0
      return false;
705
0
    }
706
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->prefix_id, temp, JSPROP_ENUMERATE)) {
707
0
      return false;
708
0
    }
709
0
    break;
710
0
  } while(false);
711
0
712
0
  return true;
713
0
}
714
715
void
716
ConsoleInstanceOptions::TraceDictionary(JSTracer* trc)
717
0
{
718
0
}
719
720
721
722
namespace binding_detail {
723
} // namespace binding_detail
724
725
726
727
ConsoleProfileEvent::ConsoleProfileEvent()
728
0
{
729
0
  // Safe to pass a null context if we pass a null value
730
0
  Init(nullptr, JS::NullHandleValue);
731
0
}
732
733
734
bool
735
ConsoleProfileEvent::InitIds(JSContext* cx, ConsoleProfileEventAtoms* atomsCache)
736
0
{
737
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
738
0
739
0
  // Initialize these in reverse order so that any failure leaves the first one
740
0
  // uninitialized.
741
0
  if (!atomsCache->arguments_id.init(cx, "arguments") ||
742
0
      !atomsCache->action_id.init(cx, "action")) {
743
0
    return false;
744
0
  }
745
0
  return true;
746
0
}
747
748
bool
749
ConsoleProfileEvent::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
750
0
{
751
0
  // Passing a null JSContext is OK only if we're initing from null,
752
0
  // Since in that case we will not have to do any property gets
753
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
754
0
  // checkers by static analysis tools
755
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
756
0
  ConsoleProfileEventAtoms* atomsCache = nullptr;
757
0
  if (cx) {
758
0
    atomsCache = GetAtomCache<ConsoleProfileEventAtoms>(cx);
759
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
760
0
      return false;
761
0
    }
762
0
  }
763
0
764
0
  if (!IsConvertibleToDictionary(val)) {
765
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
766
0
  }
767
0
768
0
  bool isNull = val.isNullOrUndefined();
769
0
  // We only need these if !isNull, in which case we have |cx|.
770
0
  Maybe<JS::Rooted<JSObject *> > object;
771
0
  Maybe<JS::Rooted<JS::Value> > temp;
772
0
  if (!isNull) {
773
0
    MOZ_ASSERT(cx);
774
0
    object.emplace(cx, &val.toObject());
775
0
    temp.emplace(cx);
776
0
  }
777
0
  if (!isNull) {
778
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->action_id, temp.ptr())) {
779
0
      return false;
780
0
    }
781
0
  }
782
0
  if (!isNull && !temp->isUndefined()) {
783
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mAction)) {
784
0
      return false;
785
0
    }
786
0
  } else {
787
0
    static const char16_t data[] = { 0 };
788
0
    mAction.Rebind(data, ArrayLength(data) - 1);
789
0
  }
790
0
  mIsAnyMemberPresent = true;
791
0
792
0
  if (!isNull) {
793
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->arguments_id, temp.ptr())) {
794
0
      return false;
795
0
    }
796
0
  }
797
0
  if (!isNull && !temp->isUndefined()) {
798
0
    mArguments.Construct();
799
0
    if (temp.ref().isObject()) {
800
0
      JS::ForOfIterator iter(cx);
801
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
802
0
        return false;
803
0
      }
804
0
      if (!iter.valueIsIterable()) {
805
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'arguments' member of ConsoleProfileEvent");
806
0
        return false;
807
0
      }
808
0
      Sequence<JS::Value> &arr = (mArguments.Value());
809
0
      JS::Rooted<JS::Value> temp(cx);
810
0
      while (true) {
811
0
        bool done;
812
0
        if (!iter.next(&temp, &done)) {
813
0
          return false;
814
0
        }
815
0
        if (done) {
816
0
          break;
817
0
        }
818
0
        JS::Value* slotPtr = arr.AppendElement(mozilla::fallible);
819
0
        if (!slotPtr) {
820
0
          JS_ReportOutOfMemory(cx);
821
0
          return false;
822
0
        }
823
0
        JS::Value& slot = *slotPtr;
824
0
#ifdef __clang__
825
0
#pragma clang diagnostic push
826
0
#pragma clang diagnostic ignored "-Wunreachable-code"
827
0
#pragma clang diagnostic ignored "-Wunreachable-code-return"
828
0
#endif // __clang__
829
0
        if ((passedToJSImpl) && !CallerSubsumes(temp)) {
830
0
          ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "element of 'arguments' member of ConsoleProfileEvent");
831
0
          return false;
832
0
        }
833
0
#ifdef __clang__
834
0
#pragma clang diagnostic pop
835
0
#endif // __clang__
836
0
        slot = temp;
837
0
      }
838
0
    } else {
839
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'arguments' member of ConsoleProfileEvent");
840
0
      return false;
841
0
    }
842
0
    mIsAnyMemberPresent = true;
843
0
  }
844
0
  return true;
845
0
}
846
847
bool
848
ConsoleProfileEvent::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
849
0
{
850
0
  ConsoleProfileEventAtoms* atomsCache = GetAtomCache<ConsoleProfileEventAtoms>(cx);
851
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
852
0
    return false;
853
0
  }
854
0
855
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
856
0
  if (!obj) {
857
0
    return false;
858
0
  }
859
0
  rval.set(JS::ObjectValue(*obj));
860
0
861
0
  do {
862
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
863
0
    JS::Rooted<JS::Value> temp(cx);
864
0
    nsString const & currentValue = mAction;
865
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
866
0
      return false;
867
0
    }
868
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->action_id, temp, JSPROP_ENUMERATE)) {
869
0
      return false;
870
0
    }
871
0
    break;
872
0
  } while(false);
873
0
874
0
  if (mArguments.WasPassed()) {
875
0
    do {
876
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
877
0
      JS::Rooted<JS::Value> temp(cx);
878
0
      Sequence<JS::Value> const & currentValue = mArguments.InternalValue();
879
0
880
0
      uint32_t length = currentValue.Length();
881
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
882
0
      if (!returnArray) {
883
0
        return false;
884
0
      }
885
0
      // Scope for 'tmp'
886
0
      {
887
0
        JS::Rooted<JS::Value> tmp(cx);
888
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
889
0
          // Control block to let us common up the JS_DefineElement calls when there
890
0
          // are different ways to succeed at wrapping the object.
891
0
          do {
892
0
            JS::ExposeValueToActiveJS(currentValue[sequenceIdx0]);
893
0
            tmp.set(currentValue[sequenceIdx0]);
894
0
            if (!MaybeWrapValue(cx, &tmp)) {
895
0
              return false;
896
0
            }
897
0
            break;
898
0
          } while (false);
899
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
900
0
                                JSPROP_ENUMERATE)) {
901
0
            return false;
902
0
          }
903
0
        }
904
0
      }
905
0
      temp.setObject(*returnArray);
906
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->arguments_id, temp, JSPROP_ENUMERATE)) {
907
0
        return false;
908
0
      }
909
0
      break;
910
0
    } while(false);
911
0
  }
912
0
913
0
  return true;
914
0
}
915
916
void
917
ConsoleProfileEvent::TraceDictionary(JSTracer* trc)
918
0
{
919
0
  if (mArguments.WasPassed()) {
920
0
    DoTraceSequence(trc, mArguments.Value());
921
0
  }
922
0
}
923
924
namespace binding_detail {
925
} // namespace binding_detail
926
927
928
929
ConsoleStackEntry::ConsoleStackEntry()
930
0
{
931
0
  // Safe to pass a null context if we pass a null value
932
0
  Init(nullptr, JS::NullHandleValue);
933
0
}
934
935
936
937
bool
938
ConsoleStackEntry::InitIds(JSContext* cx, ConsoleStackEntryAtoms* atomsCache)
939
0
{
940
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
941
0
942
0
  // Initialize these in reverse order so that any failure leaves the first one
943
0
  // uninitialized.
944
0
  if (!atomsCache->lineNumber_id.init(cx, "lineNumber") ||
945
0
      !atomsCache->functionName_id.init(cx, "functionName") ||
946
0
      !atomsCache->filename_id.init(cx, "filename") ||
947
0
      !atomsCache->columnNumber_id.init(cx, "columnNumber") ||
948
0
      !atomsCache->asyncCause_id.init(cx, "asyncCause")) {
949
0
    return false;
950
0
  }
951
0
  return true;
952
0
}
953
954
bool
955
ConsoleStackEntry::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
956
0
{
957
0
  // Passing a null JSContext is OK only if we're initing from null,
958
0
  // Since in that case we will not have to do any property gets
959
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
960
0
  // checkers by static analysis tools
961
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
962
0
  ConsoleStackEntryAtoms* atomsCache = nullptr;
963
0
  if (cx) {
964
0
    atomsCache = GetAtomCache<ConsoleStackEntryAtoms>(cx);
965
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
966
0
      return false;
967
0
    }
968
0
  }
969
0
970
0
  if (!IsConvertibleToDictionary(val)) {
971
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
972
0
  }
973
0
974
0
  bool isNull = val.isNullOrUndefined();
975
0
  // We only need these if !isNull, in which case we have |cx|.
976
0
  Maybe<JS::Rooted<JSObject *> > object;
977
0
  Maybe<JS::Rooted<JS::Value> > temp;
978
0
  if (!isNull) {
979
0
    MOZ_ASSERT(cx);
980
0
    object.emplace(cx, &val.toObject());
981
0
    temp.emplace(cx);
982
0
  }
983
0
  if (!isNull) {
984
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->asyncCause_id, temp.ptr())) {
985
0
      return false;
986
0
    }
987
0
  }
988
0
  if (!isNull && !temp->isUndefined()) {
989
0
    mAsyncCause.Construct();
990
0
    if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mAsyncCause.Value()))) {
991
0
      return false;
992
0
    }
993
0
    mIsAnyMemberPresent = true;
994
0
  }
995
0
996
0
  if (!isNull) {
997
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->columnNumber_id, temp.ptr())) {
998
0
      return false;
999
0
    }
1000
0
  }
1001
0
  if (!isNull && !temp->isUndefined()) {
1002
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mColumnNumber)) {
1003
0
      return false;
1004
0
    }
1005
0
  } else {
1006
0
    mColumnNumber = 0U;
1007
0
  }
1008
0
  mIsAnyMemberPresent = true;
1009
0
1010
0
  if (!isNull) {
1011
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->filename_id, temp.ptr())) {
1012
0
      return false;
1013
0
    }
1014
0
  }
1015
0
  if (!isNull && !temp->isUndefined()) {
1016
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFilename)) {
1017
0
      return false;
1018
0
    }
1019
0
  } else {
1020
0
    static const char16_t data[] = { 0 };
1021
0
    mFilename.Rebind(data, ArrayLength(data) - 1);
1022
0
  }
1023
0
  mIsAnyMemberPresent = true;
1024
0
1025
0
  if (!isNull) {
1026
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->functionName_id, temp.ptr())) {
1027
0
      return false;
1028
0
    }
1029
0
  }
1030
0
  if (!isNull && !temp->isUndefined()) {
1031
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFunctionName)) {
1032
0
      return false;
1033
0
    }
1034
0
  } else {
1035
0
    static const char16_t data[] = { 0 };
1036
0
    mFunctionName.Rebind(data, ArrayLength(data) - 1);
1037
0
  }
1038
0
  mIsAnyMemberPresent = true;
1039
0
1040
0
  if (!isNull) {
1041
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->lineNumber_id, temp.ptr())) {
1042
0
      return false;
1043
0
    }
1044
0
  }
1045
0
  if (!isNull && !temp->isUndefined()) {
1046
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mLineNumber)) {
1047
0
      return false;
1048
0
    }
1049
0
  } else {
1050
0
    mLineNumber = 0U;
1051
0
  }
1052
0
  mIsAnyMemberPresent = true;
1053
0
  return true;
1054
0
}
1055
1056
bool
1057
ConsoleStackEntry::Init(const nsAString& aJSON)
1058
0
{
1059
0
  AutoJSAPI jsapi;
1060
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1061
0
  if (!cleanGlobal) {
1062
0
    return false;
1063
0
  }
1064
0
  if (!jsapi.Init(cleanGlobal)) {
1065
0
    return false;
1066
0
  }
1067
0
  JSContext* cx = jsapi.cx();
1068
0
  JS::Rooted<JS::Value> json(cx);
1069
0
  bool ok = ParseJSON(cx, aJSON, &json);
1070
0
  NS_ENSURE_TRUE(ok, false);
1071
0
  return Init(cx, json);
1072
0
}
1073
1074
bool
1075
ConsoleStackEntry::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1076
0
{
1077
0
  ConsoleStackEntryAtoms* atomsCache = GetAtomCache<ConsoleStackEntryAtoms>(cx);
1078
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1079
0
    return false;
1080
0
  }
1081
0
1082
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1083
0
  if (!obj) {
1084
0
    return false;
1085
0
  }
1086
0
  rval.set(JS::ObjectValue(*obj));
1087
0
1088
0
  if (mAsyncCause.WasPassed()) {
1089
0
    do {
1090
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1091
0
      JS::Rooted<JS::Value> temp(cx);
1092
0
      nsString const & currentValue = mAsyncCause.InternalValue();
1093
0
      if (!xpc::StringToJsval(cx, currentValue, &temp)) {
1094
0
        return false;
1095
0
      }
1096
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->asyncCause_id, temp, JSPROP_ENUMERATE)) {
1097
0
        return false;
1098
0
      }
1099
0
      break;
1100
0
    } while(false);
1101
0
  }
1102
0
1103
0
  do {
1104
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1105
0
    JS::Rooted<JS::Value> temp(cx);
1106
0
    uint32_t const & currentValue = mColumnNumber;
1107
0
    temp.setNumber(currentValue);
1108
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->columnNumber_id, temp, JSPROP_ENUMERATE)) {
1109
0
      return false;
1110
0
    }
1111
0
    break;
1112
0
  } while(false);
1113
0
1114
0
  do {
1115
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1116
0
    JS::Rooted<JS::Value> temp(cx);
1117
0
    nsString const & currentValue = mFilename;
1118
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1119
0
      return false;
1120
0
    }
1121
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->filename_id, temp, JSPROP_ENUMERATE)) {
1122
0
      return false;
1123
0
    }
1124
0
    break;
1125
0
  } while(false);
1126
0
1127
0
  do {
1128
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1129
0
    JS::Rooted<JS::Value> temp(cx);
1130
0
    nsString const & currentValue = mFunctionName;
1131
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1132
0
      return false;
1133
0
    }
1134
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->functionName_id, temp, JSPROP_ENUMERATE)) {
1135
0
      return false;
1136
0
    }
1137
0
    break;
1138
0
  } while(false);
1139
0
1140
0
  do {
1141
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1142
0
    JS::Rooted<JS::Value> temp(cx);
1143
0
    uint32_t const & currentValue = mLineNumber;
1144
0
    temp.setNumber(currentValue);
1145
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->lineNumber_id, temp, JSPROP_ENUMERATE)) {
1146
0
      return false;
1147
0
    }
1148
0
    break;
1149
0
  } while(false);
1150
0
1151
0
  return true;
1152
0
}
1153
1154
bool
1155
ConsoleStackEntry::ToJSON(nsAString& aJSON) const
1156
0
{
1157
0
  AutoJSAPI jsapi;
1158
0
  jsapi.Init();
1159
0
  JSContext *cx = jsapi.cx();
1160
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1161
0
  // because we'll only be creating objects, in ways that have no
1162
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1163
0
  // which likewise guarantees no side-effects for the sorts of
1164
0
  // things we will pass it.
1165
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1166
0
  JS::Rooted<JS::Value> val(cx);
1167
0
  if (!ToObjectInternal(cx, &val)) {
1168
0
    return false;
1169
0
  }
1170
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1171
0
  return StringifyToJSON(cx, obj, aJSON);
1172
0
}
1173
1174
void
1175
ConsoleStackEntry::TraceDictionary(JSTracer* trc)
1176
0
{
1177
0
}
1178
1179
ConsoleStackEntry&
1180
ConsoleStackEntry::operator=(const ConsoleStackEntry& aOther)
1181
0
{
1182
0
  DictionaryBase::operator=(aOther);
1183
0
  mAsyncCause.Reset();
1184
0
  if (aOther.mAsyncCause.WasPassed()) {
1185
0
    mAsyncCause.Construct(aOther.mAsyncCause.Value());
1186
0
  }
1187
0
  mColumnNumber = aOther.mColumnNumber;
1188
0
  mFilename = aOther.mFilename;
1189
0
  mFunctionName = aOther.mFunctionName;
1190
0
  mLineNumber = aOther.mLineNumber;
1191
0
  return *this;
1192
0
}
1193
1194
namespace binding_detail {
1195
} // namespace binding_detail
1196
1197
1198
1199
ConsoleTimerError::ConsoleTimerError()
1200
0
{
1201
0
  // Safe to pass a null context if we pass a null value
1202
0
  Init(nullptr, JS::NullHandleValue);
1203
0
}
1204
1205
1206
1207
bool
1208
ConsoleTimerError::InitIds(JSContext* cx, ConsoleTimerErrorAtoms* atomsCache)
1209
0
{
1210
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1211
0
1212
0
  // Initialize these in reverse order so that any failure leaves the first one
1213
0
  // uninitialized.
1214
0
  if (!atomsCache->name_id.init(cx, "name") ||
1215
0
      !atomsCache->error_id.init(cx, "error")) {
1216
0
    return false;
1217
0
  }
1218
0
  return true;
1219
0
}
1220
1221
bool
1222
ConsoleTimerError::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1223
0
{
1224
0
  // Passing a null JSContext is OK only if we're initing from null,
1225
0
  // Since in that case we will not have to do any property gets
1226
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1227
0
  // checkers by static analysis tools
1228
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1229
0
  ConsoleTimerErrorAtoms* atomsCache = nullptr;
1230
0
  if (cx) {
1231
0
    atomsCache = GetAtomCache<ConsoleTimerErrorAtoms>(cx);
1232
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1233
0
      return false;
1234
0
    }
1235
0
  }
1236
0
1237
0
  if (!IsConvertibleToDictionary(val)) {
1238
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1239
0
  }
1240
0
1241
0
  bool isNull = val.isNullOrUndefined();
1242
0
  // We only need these if !isNull, in which case we have |cx|.
1243
0
  Maybe<JS::Rooted<JSObject *> > object;
1244
0
  Maybe<JS::Rooted<JS::Value> > temp;
1245
0
  if (!isNull) {
1246
0
    MOZ_ASSERT(cx);
1247
0
    object.emplace(cx, &val.toObject());
1248
0
    temp.emplace(cx);
1249
0
  }
1250
0
  if (!isNull) {
1251
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->error_id, temp.ptr())) {
1252
0
      return false;
1253
0
    }
1254
0
  }
1255
0
  if (!isNull && !temp->isUndefined()) {
1256
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mError)) {
1257
0
      return false;
1258
0
    }
1259
0
  } else {
1260
0
    static const char16_t data[] = { 0 };
1261
0
    mError.Rebind(data, ArrayLength(data) - 1);
1262
0
  }
1263
0
  mIsAnyMemberPresent = true;
1264
0
1265
0
  if (!isNull) {
1266
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
1267
0
      return false;
1268
0
    }
1269
0
  }
1270
0
  if (!isNull && !temp->isUndefined()) {
1271
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
1272
0
      return false;
1273
0
    }
1274
0
  } else {
1275
0
    static const char16_t data[] = { 0 };
1276
0
    mName.Rebind(data, ArrayLength(data) - 1);
1277
0
  }
1278
0
  mIsAnyMemberPresent = true;
1279
0
  return true;
1280
0
}
1281
1282
bool
1283
ConsoleTimerError::Init(const nsAString& aJSON)
1284
0
{
1285
0
  AutoJSAPI jsapi;
1286
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1287
0
  if (!cleanGlobal) {
1288
0
    return false;
1289
0
  }
1290
0
  if (!jsapi.Init(cleanGlobal)) {
1291
0
    return false;
1292
0
  }
1293
0
  JSContext* cx = jsapi.cx();
1294
0
  JS::Rooted<JS::Value> json(cx);
1295
0
  bool ok = ParseJSON(cx, aJSON, &json);
1296
0
  NS_ENSURE_TRUE(ok, false);
1297
0
  return Init(cx, json);
1298
0
}
1299
1300
bool
1301
ConsoleTimerError::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1302
0
{
1303
0
  ConsoleTimerErrorAtoms* atomsCache = GetAtomCache<ConsoleTimerErrorAtoms>(cx);
1304
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1305
0
    return false;
1306
0
  }
1307
0
1308
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1309
0
  if (!obj) {
1310
0
    return false;
1311
0
  }
1312
0
  rval.set(JS::ObjectValue(*obj));
1313
0
1314
0
  do {
1315
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1316
0
    JS::Rooted<JS::Value> temp(cx);
1317
0
    nsString const & currentValue = mError;
1318
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1319
0
      return false;
1320
0
    }
1321
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->error_id, temp, JSPROP_ENUMERATE)) {
1322
0
      return false;
1323
0
    }
1324
0
    break;
1325
0
  } while(false);
1326
0
1327
0
  do {
1328
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1329
0
    JS::Rooted<JS::Value> temp(cx);
1330
0
    nsString const & currentValue = mName;
1331
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1332
0
      return false;
1333
0
    }
1334
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
1335
0
      return false;
1336
0
    }
1337
0
    break;
1338
0
  } while(false);
1339
0
1340
0
  return true;
1341
0
}
1342
1343
bool
1344
ConsoleTimerError::ToJSON(nsAString& aJSON) const
1345
0
{
1346
0
  AutoJSAPI jsapi;
1347
0
  jsapi.Init();
1348
0
  JSContext *cx = jsapi.cx();
1349
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1350
0
  // because we'll only be creating objects, in ways that have no
1351
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1352
0
  // which likewise guarantees no side-effects for the sorts of
1353
0
  // things we will pass it.
1354
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1355
0
  JS::Rooted<JS::Value> val(cx);
1356
0
  if (!ToObjectInternal(cx, &val)) {
1357
0
    return false;
1358
0
  }
1359
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1360
0
  return StringifyToJSON(cx, obj, aJSON);
1361
0
}
1362
1363
void
1364
ConsoleTimerError::TraceDictionary(JSTracer* trc)
1365
0
{
1366
0
}
1367
1368
ConsoleTimerError&
1369
ConsoleTimerError::operator=(const ConsoleTimerError& aOther)
1370
0
{
1371
0
  DictionaryBase::operator=(aOther);
1372
0
  mError = aOther.mError;
1373
0
  mName = aOther.mName;
1374
0
  return *this;
1375
0
}
1376
1377
namespace binding_detail {
1378
} // namespace binding_detail
1379
1380
1381
1382
ConsoleTimerLogOrEnd::ConsoleTimerLogOrEnd()
1383
0
{
1384
0
  // Safe to pass a null context if we pass a null value
1385
0
  Init(nullptr, JS::NullHandleValue);
1386
0
}
1387
1388
1389
1390
bool
1391
ConsoleTimerLogOrEnd::InitIds(JSContext* cx, ConsoleTimerLogOrEndAtoms* atomsCache)
1392
0
{
1393
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1394
0
1395
0
  // Initialize these in reverse order so that any failure leaves the first one
1396
0
  // uninitialized.
1397
0
  if (!atomsCache->name_id.init(cx, "name") ||
1398
0
      !atomsCache->duration_id.init(cx, "duration")) {
1399
0
    return false;
1400
0
  }
1401
0
  return true;
1402
0
}
1403
1404
bool
1405
ConsoleTimerLogOrEnd::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1406
0
{
1407
0
  // Passing a null JSContext is OK only if we're initing from null,
1408
0
  // Since in that case we will not have to do any property gets
1409
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1410
0
  // checkers by static analysis tools
1411
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1412
0
  ConsoleTimerLogOrEndAtoms* atomsCache = nullptr;
1413
0
  if (cx) {
1414
0
    atomsCache = GetAtomCache<ConsoleTimerLogOrEndAtoms>(cx);
1415
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1416
0
      return false;
1417
0
    }
1418
0
  }
1419
0
1420
0
  if (!IsConvertibleToDictionary(val)) {
1421
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1422
0
  }
1423
0
1424
0
  bool isNull = val.isNullOrUndefined();
1425
0
  // We only need these if !isNull, in which case we have |cx|.
1426
0
  Maybe<JS::Rooted<JSObject *> > object;
1427
0
  Maybe<JS::Rooted<JS::Value> > temp;
1428
0
  if (!isNull) {
1429
0
    MOZ_ASSERT(cx);
1430
0
    object.emplace(cx, &val.toObject());
1431
0
    temp.emplace(cx);
1432
0
  }
1433
0
  if (!isNull) {
1434
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->duration_id, temp.ptr())) {
1435
0
      return false;
1436
0
    }
1437
0
  }
1438
0
  if (!isNull && !temp->isUndefined()) {
1439
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mDuration)) {
1440
0
      return false;
1441
0
    } else if (!mozilla::IsFinite(mDuration)) {
1442
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'duration' member of ConsoleTimerLogOrEnd");
1443
0
      return false;
1444
0
    }
1445
0
  } else {
1446
0
    mDuration = 0.0;
1447
0
  }
1448
0
  mIsAnyMemberPresent = true;
1449
0
1450
0
  if (!isNull) {
1451
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
1452
0
      return false;
1453
0
    }
1454
0
  }
1455
0
  if (!isNull && !temp->isUndefined()) {
1456
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
1457
0
      return false;
1458
0
    }
1459
0
  } else {
1460
0
    static const char16_t data[] = { 0 };
1461
0
    mName.Rebind(data, ArrayLength(data) - 1);
1462
0
  }
1463
0
  mIsAnyMemberPresent = true;
1464
0
  return true;
1465
0
}
1466
1467
bool
1468
ConsoleTimerLogOrEnd::Init(const nsAString& aJSON)
1469
0
{
1470
0
  AutoJSAPI jsapi;
1471
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1472
0
  if (!cleanGlobal) {
1473
0
    return false;
1474
0
  }
1475
0
  if (!jsapi.Init(cleanGlobal)) {
1476
0
    return false;
1477
0
  }
1478
0
  JSContext* cx = jsapi.cx();
1479
0
  JS::Rooted<JS::Value> json(cx);
1480
0
  bool ok = ParseJSON(cx, aJSON, &json);
1481
0
  NS_ENSURE_TRUE(ok, false);
1482
0
  return Init(cx, json);
1483
0
}
1484
1485
bool
1486
ConsoleTimerLogOrEnd::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1487
0
{
1488
0
  ConsoleTimerLogOrEndAtoms* atomsCache = GetAtomCache<ConsoleTimerLogOrEndAtoms>(cx);
1489
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1490
0
    return false;
1491
0
  }
1492
0
1493
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1494
0
  if (!obj) {
1495
0
    return false;
1496
0
  }
1497
0
  rval.set(JS::ObjectValue(*obj));
1498
0
1499
0
  do {
1500
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1501
0
    JS::Rooted<JS::Value> temp(cx);
1502
0
    double const & currentValue = mDuration;
1503
0
    temp.set(JS_NumberValue(double(currentValue)));
1504
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->duration_id, temp, JSPROP_ENUMERATE)) {
1505
0
      return false;
1506
0
    }
1507
0
    break;
1508
0
  } while(false);
1509
0
1510
0
  do {
1511
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1512
0
    JS::Rooted<JS::Value> temp(cx);
1513
0
    nsString const & currentValue = mName;
1514
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1515
0
      return false;
1516
0
    }
1517
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
1518
0
      return false;
1519
0
    }
1520
0
    break;
1521
0
  } while(false);
1522
0
1523
0
  return true;
1524
0
}
1525
1526
bool
1527
ConsoleTimerLogOrEnd::ToJSON(nsAString& aJSON) const
1528
0
{
1529
0
  AutoJSAPI jsapi;
1530
0
  jsapi.Init();
1531
0
  JSContext *cx = jsapi.cx();
1532
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1533
0
  // because we'll only be creating objects, in ways that have no
1534
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1535
0
  // which likewise guarantees no side-effects for the sorts of
1536
0
  // things we will pass it.
1537
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1538
0
  JS::Rooted<JS::Value> val(cx);
1539
0
  if (!ToObjectInternal(cx, &val)) {
1540
0
    return false;
1541
0
  }
1542
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1543
0
  return StringifyToJSON(cx, obj, aJSON);
1544
0
}
1545
1546
void
1547
ConsoleTimerLogOrEnd::TraceDictionary(JSTracer* trc)
1548
0
{
1549
0
}
1550
1551
ConsoleTimerLogOrEnd&
1552
ConsoleTimerLogOrEnd::operator=(const ConsoleTimerLogOrEnd& aOther)
1553
0
{
1554
0
  DictionaryBase::operator=(aOther);
1555
0
  mDuration = aOther.mDuration;
1556
0
  mName = aOther.mName;
1557
0
  return *this;
1558
0
}
1559
1560
namespace binding_detail {
1561
} // namespace binding_detail
1562
1563
1564
1565
ConsoleTimerStart::ConsoleTimerStart()
1566
0
{
1567
0
  // Safe to pass a null context if we pass a null value
1568
0
  Init(nullptr, JS::NullHandleValue);
1569
0
}
1570
1571
1572
1573
bool
1574
ConsoleTimerStart::InitIds(JSContext* cx, ConsoleTimerStartAtoms* atomsCache)
1575
0
{
1576
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1577
0
1578
0
  // Initialize these in reverse order so that any failure leaves the first one
1579
0
  // uninitialized.
1580
0
  if (!atomsCache->name_id.init(cx, "name")) {
1581
0
    return false;
1582
0
  }
1583
0
  return true;
1584
0
}
1585
1586
bool
1587
ConsoleTimerStart::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1588
0
{
1589
0
  // Passing a null JSContext is OK only if we're initing from null,
1590
0
  // Since in that case we will not have to do any property gets
1591
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1592
0
  // checkers by static analysis tools
1593
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1594
0
  ConsoleTimerStartAtoms* atomsCache = nullptr;
1595
0
  if (cx) {
1596
0
    atomsCache = GetAtomCache<ConsoleTimerStartAtoms>(cx);
1597
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1598
0
      return false;
1599
0
    }
1600
0
  }
1601
0
1602
0
  if (!IsConvertibleToDictionary(val)) {
1603
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1604
0
  }
1605
0
1606
0
  bool isNull = val.isNullOrUndefined();
1607
0
  // We only need these if !isNull, in which case we have |cx|.
1608
0
  Maybe<JS::Rooted<JSObject *> > object;
1609
0
  Maybe<JS::Rooted<JS::Value> > temp;
1610
0
  if (!isNull) {
1611
0
    MOZ_ASSERT(cx);
1612
0
    object.emplace(cx, &val.toObject());
1613
0
    temp.emplace(cx);
1614
0
  }
1615
0
  if (!isNull) {
1616
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
1617
0
      return false;
1618
0
    }
1619
0
  }
1620
0
  if (!isNull && !temp->isUndefined()) {
1621
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
1622
0
      return false;
1623
0
    }
1624
0
  } else {
1625
0
    static const char16_t data[] = { 0 };
1626
0
    mName.Rebind(data, ArrayLength(data) - 1);
1627
0
  }
1628
0
  mIsAnyMemberPresent = true;
1629
0
  return true;
1630
0
}
1631
1632
bool
1633
ConsoleTimerStart::Init(const nsAString& aJSON)
1634
0
{
1635
0
  AutoJSAPI jsapi;
1636
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1637
0
  if (!cleanGlobal) {
1638
0
    return false;
1639
0
  }
1640
0
  if (!jsapi.Init(cleanGlobal)) {
1641
0
    return false;
1642
0
  }
1643
0
  JSContext* cx = jsapi.cx();
1644
0
  JS::Rooted<JS::Value> json(cx);
1645
0
  bool ok = ParseJSON(cx, aJSON, &json);
1646
0
  NS_ENSURE_TRUE(ok, false);
1647
0
  return Init(cx, json);
1648
0
}
1649
1650
bool
1651
ConsoleTimerStart::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1652
0
{
1653
0
  ConsoleTimerStartAtoms* atomsCache = GetAtomCache<ConsoleTimerStartAtoms>(cx);
1654
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1655
0
    return false;
1656
0
  }
1657
0
1658
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1659
0
  if (!obj) {
1660
0
    return false;
1661
0
  }
1662
0
  rval.set(JS::ObjectValue(*obj));
1663
0
1664
0
  do {
1665
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1666
0
    JS::Rooted<JS::Value> temp(cx);
1667
0
    nsString const & currentValue = mName;
1668
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1669
0
      return false;
1670
0
    }
1671
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
1672
0
      return false;
1673
0
    }
1674
0
    break;
1675
0
  } while(false);
1676
0
1677
0
  return true;
1678
0
}
1679
1680
bool
1681
ConsoleTimerStart::ToJSON(nsAString& aJSON) const
1682
0
{
1683
0
  AutoJSAPI jsapi;
1684
0
  jsapi.Init();
1685
0
  JSContext *cx = jsapi.cx();
1686
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1687
0
  // because we'll only be creating objects, in ways that have no
1688
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1689
0
  // which likewise guarantees no side-effects for the sorts of
1690
0
  // things we will pass it.
1691
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1692
0
  JS::Rooted<JS::Value> val(cx);
1693
0
  if (!ToObjectInternal(cx, &val)) {
1694
0
    return false;
1695
0
  }
1696
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1697
0
  return StringifyToJSON(cx, obj, aJSON);
1698
0
}
1699
1700
void
1701
ConsoleTimerStart::TraceDictionary(JSTracer* trc)
1702
0
{
1703
0
}
1704
1705
ConsoleTimerStart&
1706
ConsoleTimerStart::operator=(const ConsoleTimerStart& aOther)
1707
0
{
1708
0
  DictionaryBase::operator=(aOther);
1709
0
  mName = aOther.mName;
1710
0
  return *this;
1711
0
}
1712
1713
namespace binding_detail {
1714
} // namespace binding_detail
1715
1716
1717
bool
1718
UnsignedLongLongOrString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
1719
0
{
1720
0
  switch (mType) {
1721
0
    case eUninitialized: {
1722
0
      return false;
1723
0
      break;
1724
0
    }
1725
0
    case eUnsignedLongLong: {
1726
0
      rval.set(JS_NumberValue(double(mValue.mUnsignedLongLong.Value())));
1727
0
      return true;
1728
0
      break;
1729
0
    }
1730
0
    case eString: {
1731
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
1732
0
        return false;
1733
0
      }
1734
0
      return true;
1735
0
      break;
1736
0
    }
1737
0
    default: {
1738
0
      return false;
1739
0
      break;
1740
0
    }
1741
0
  }
1742
0
1743
0
  return false;
1744
0
}
1745
1746
1747
uint64_t&
1748
OwningUnsignedLongLongOrString::RawSetAsUnsignedLongLong()
1749
0
{
1750
0
  if (mType == eUnsignedLongLong) {
1751
0
    return mValue.mUnsignedLongLong.Value();
1752
0
  }
1753
0
  MOZ_ASSERT(mType == eUninitialized);
1754
0
  mType = eUnsignedLongLong;
1755
0
  return mValue.mUnsignedLongLong.SetValue();
1756
0
}
1757
1758
uint64_t&
1759
OwningUnsignedLongLongOrString::SetAsUnsignedLongLong()
1760
0
{
1761
0
  if (mType == eUnsignedLongLong) {
1762
0
    return mValue.mUnsignedLongLong.Value();
1763
0
  }
1764
0
  Uninit();
1765
0
  mType = eUnsignedLongLong;
1766
0
  return mValue.mUnsignedLongLong.SetValue();
1767
0
}
1768
1769
bool
1770
OwningUnsignedLongLongOrString::TrySetToUnsignedLongLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1771
0
{
1772
0
  tryNext = false;
1773
0
  { // scope for memberSlot
1774
0
    uint64_t& memberSlot = RawSetAsUnsignedLongLong();
1775
0
    if (!ValueToPrimitive<uint64_t, eDefault>(cx, value, &memberSlot)) {
1776
0
      return false;
1777
0
    }
1778
0
  }
1779
0
  return true;
1780
0
}
1781
1782
void
1783
OwningUnsignedLongLongOrString::DestroyUnsignedLongLong()
1784
0
{
1785
0
  MOZ_ASSERT(IsUnsignedLongLong(), "Wrong type!");
1786
0
  mValue.mUnsignedLongLong.Destroy();
1787
0
  mType = eUninitialized;
1788
0
}
1789
1790
1791
1792
1793
nsString&
1794
OwningUnsignedLongLongOrString::RawSetAsString()
1795
0
{
1796
0
  if (mType == eString) {
1797
0
    return mValue.mString.Value();
1798
0
  }
1799
0
  MOZ_ASSERT(mType == eUninitialized);
1800
0
  mType = eString;
1801
0
  return mValue.mString.SetValue();
1802
0
}
1803
1804
nsString&
1805
OwningUnsignedLongLongOrString::SetAsString()
1806
0
{
1807
0
  if (mType == eString) {
1808
0
    return mValue.mString.Value();
1809
0
  }
1810
0
  Uninit();
1811
0
  mType = eString;
1812
0
  return mValue.mString.SetValue();
1813
0
}
1814
1815
bool
1816
OwningUnsignedLongLongOrString::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1817
0
{
1818
0
  tryNext = false;
1819
0
  { // scope for memberSlot
1820
0
    nsString& memberSlot = RawSetAsString();
1821
0
    if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
1822
0
      return false;
1823
0
    }
1824
0
  }
1825
0
  return true;
1826
0
}
1827
1828
1829
void
1830
OwningUnsignedLongLongOrString::DestroyString()
1831
0
{
1832
0
  MOZ_ASSERT(IsString(), "Wrong type!");
1833
0
  mValue.mString.Destroy();
1834
0
  mType = eUninitialized;
1835
0
}
1836
1837
1838
1839
1840
void
1841
OwningUnsignedLongLongOrString::Uninit()
1842
{
1843
  switch (mType) {
1844
    case eUninitialized: {
1845
      break;
1846
    }
1847
    case eUnsignedLongLong: {
1848
      DestroyUnsignedLongLong();
1849
      break;
1850
    }
1851
    case eString: {
1852
      DestroyString();
1853
      break;
1854
    }
1855
  }
1856
}
1857
1858
bool
1859
OwningUnsignedLongLongOrString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
1860
0
{
1861
0
  switch (mType) {
1862
0
    case eUninitialized: {
1863
0
      return false;
1864
0
      break;
1865
0
    }
1866
0
    case eUnsignedLongLong: {
1867
0
      rval.set(JS_NumberValue(double(mValue.mUnsignedLongLong.Value())));
1868
0
      return true;
1869
0
      break;
1870
0
    }
1871
0
    case eString: {
1872
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
1873
0
        return false;
1874
0
      }
1875
0
      return true;
1876
0
      break;
1877
0
    }
1878
0
    default: {
1879
0
      return false;
1880
0
      break;
1881
0
    }
1882
0
  }
1883
0
1884
0
  return false;
1885
0
}
1886
1887
void
1888
OwningUnsignedLongLongOrString::TraceUnion(JSTracer* trc)
1889
0
{
1890
0
}
1891
1892
OwningUnsignedLongLongOrString&
1893
OwningUnsignedLongLongOrString::operator=(const OwningUnsignedLongLongOrString& aOther)
1894
0
{
1895
0
  switch (aOther.mType) {
1896
0
    case eUninitialized: {
1897
0
      MOZ_ASSERT(mType == eUninitialized,
1898
0
                 "We need to destroy ourselves?");
1899
0
      break;
1900
0
    }
1901
0
    case eUnsignedLongLong: {
1902
0
      SetAsUnsignedLongLong() = aOther.GetAsUnsignedLongLong();
1903
0
      break;
1904
0
    }
1905
0
    case eString: {
1906
0
      SetAsString() = aOther.GetAsString();
1907
0
      break;
1908
0
    }
1909
0
  }
1910
0
  return *this;
1911
0
}
1912
1913
1914
1915
ConsoleEvent::ConsoleEvent()
1916
  : mCounter(JS::UndefinedValue()),
1917
    mTimer(JS::UndefinedValue())
1918
0
{
1919
0
  // Safe to pass a null context if we pass a null value
1920
0
  Init(nullptr, JS::NullHandleValue);
1921
0
}
1922
1923
1924
bool
1925
ConsoleEvent::InitIds(JSContext* cx, ConsoleEventAtoms* atomsCache)
1926
0
{
1927
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1928
0
1929
0
  // Initialize these in reverse order so that any failure leaves the first one
1930
0
  // uninitialized.
1931
0
  if (!atomsCache->timer_id.init(cx, "timer") ||
1932
0
      !atomsCache->timeStamp_id.init(cx, "timeStamp") ||
1933
0
      !atomsCache->styles_id.init(cx, "styles") ||
1934
0
      !atomsCache->private_id.init(cx, "private") ||
1935
0
      !atomsCache->prefix_id.init(cx, "prefix") ||
1936
0
      !atomsCache->lineNumber_id.init(cx, "lineNumber") ||
1937
0
      !atomsCache->level_id.init(cx, "level") ||
1938
0
      !atomsCache->innerID_id.init(cx, "innerID") ||
1939
0
      !atomsCache->groupName_id.init(cx, "groupName") ||
1940
0
      !atomsCache->functionName_id.init(cx, "functionName") ||
1941
0
      !atomsCache->filename_id.init(cx, "filename") ||
1942
0
      !atomsCache->counter_id.init(cx, "counter") ||
1943
0
      !atomsCache->consoleID_id.init(cx, "consoleID") ||
1944
0
      !atomsCache->columnNumber_id.init(cx, "columnNumber") ||
1945
0
      !atomsCache->arguments_id.init(cx, "arguments") ||
1946
0
      !atomsCache->addonId_id.init(cx, "addonId") ||
1947
0
      !atomsCache->ID_id.init(cx, "ID")) {
1948
0
    return false;
1949
0
  }
1950
0
  return true;
1951
0
}
1952
1953
bool
1954
ConsoleEvent::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1955
0
{
1956
0
  // Passing a null JSContext is OK only if we're initing from null,
1957
0
  // Since in that case we will not have to do any property gets
1958
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1959
0
  // checkers by static analysis tools
1960
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1961
0
  ConsoleEventAtoms* atomsCache = nullptr;
1962
0
  if (cx) {
1963
0
    atomsCache = GetAtomCache<ConsoleEventAtoms>(cx);
1964
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1965
0
      return false;
1966
0
    }
1967
0
  }
1968
0
1969
0
  if (!IsConvertibleToDictionary(val)) {
1970
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1971
0
  }
1972
0
1973
0
  bool isNull = val.isNullOrUndefined();
1974
0
  // We only need these if !isNull, in which case we have |cx|.
1975
0
  Maybe<JS::Rooted<JSObject *> > object;
1976
0
  Maybe<JS::Rooted<JS::Value> > temp;
1977
0
  if (!isNull) {
1978
0
    MOZ_ASSERT(cx);
1979
0
    object.emplace(cx, &val.toObject());
1980
0
    temp.emplace(cx);
1981
0
  }
1982
0
  if (!isNull) {
1983
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->ID_id, temp.ptr())) {
1984
0
      return false;
1985
0
    }
1986
0
  }
1987
0
  if (!isNull && !temp->isUndefined()) {
1988
0
    mID.Construct();
1989
0
    {
1990
0
      bool done = false, failed = false, tryNext;
1991
0
      do {
1992
0
        if (temp.ref().isNumber()) {
1993
0
          done = (failed = !(mID.Value()).TrySetToUnsignedLongLong(cx, temp.ref(), tryNext)) || !tryNext;
1994
0
          break;
1995
0
        }
1996
0
        done = (failed = !(mID.Value()).TrySetToString(cx, temp.ref(), tryNext)) || !tryNext;
1997
0
        break;
1998
0
      } while (false);
1999
0
      if (failed) {
2000
0
        return false;
2001
0
      }
2002
0
      if (!done) {
2003
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'ID' member of ConsoleEvent", "");
2004
0
        return false;
2005
0
      }
2006
0
    }
2007
0
    mIsAnyMemberPresent = true;
2008
0
  }
2009
0
2010
0
  if (!isNull) {
2011
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->addonId_id, temp.ptr())) {
2012
0
      return false;
2013
0
    }
2014
0
  }
2015
0
  if (!isNull && !temp->isUndefined()) {
2016
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mAddonId)) {
2017
0
      return false;
2018
0
    }
2019
0
  } else {
2020
0
    static const char16_t data[] = { 0 };
2021
0
    mAddonId.Rebind(data, ArrayLength(data) - 1);
2022
0
  }
2023
0
  mIsAnyMemberPresent = true;
2024
0
2025
0
  if (!isNull) {
2026
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->arguments_id, temp.ptr())) {
2027
0
      return false;
2028
0
    }
2029
0
  }
2030
0
  if (!isNull && !temp->isUndefined()) {
2031
0
    mArguments.Construct();
2032
0
    if (temp.ref().isObject()) {
2033
0
      JS::ForOfIterator iter(cx);
2034
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
2035
0
        return false;
2036
0
      }
2037
0
      if (!iter.valueIsIterable()) {
2038
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'arguments' member of ConsoleEvent");
2039
0
        return false;
2040
0
      }
2041
0
      Sequence<JS::Value> &arr = (mArguments.Value());
2042
0
      JS::Rooted<JS::Value> temp(cx);
2043
0
      while (true) {
2044
0
        bool done;
2045
0
        if (!iter.next(&temp, &done)) {
2046
0
          return false;
2047
0
        }
2048
0
        if (done) {
2049
0
          break;
2050
0
        }
2051
0
        JS::Value* slotPtr = arr.AppendElement(mozilla::fallible);
2052
0
        if (!slotPtr) {
2053
0
          JS_ReportOutOfMemory(cx);
2054
0
          return false;
2055
0
        }
2056
0
        JS::Value& slot = *slotPtr;
2057
0
#ifdef __clang__
2058
0
#pragma clang diagnostic push
2059
0
#pragma clang diagnostic ignored "-Wunreachable-code"
2060
0
#pragma clang diagnostic ignored "-Wunreachable-code-return"
2061
0
#endif // __clang__
2062
0
        if ((passedToJSImpl) && !CallerSubsumes(temp)) {
2063
0
          ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "element of 'arguments' member of ConsoleEvent");
2064
0
          return false;
2065
0
        }
2066
0
#ifdef __clang__
2067
0
#pragma clang diagnostic pop
2068
0
#endif // __clang__
2069
0
        slot = temp;
2070
0
      }
2071
0
    } else {
2072
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'arguments' member of ConsoleEvent");
2073
0
      return false;
2074
0
    }
2075
0
    mIsAnyMemberPresent = true;
2076
0
  }
2077
0
2078
0
  if (!isNull) {
2079
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->columnNumber_id, temp.ptr())) {
2080
0
      return false;
2081
0
    }
2082
0
  }
2083
0
  if (!isNull && !temp->isUndefined()) {
2084
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mColumnNumber)) {
2085
0
      return false;
2086
0
    }
2087
0
  } else {
2088
0
    mColumnNumber = 0U;
2089
0
  }
2090
0
  mIsAnyMemberPresent = true;
2091
0
2092
0
  if (!isNull) {
2093
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->consoleID_id, temp.ptr())) {
2094
0
      return false;
2095
0
    }
2096
0
  }
2097
0
  if (!isNull && !temp->isUndefined()) {
2098
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mConsoleID)) {
2099
0
      return false;
2100
0
    }
2101
0
  } else {
2102
0
    static const char16_t data[] = { 0 };
2103
0
    mConsoleID.Rebind(data, ArrayLength(data) - 1);
2104
0
  }
2105
0
  mIsAnyMemberPresent = true;
2106
0
2107
0
  if (!isNull) {
2108
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->counter_id, temp.ptr())) {
2109
0
      return false;
2110
0
    }
2111
0
  }
2112
0
  if (!isNull && !temp->isUndefined()) {
2113
0
#ifdef __clang__
2114
0
#pragma clang diagnostic push
2115
0
#pragma clang diagnostic ignored "-Wunreachable-code"
2116
0
#pragma clang diagnostic ignored "-Wunreachable-code-return"
2117
0
#endif // __clang__
2118
0
    if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
2119
0
      ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'counter' member of ConsoleEvent");
2120
0
      return false;
2121
0
    }
2122
0
#ifdef __clang__
2123
0
#pragma clang diagnostic pop
2124
0
#endif // __clang__
2125
0
    mCounter = temp.ref();
2126
0
  } else {
2127
0
    mCounter = JS::NullValue();
2128
0
  }
2129
0
  mIsAnyMemberPresent = true;
2130
0
2131
0
  if (!isNull) {
2132
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->filename_id, temp.ptr())) {
2133
0
      return false;
2134
0
    }
2135
0
  }
2136
0
  if (!isNull && !temp->isUndefined()) {
2137
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFilename)) {
2138
0
      return false;
2139
0
    }
2140
0
  } else {
2141
0
    static const char16_t data[] = { 0 };
2142
0
    mFilename.Rebind(data, ArrayLength(data) - 1);
2143
0
  }
2144
0
  mIsAnyMemberPresent = true;
2145
0
2146
0
  if (!isNull) {
2147
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->functionName_id, temp.ptr())) {
2148
0
      return false;
2149
0
    }
2150
0
  }
2151
0
  if (!isNull && !temp->isUndefined()) {
2152
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFunctionName)) {
2153
0
      return false;
2154
0
    }
2155
0
  } else {
2156
0
    static const char16_t data[] = { 0 };
2157
0
    mFunctionName.Rebind(data, ArrayLength(data) - 1);
2158
0
  }
2159
0
  mIsAnyMemberPresent = true;
2160
0
2161
0
  if (!isNull) {
2162
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->groupName_id, temp.ptr())) {
2163
0
      return false;
2164
0
    }
2165
0
  }
2166
0
  if (!isNull && !temp->isUndefined()) {
2167
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mGroupName)) {
2168
0
      return false;
2169
0
    }
2170
0
  } else {
2171
0
    static const char16_t data[] = { 0 };
2172
0
    mGroupName.Rebind(data, ArrayLength(data) - 1);
2173
0
  }
2174
0
  mIsAnyMemberPresent = true;
2175
0
2176
0
  if (!isNull) {
2177
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->innerID_id, temp.ptr())) {
2178
0
      return false;
2179
0
    }
2180
0
  }
2181
0
  if (!isNull && !temp->isUndefined()) {
2182
0
    mInnerID.Construct();
2183
0
    {
2184
0
      bool done = false, failed = false, tryNext;
2185
0
      do {
2186
0
        if (temp.ref().isNumber()) {
2187
0
          done = (failed = !(mInnerID.Value()).TrySetToUnsignedLongLong(cx, temp.ref(), tryNext)) || !tryNext;
2188
0
          break;
2189
0
        }
2190
0
        done = (failed = !(mInnerID.Value()).TrySetToString(cx, temp.ref(), tryNext)) || !tryNext;
2191
0
        break;
2192
0
      } while (false);
2193
0
      if (failed) {
2194
0
        return false;
2195
0
      }
2196
0
      if (!done) {
2197
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'innerID' member of ConsoleEvent", "");
2198
0
        return false;
2199
0
      }
2200
0
    }
2201
0
    mIsAnyMemberPresent = true;
2202
0
  }
2203
0
2204
0
  if (!isNull) {
2205
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->level_id, temp.ptr())) {
2206
0
      return false;
2207
0
    }
2208
0
  }
2209
0
  if (!isNull && !temp->isUndefined()) {
2210
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mLevel)) {
2211
0
      return false;
2212
0
    }
2213
0
  } else {
2214
0
    static const char16_t data[] = { 0 };
2215
0
    mLevel.Rebind(data, ArrayLength(data) - 1);
2216
0
  }
2217
0
  mIsAnyMemberPresent = true;
2218
0
2219
0
  if (!isNull) {
2220
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->lineNumber_id, temp.ptr())) {
2221
0
      return false;
2222
0
    }
2223
0
  }
2224
0
  if (!isNull && !temp->isUndefined()) {
2225
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mLineNumber)) {
2226
0
      return false;
2227
0
    }
2228
0
  } else {
2229
0
    mLineNumber = 0U;
2230
0
  }
2231
0
  mIsAnyMemberPresent = true;
2232
0
2233
0
  if (!isNull) {
2234
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->prefix_id, temp.ptr())) {
2235
0
      return false;
2236
0
    }
2237
0
  }
2238
0
  if (!isNull && !temp->isUndefined()) {
2239
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPrefix)) {
2240
0
      return false;
2241
0
    }
2242
0
  } else {
2243
0
    static const char16_t data[] = { 0 };
2244
0
    mPrefix.Rebind(data, ArrayLength(data) - 1);
2245
0
  }
2246
0
  mIsAnyMemberPresent = true;
2247
0
2248
0
  if (!isNull) {
2249
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->private_id, temp.ptr())) {
2250
0
      return false;
2251
0
    }
2252
0
  }
2253
0
  if (!isNull && !temp->isUndefined()) {
2254
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mPrivate)) {
2255
0
      return false;
2256
0
    }
2257
0
  } else {
2258
0
    mPrivate = false;
2259
0
  }
2260
0
  mIsAnyMemberPresent = true;
2261
0
2262
0
  if (!isNull) {
2263
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->styles_id, temp.ptr())) {
2264
0
      return false;
2265
0
    }
2266
0
  }
2267
0
  if (!isNull && !temp->isUndefined()) {
2268
0
    mStyles.Construct();
2269
0
    if (temp.ref().isObject()) {
2270
0
      JS::ForOfIterator iter(cx);
2271
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
2272
0
        return false;
2273
0
      }
2274
0
      if (!iter.valueIsIterable()) {
2275
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'styles' member of ConsoleEvent");
2276
0
        return false;
2277
0
      }
2278
0
      Sequence<nsString> &arr = (mStyles.Value());
2279
0
      JS::Rooted<JS::Value> temp(cx);
2280
0
      while (true) {
2281
0
        bool done;
2282
0
        if (!iter.next(&temp, &done)) {
2283
0
          return false;
2284
0
        }
2285
0
        if (done) {
2286
0
          break;
2287
0
        }
2288
0
        nsString* slotPtr = arr.AppendElement(mozilla::fallible);
2289
0
        if (!slotPtr) {
2290
0
          JS_ReportOutOfMemory(cx);
2291
0
          return false;
2292
0
        }
2293
0
        nsString& slot = *slotPtr;
2294
0
        if (!ConvertJSValueToString(cx, temp, eNull, eNull, slot)) {
2295
0
          return false;
2296
0
        }
2297
0
      }
2298
0
    } else {
2299
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'styles' member of ConsoleEvent");
2300
0
      return false;
2301
0
    }
2302
0
    mIsAnyMemberPresent = true;
2303
0
  }
2304
0
2305
0
  if (!isNull) {
2306
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->timeStamp_id, temp.ptr())) {
2307
0
      return false;
2308
0
    }
2309
0
  }
2310
0
  if (!isNull && !temp->isUndefined()) {
2311
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mTimeStamp)) {
2312
0
      return false;
2313
0
    } else if (!mozilla::IsFinite(mTimeStamp)) {
2314
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'timeStamp' member of ConsoleEvent");
2315
0
      return false;
2316
0
    }
2317
0
  } else {
2318
0
    mTimeStamp = 0.0;
2319
0
  }
2320
0
  mIsAnyMemberPresent = true;
2321
0
2322
0
  if (!isNull) {
2323
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->timer_id, temp.ptr())) {
2324
0
      return false;
2325
0
    }
2326
0
  }
2327
0
  if (!isNull && !temp->isUndefined()) {
2328
0
#ifdef __clang__
2329
0
#pragma clang diagnostic push
2330
0
#pragma clang diagnostic ignored "-Wunreachable-code"
2331
0
#pragma clang diagnostic ignored "-Wunreachable-code-return"
2332
0
#endif // __clang__
2333
0
    if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
2334
0
      ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'timer' member of ConsoleEvent");
2335
0
      return false;
2336
0
    }
2337
0
#ifdef __clang__
2338
0
#pragma clang diagnostic pop
2339
0
#endif // __clang__
2340
0
    mTimer = temp.ref();
2341
0
  } else {
2342
0
    mTimer = JS::NullValue();
2343
0
  }
2344
0
  mIsAnyMemberPresent = true;
2345
0
  return true;
2346
0
}
2347
2348
bool
2349
ConsoleEvent::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
2350
0
{
2351
0
  ConsoleEventAtoms* atomsCache = GetAtomCache<ConsoleEventAtoms>(cx);
2352
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
2353
0
    return false;
2354
0
  }
2355
0
2356
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
2357
0
  if (!obj) {
2358
0
    return false;
2359
0
  }
2360
0
  rval.set(JS::ObjectValue(*obj));
2361
0
2362
0
  if (mID.WasPassed()) {
2363
0
    do {
2364
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2365
0
      JS::Rooted<JS::Value> temp(cx);
2366
0
      OwningUnsignedLongLongOrString const & currentValue = mID.InternalValue();
2367
0
      if (!currentValue.ToJSVal(cx, obj, &temp)) {
2368
0
        return false;
2369
0
      }
2370
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->ID_id, temp, JSPROP_ENUMERATE)) {
2371
0
        return false;
2372
0
      }
2373
0
      break;
2374
0
    } while(false);
2375
0
  }
2376
0
2377
0
  do {
2378
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2379
0
    JS::Rooted<JS::Value> temp(cx);
2380
0
    nsString const & currentValue = mAddonId;
2381
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
2382
0
      return false;
2383
0
    }
2384
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->addonId_id, temp, JSPROP_ENUMERATE)) {
2385
0
      return false;
2386
0
    }
2387
0
    break;
2388
0
  } while(false);
2389
0
2390
0
  if (mArguments.WasPassed()) {
2391
0
    do {
2392
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2393
0
      JS::Rooted<JS::Value> temp(cx);
2394
0
      Sequence<JS::Value> const & currentValue = mArguments.InternalValue();
2395
0
2396
0
      uint32_t length = currentValue.Length();
2397
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
2398
0
      if (!returnArray) {
2399
0
        return false;
2400
0
      }
2401
0
      // Scope for 'tmp'
2402
0
      {
2403
0
        JS::Rooted<JS::Value> tmp(cx);
2404
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2405
0
          // Control block to let us common up the JS_DefineElement calls when there
2406
0
          // are different ways to succeed at wrapping the object.
2407
0
          do {
2408
0
            JS::ExposeValueToActiveJS(currentValue[sequenceIdx0]);
2409
0
            tmp.set(currentValue[sequenceIdx0]);
2410
0
            if (!MaybeWrapValue(cx, &tmp)) {
2411
0
              return false;
2412
0
            }
2413
0
            break;
2414
0
          } while (false);
2415
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2416
0
                                JSPROP_ENUMERATE)) {
2417
0
            return false;
2418
0
          }
2419
0
        }
2420
0
      }
2421
0
      temp.setObject(*returnArray);
2422
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->arguments_id, temp, JSPROP_ENUMERATE)) {
2423
0
        return false;
2424
0
      }
2425
0
      break;
2426
0
    } while(false);
2427
0
  }
2428
0
2429
0
  do {
2430
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2431
0
    JS::Rooted<JS::Value> temp(cx);
2432
0
    uint32_t const & currentValue = mColumnNumber;
2433
0
    temp.setNumber(currentValue);
2434
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->columnNumber_id, temp, JSPROP_ENUMERATE)) {
2435
0
      return false;
2436
0
    }
2437
0
    break;
2438
0
  } while(false);
2439
0
2440
0
  do {
2441
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2442
0
    JS::Rooted<JS::Value> temp(cx);
2443
0
    nsString const & currentValue = mConsoleID;
2444
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
2445
0
      return false;
2446
0
    }
2447
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->consoleID_id, temp, JSPROP_ENUMERATE)) {
2448
0
      return false;
2449
0
    }
2450
0
    break;
2451
0
  } while(false);
2452
0
2453
0
  do {
2454
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2455
0
    JS::Rooted<JS::Value> temp(cx);
2456
0
    JS::Value const & currentValue = mCounter;
2457
0
    JS::ExposeValueToActiveJS(currentValue);
2458
0
    temp.set(currentValue);
2459
0
    if (!MaybeWrapValue(cx, &temp)) {
2460
0
      return false;
2461
0
    }
2462
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->counter_id, temp, JSPROP_ENUMERATE)) {
2463
0
      return false;
2464
0
    }
2465
0
    break;
2466
0
  } while(false);
2467
0
2468
0
  do {
2469
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2470
0
    JS::Rooted<JS::Value> temp(cx);
2471
0
    nsString const & currentValue = mFilename;
2472
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
2473
0
      return false;
2474
0
    }
2475
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->filename_id, temp, JSPROP_ENUMERATE)) {
2476
0
      return false;
2477
0
    }
2478
0
    break;
2479
0
  } while(false);
2480
0
2481
0
  do {
2482
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2483
0
    JS::Rooted<JS::Value> temp(cx);
2484
0
    nsString const & currentValue = mFunctionName;
2485
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
2486
0
      return false;
2487
0
    }
2488
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->functionName_id, temp, JSPROP_ENUMERATE)) {
2489
0
      return false;
2490
0
    }
2491
0
    break;
2492
0
  } while(false);
2493
0
2494
0
  do {
2495
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2496
0
    JS::Rooted<JS::Value> temp(cx);
2497
0
    nsString const & currentValue = mGroupName;
2498
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
2499
0
      return false;
2500
0
    }
2501
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->groupName_id, temp, JSPROP_ENUMERATE)) {
2502
0
      return false;
2503
0
    }
2504
0
    break;
2505
0
  } while(false);
2506
0
2507
0
  if (mInnerID.WasPassed()) {
2508
0
    do {
2509
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2510
0
      JS::Rooted<JS::Value> temp(cx);
2511
0
      OwningUnsignedLongLongOrString const & currentValue = mInnerID.InternalValue();
2512
0
      if (!currentValue.ToJSVal(cx, obj, &temp)) {
2513
0
        return false;
2514
0
      }
2515
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->innerID_id, temp, JSPROP_ENUMERATE)) {
2516
0
        return false;
2517
0
      }
2518
0
      break;
2519
0
    } while(false);
2520
0
  }
2521
0
2522
0
  do {
2523
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2524
0
    JS::Rooted<JS::Value> temp(cx);
2525
0
    nsString const & currentValue = mLevel;
2526
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
2527
0
      return false;
2528
0
    }
2529
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->level_id, temp, JSPROP_ENUMERATE)) {
2530
0
      return false;
2531
0
    }
2532
0
    break;
2533
0
  } while(false);
2534
0
2535
0
  do {
2536
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2537
0
    JS::Rooted<JS::Value> temp(cx);
2538
0
    uint32_t const & currentValue = mLineNumber;
2539
0
    temp.setNumber(currentValue);
2540
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->lineNumber_id, temp, JSPROP_ENUMERATE)) {
2541
0
      return false;
2542
0
    }
2543
0
    break;
2544
0
  } while(false);
2545
0
2546
0
  do {
2547
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2548
0
    JS::Rooted<JS::Value> temp(cx);
2549
0
    nsString const & currentValue = mPrefix;
2550
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
2551
0
      return false;
2552
0
    }
2553
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->prefix_id, temp, JSPROP_ENUMERATE)) {
2554
0
      return false;
2555
0
    }
2556
0
    break;
2557
0
  } while(false);
2558
0
2559
0
  do {
2560
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2561
0
    JS::Rooted<JS::Value> temp(cx);
2562
0
    bool const & currentValue = mPrivate;
2563
0
    temp.setBoolean(currentValue);
2564
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->private_id, temp, JSPROP_ENUMERATE)) {
2565
0
      return false;
2566
0
    }
2567
0
    break;
2568
0
  } while(false);
2569
0
2570
0
  if (mStyles.WasPassed()) {
2571
0
    do {
2572
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2573
0
      JS::Rooted<JS::Value> temp(cx);
2574
0
      Sequence<nsString> const & currentValue = mStyles.InternalValue();
2575
0
2576
0
      uint32_t length = currentValue.Length();
2577
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
2578
0
      if (!returnArray) {
2579
0
        return false;
2580
0
      }
2581
0
      // Scope for 'tmp'
2582
0
      {
2583
0
        JS::Rooted<JS::Value> tmp(cx);
2584
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2585
0
          // Control block to let us common up the JS_DefineElement calls when there
2586
0
          // are different ways to succeed at wrapping the object.
2587
0
          do {
2588
0
            if (!xpc::StringToJsval(cx, currentValue[sequenceIdx0], &tmp)) {
2589
0
              return false;
2590
0
            }
2591
0
            break;
2592
0
          } while (false);
2593
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2594
0
                                JSPROP_ENUMERATE)) {
2595
0
            return false;
2596
0
          }
2597
0
        }
2598
0
      }
2599
0
      temp.setObject(*returnArray);
2600
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->styles_id, temp, JSPROP_ENUMERATE)) {
2601
0
        return false;
2602
0
      }
2603
0
      break;
2604
0
    } while(false);
2605
0
  }
2606
0
2607
0
  do {
2608
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2609
0
    JS::Rooted<JS::Value> temp(cx);
2610
0
    double const & currentValue = mTimeStamp;
2611
0
    temp.set(JS_NumberValue(double(currentValue)));
2612
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->timeStamp_id, temp, JSPROP_ENUMERATE)) {
2613
0
      return false;
2614
0
    }
2615
0
    break;
2616
0
  } while(false);
2617
0
2618
0
  do {
2619
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2620
0
    JS::Rooted<JS::Value> temp(cx);
2621
0
    JS::Value const & currentValue = mTimer;
2622
0
    JS::ExposeValueToActiveJS(currentValue);
2623
0
    temp.set(currentValue);
2624
0
    if (!MaybeWrapValue(cx, &temp)) {
2625
0
      return false;
2626
0
    }
2627
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->timer_id, temp, JSPROP_ENUMERATE)) {
2628
0
      return false;
2629
0
    }
2630
0
    break;
2631
0
  } while(false);
2632
0
2633
0
  return true;
2634
0
}
2635
2636
void
2637
ConsoleEvent::TraceDictionary(JSTracer* trc)
2638
0
{
2639
0
  if (mArguments.WasPassed()) {
2640
0
    DoTraceSequence(trc, mArguments.Value());
2641
0
  }
2642
0
2643
0
  JS::UnsafeTraceRoot(trc, &mCounter, "ConsoleEvent.mCounter");
2644
0
2645
0
  JS::UnsafeTraceRoot(trc, &mTimer, "ConsoleEvent.mTimer");
2646
0
}
2647
2648
namespace binding_detail {
2649
} // namespace binding_detail
2650
2651
2652
void
2653
ConsoleInstanceDumpCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& message, ErrorResult& aRv)
2654
0
{
2655
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
2656
0
  JS::AutoValueVector argv(cx);
2657
0
  if (!argv.resize(1)) {
2658
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
2659
0
    return;
2660
0
  }
2661
0
  unsigned argc = 1;
2662
0
2663
0
  do {
2664
0
    nsString mutableStr(message);
2665
0
    if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) {
2666
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
2667
0
      return;
2668
0
    }
2669
0
    break;
2670
0
  } while (false);
2671
0
2672
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
2673
0
  if (!JS::Call(cx, aThisVal, callable,
2674
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
2675
0
    aRv.NoteJSContextException(cx);
2676
0
    return;
2677
0
  }
2678
0
}
2679
2680
2681
2682
namespace binding_detail {
2683
} // namespace binding_detail
2684
2685
2686
namespace ConsoleInstance_Binding {
2687
2688
MOZ_CAN_RUN_SCRIPT static bool
2689
_assert_(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2690
0
{
2691
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.assert", DOM, cx);
2692
0
2693
0
  bool arg0;
2694
0
  if (args.hasDefined(0)) {
2695
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
2696
0
      return false;
2697
0
    }
2698
0
  } else {
2699
0
    arg0 = false;
2700
0
  }
2701
0
  AutoSequence<JS::Value> arg1;
2702
0
  SequenceRooter<JS::Value> arg1_holder(cx, &arg1);
2703
0
  if (args.length() > 1) {
2704
0
    if (!arg1.SetCapacity(args.length() - 1, mozilla::fallible)) {
2705
0
      JS_ReportOutOfMemory(cx);
2706
0
      return false;
2707
0
    }
2708
0
    for (uint32_t variadicArg = 1; variadicArg < args.length(); ++variadicArg) {
2709
0
      JS::Value& slot = *arg1.AppendElement(mozilla::fallible);
2710
0
      slot = args[variadicArg];
2711
0
    }
2712
0
  }
2713
0
  self->Assert(cx, arg0, Constify(arg1));
2714
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2715
0
  args.rval().setUndefined();
2716
0
  return true;
2717
0
}
2718
2719
static const JSJitInfo assert_methodinfo = {
2720
  { (JSJitGetterOp)_assert_ },
2721
  { prototypes::id::ConsoleInstance },
2722
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2723
  JSJitInfo::Method,
2724
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2725
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2726
  false,  /* isInfallible. False in setters. */
2727
  false,  /* isMovable.  Not relevant for setters. */
2728
  false, /* isEliminatable.  Not relevant for setters. */
2729
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2730
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2731
  false,  /* isTypedMethod.  Only relevant for methods. */
2732
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2733
};
2734
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2735
static_assert(0 < 1, "There is no slot for us");
2736
2737
MOZ_CAN_RUN_SCRIPT static bool
2738
clear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2739
0
{
2740
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.clear", DOM, cx);
2741
0
2742
0
  self->Clear(cx);
2743
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2744
0
  args.rval().setUndefined();
2745
0
  return true;
2746
0
}
2747
2748
static const JSJitInfo clear_methodinfo = {
2749
  { (JSJitGetterOp)clear },
2750
  { prototypes::id::ConsoleInstance },
2751
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2752
  JSJitInfo::Method,
2753
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2754
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2755
  true,  /* isInfallible. False in setters. */
2756
  false,  /* isMovable.  Not relevant for setters. */
2757
  false, /* isEliminatable.  Not relevant for setters. */
2758
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2759
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2760
  false,  /* isTypedMethod.  Only relevant for methods. */
2761
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2762
};
2763
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2764
static_assert(0 < 1, "There is no slot for us");
2765
2766
MOZ_CAN_RUN_SCRIPT static bool
2767
count(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2768
0
{
2769
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.count", DOM, cx);
2770
0
2771
0
  binding_detail::FakeString arg0;
2772
0
  if (args.hasDefined(0)) {
2773
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
2774
0
      return false;
2775
0
    }
2776
0
  } else {
2777
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
2778
0
    arg0.Rebind(data, ArrayLength(data) - 1);
2779
0
  }
2780
0
  self->Count(cx, NonNullHelper(Constify(arg0)));
2781
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2782
0
  args.rval().setUndefined();
2783
0
  return true;
2784
0
}
2785
2786
static const JSJitInfo count_methodinfo = {
2787
  { (JSJitGetterOp)count },
2788
  { prototypes::id::ConsoleInstance },
2789
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2790
  JSJitInfo::Method,
2791
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2792
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2793
  false,  /* isInfallible. False in setters. */
2794
  false,  /* isMovable.  Not relevant for setters. */
2795
  false, /* isEliminatable.  Not relevant for setters. */
2796
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2797
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2798
  false,  /* isTypedMethod.  Only relevant for methods. */
2799
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2800
};
2801
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2802
static_assert(0 < 1, "There is no slot for us");
2803
2804
MOZ_CAN_RUN_SCRIPT static bool
2805
countReset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2806
0
{
2807
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.countReset", DOM, cx);
2808
0
2809
0
  binding_detail::FakeString arg0;
2810
0
  if (args.hasDefined(0)) {
2811
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
2812
0
      return false;
2813
0
    }
2814
0
  } else {
2815
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
2816
0
    arg0.Rebind(data, ArrayLength(data) - 1);
2817
0
  }
2818
0
  self->CountReset(cx, NonNullHelper(Constify(arg0)));
2819
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2820
0
  args.rval().setUndefined();
2821
0
  return true;
2822
0
}
2823
2824
static const JSJitInfo countReset_methodinfo = {
2825
  { (JSJitGetterOp)countReset },
2826
  { prototypes::id::ConsoleInstance },
2827
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2828
  JSJitInfo::Method,
2829
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2830
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2831
  false,  /* isInfallible. False in setters. */
2832
  false,  /* isMovable.  Not relevant for setters. */
2833
  false, /* isEliminatable.  Not relevant for setters. */
2834
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2835
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2836
  false,  /* isTypedMethod.  Only relevant for methods. */
2837
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2838
};
2839
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2840
static_assert(0 < 1, "There is no slot for us");
2841
2842
MOZ_CAN_RUN_SCRIPT static bool
2843
debug(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2844
0
{
2845
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.debug", DOM, cx);
2846
0
2847
0
  AutoSequence<JS::Value> arg0;
2848
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
2849
0
  if (args.length() > 0) {
2850
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
2851
0
      JS_ReportOutOfMemory(cx);
2852
0
      return false;
2853
0
    }
2854
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
2855
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
2856
0
      slot = args[variadicArg];
2857
0
    }
2858
0
  }
2859
0
  self->Debug(cx, Constify(arg0));
2860
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2861
0
  args.rval().setUndefined();
2862
0
  return true;
2863
0
}
2864
2865
static const JSJitInfo debug_methodinfo = {
2866
  { (JSJitGetterOp)debug },
2867
  { prototypes::id::ConsoleInstance },
2868
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2869
  JSJitInfo::Method,
2870
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2871
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2872
  false,  /* isInfallible. False in setters. */
2873
  false,  /* isMovable.  Not relevant for setters. */
2874
  false, /* isEliminatable.  Not relevant for setters. */
2875
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2876
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2877
  false,  /* isTypedMethod.  Only relevant for methods. */
2878
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2879
};
2880
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2881
static_assert(0 < 1, "There is no slot for us");
2882
2883
MOZ_CAN_RUN_SCRIPT static bool
2884
error(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2885
0
{
2886
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.error", DOM, cx);
2887
0
2888
0
  AutoSequence<JS::Value> arg0;
2889
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
2890
0
  if (args.length() > 0) {
2891
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
2892
0
      JS_ReportOutOfMemory(cx);
2893
0
      return false;
2894
0
    }
2895
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
2896
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
2897
0
      slot = args[variadicArg];
2898
0
    }
2899
0
  }
2900
0
  self->Error(cx, Constify(arg0));
2901
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2902
0
  args.rval().setUndefined();
2903
0
  return true;
2904
0
}
2905
2906
static const JSJitInfo error_methodinfo = {
2907
  { (JSJitGetterOp)error },
2908
  { prototypes::id::ConsoleInstance },
2909
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2910
  JSJitInfo::Method,
2911
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2912
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2913
  false,  /* isInfallible. False in setters. */
2914
  false,  /* isMovable.  Not relevant for setters. */
2915
  false, /* isEliminatable.  Not relevant for setters. */
2916
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2917
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2918
  false,  /* isTypedMethod.  Only relevant for methods. */
2919
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2920
};
2921
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2922
static_assert(0 < 1, "There is no slot for us");
2923
2924
MOZ_CAN_RUN_SCRIPT static bool
2925
info(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2926
0
{
2927
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.info", DOM, cx);
2928
0
2929
0
  AutoSequence<JS::Value> arg0;
2930
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
2931
0
  if (args.length() > 0) {
2932
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
2933
0
      JS_ReportOutOfMemory(cx);
2934
0
      return false;
2935
0
    }
2936
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
2937
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
2938
0
      slot = args[variadicArg];
2939
0
    }
2940
0
  }
2941
0
  self->Info(cx, Constify(arg0));
2942
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2943
0
  args.rval().setUndefined();
2944
0
  return true;
2945
0
}
2946
2947
static const JSJitInfo info_methodinfo = {
2948
  { (JSJitGetterOp)info },
2949
  { prototypes::id::ConsoleInstance },
2950
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2951
  JSJitInfo::Method,
2952
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2953
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2954
  false,  /* isInfallible. False in setters. */
2955
  false,  /* isMovable.  Not relevant for setters. */
2956
  false, /* isEliminatable.  Not relevant for setters. */
2957
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2958
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2959
  false,  /* isTypedMethod.  Only relevant for methods. */
2960
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2961
};
2962
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2963
static_assert(0 < 1, "There is no slot for us");
2964
2965
MOZ_CAN_RUN_SCRIPT static bool
2966
log(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
2967
0
{
2968
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.log", DOM, cx);
2969
0
2970
0
  AutoSequence<JS::Value> arg0;
2971
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
2972
0
  if (args.length() > 0) {
2973
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
2974
0
      JS_ReportOutOfMemory(cx);
2975
0
      return false;
2976
0
    }
2977
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
2978
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
2979
0
      slot = args[variadicArg];
2980
0
    }
2981
0
  }
2982
0
  self->Log(cx, Constify(arg0));
2983
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2984
0
  args.rval().setUndefined();
2985
0
  return true;
2986
0
}
2987
2988
static const JSJitInfo log_methodinfo = {
2989
  { (JSJitGetterOp)log },
2990
  { prototypes::id::ConsoleInstance },
2991
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
2992
  JSJitInfo::Method,
2993
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2994
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2995
  false,  /* isInfallible. False in setters. */
2996
  false,  /* isMovable.  Not relevant for setters. */
2997
  false, /* isEliminatable.  Not relevant for setters. */
2998
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2999
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3000
  false,  /* isTypedMethod.  Only relevant for methods. */
3001
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3002
};
3003
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3004
static_assert(0 < 1, "There is no slot for us");
3005
3006
MOZ_CAN_RUN_SCRIPT static bool
3007
table(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3008
0
{
3009
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.table", DOM, cx);
3010
0
3011
0
  AutoSequence<JS::Value> arg0;
3012
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3013
0
  if (args.length() > 0) {
3014
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3015
0
      JS_ReportOutOfMemory(cx);
3016
0
      return false;
3017
0
    }
3018
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3019
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3020
0
      slot = args[variadicArg];
3021
0
    }
3022
0
  }
3023
0
  self->Table(cx, Constify(arg0));
3024
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3025
0
  args.rval().setUndefined();
3026
0
  return true;
3027
0
}
3028
3029
static const JSJitInfo table_methodinfo = {
3030
  { (JSJitGetterOp)table },
3031
  { prototypes::id::ConsoleInstance },
3032
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3033
  JSJitInfo::Method,
3034
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3035
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3036
  false,  /* isInfallible. False in setters. */
3037
  false,  /* isMovable.  Not relevant for setters. */
3038
  false, /* isEliminatable.  Not relevant for setters. */
3039
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3040
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3041
  false,  /* isTypedMethod.  Only relevant for methods. */
3042
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3043
};
3044
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3045
static_assert(0 < 1, "There is no slot for us");
3046
3047
MOZ_CAN_RUN_SCRIPT static bool
3048
trace(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3049
0
{
3050
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.trace", DOM, cx);
3051
0
3052
0
  AutoSequence<JS::Value> arg0;
3053
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3054
0
  if (args.length() > 0) {
3055
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3056
0
      JS_ReportOutOfMemory(cx);
3057
0
      return false;
3058
0
    }
3059
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3060
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3061
0
      slot = args[variadicArg];
3062
0
    }
3063
0
  }
3064
0
  self->Trace(cx, Constify(arg0));
3065
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3066
0
  args.rval().setUndefined();
3067
0
  return true;
3068
0
}
3069
3070
static const JSJitInfo trace_methodinfo = {
3071
  { (JSJitGetterOp)trace },
3072
  { prototypes::id::ConsoleInstance },
3073
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3074
  JSJitInfo::Method,
3075
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3076
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3077
  false,  /* isInfallible. False in setters. */
3078
  false,  /* isMovable.  Not relevant for setters. */
3079
  false, /* isEliminatable.  Not relevant for setters. */
3080
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3081
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3082
  false,  /* isTypedMethod.  Only relevant for methods. */
3083
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3084
};
3085
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3086
static_assert(0 < 1, "There is no slot for us");
3087
3088
MOZ_CAN_RUN_SCRIPT static bool
3089
warn(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3090
0
{
3091
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.warn", DOM, cx);
3092
0
3093
0
  AutoSequence<JS::Value> arg0;
3094
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3095
0
  if (args.length() > 0) {
3096
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3097
0
      JS_ReportOutOfMemory(cx);
3098
0
      return false;
3099
0
    }
3100
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3101
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3102
0
      slot = args[variadicArg];
3103
0
    }
3104
0
  }
3105
0
  self->Warn(cx, Constify(arg0));
3106
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3107
0
  args.rval().setUndefined();
3108
0
  return true;
3109
0
}
3110
3111
static const JSJitInfo warn_methodinfo = {
3112
  { (JSJitGetterOp)warn },
3113
  { prototypes::id::ConsoleInstance },
3114
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3115
  JSJitInfo::Method,
3116
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3117
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3118
  false,  /* isInfallible. False in setters. */
3119
  false,  /* isMovable.  Not relevant for setters. */
3120
  false, /* isEliminatable.  Not relevant for setters. */
3121
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3122
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3123
  false,  /* isTypedMethod.  Only relevant for methods. */
3124
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3125
};
3126
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3127
static_assert(0 < 1, "There is no slot for us");
3128
3129
MOZ_CAN_RUN_SCRIPT static bool
3130
dir(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3131
0
{
3132
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.dir", DOM, cx);
3133
0
3134
0
  AutoSequence<JS::Value> arg0;
3135
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3136
0
  if (args.length() > 0) {
3137
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3138
0
      JS_ReportOutOfMemory(cx);
3139
0
      return false;
3140
0
    }
3141
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3142
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3143
0
      slot = args[variadicArg];
3144
0
    }
3145
0
  }
3146
0
  self->Dir(cx, Constify(arg0));
3147
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3148
0
  args.rval().setUndefined();
3149
0
  return true;
3150
0
}
3151
3152
static const JSJitInfo dir_methodinfo = {
3153
  { (JSJitGetterOp)dir },
3154
  { prototypes::id::ConsoleInstance },
3155
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3156
  JSJitInfo::Method,
3157
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3158
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3159
  false,  /* isInfallible. False in setters. */
3160
  false,  /* isMovable.  Not relevant for setters. */
3161
  false, /* isEliminatable.  Not relevant for setters. */
3162
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3163
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3164
  false,  /* isTypedMethod.  Only relevant for methods. */
3165
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3166
};
3167
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3168
static_assert(0 < 1, "There is no slot for us");
3169
3170
MOZ_CAN_RUN_SCRIPT static bool
3171
dirxml(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3172
0
{
3173
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.dirxml", DOM, cx);
3174
0
3175
0
  AutoSequence<JS::Value> arg0;
3176
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3177
0
  if (args.length() > 0) {
3178
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3179
0
      JS_ReportOutOfMemory(cx);
3180
0
      return false;
3181
0
    }
3182
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3183
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3184
0
      slot = args[variadicArg];
3185
0
    }
3186
0
  }
3187
0
  self->Dirxml(cx, Constify(arg0));
3188
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3189
0
  args.rval().setUndefined();
3190
0
  return true;
3191
0
}
3192
3193
static const JSJitInfo dirxml_methodinfo = {
3194
  { (JSJitGetterOp)dirxml },
3195
  { prototypes::id::ConsoleInstance },
3196
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3197
  JSJitInfo::Method,
3198
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3199
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3200
  false,  /* isInfallible. False in setters. */
3201
  false,  /* isMovable.  Not relevant for setters. */
3202
  false, /* isEliminatable.  Not relevant for setters. */
3203
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3204
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3205
  false,  /* isTypedMethod.  Only relevant for methods. */
3206
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3207
};
3208
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3209
static_assert(0 < 1, "There is no slot for us");
3210
3211
MOZ_CAN_RUN_SCRIPT static bool
3212
group(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3213
0
{
3214
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.group", DOM, cx);
3215
0
3216
0
  AutoSequence<JS::Value> arg0;
3217
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3218
0
  if (args.length() > 0) {
3219
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3220
0
      JS_ReportOutOfMemory(cx);
3221
0
      return false;
3222
0
    }
3223
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3224
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3225
0
      slot = args[variadicArg];
3226
0
    }
3227
0
  }
3228
0
  self->Group(cx, Constify(arg0));
3229
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3230
0
  args.rval().setUndefined();
3231
0
  return true;
3232
0
}
3233
3234
static const JSJitInfo group_methodinfo = {
3235
  { (JSJitGetterOp)group },
3236
  { prototypes::id::ConsoleInstance },
3237
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3238
  JSJitInfo::Method,
3239
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3240
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3241
  false,  /* isInfallible. False in setters. */
3242
  false,  /* isMovable.  Not relevant for setters. */
3243
  false, /* isEliminatable.  Not relevant for setters. */
3244
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3245
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3246
  false,  /* isTypedMethod.  Only relevant for methods. */
3247
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3248
};
3249
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3250
static_assert(0 < 1, "There is no slot for us");
3251
3252
MOZ_CAN_RUN_SCRIPT static bool
3253
groupCollapsed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3254
0
{
3255
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.groupCollapsed", DOM, cx);
3256
0
3257
0
  AutoSequence<JS::Value> arg0;
3258
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3259
0
  if (args.length() > 0) {
3260
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3261
0
      JS_ReportOutOfMemory(cx);
3262
0
      return false;
3263
0
    }
3264
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3265
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3266
0
      slot = args[variadicArg];
3267
0
    }
3268
0
  }
3269
0
  self->GroupCollapsed(cx, Constify(arg0));
3270
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3271
0
  args.rval().setUndefined();
3272
0
  return true;
3273
0
}
3274
3275
static const JSJitInfo groupCollapsed_methodinfo = {
3276
  { (JSJitGetterOp)groupCollapsed },
3277
  { prototypes::id::ConsoleInstance },
3278
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3279
  JSJitInfo::Method,
3280
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3281
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3282
  false,  /* isInfallible. False in setters. */
3283
  false,  /* isMovable.  Not relevant for setters. */
3284
  false, /* isEliminatable.  Not relevant for setters. */
3285
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3286
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3287
  false,  /* isTypedMethod.  Only relevant for methods. */
3288
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3289
};
3290
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3291
static_assert(0 < 1, "There is no slot for us");
3292
3293
MOZ_CAN_RUN_SCRIPT static bool
3294
groupEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3295
0
{
3296
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.groupEnd", DOM, cx);
3297
0
3298
0
  self->GroupEnd(cx);
3299
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3300
0
  args.rval().setUndefined();
3301
0
  return true;
3302
0
}
3303
3304
static const JSJitInfo groupEnd_methodinfo = {
3305
  { (JSJitGetterOp)groupEnd },
3306
  { prototypes::id::ConsoleInstance },
3307
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3308
  JSJitInfo::Method,
3309
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3310
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3311
  true,  /* isInfallible. False in setters. */
3312
  false,  /* isMovable.  Not relevant for setters. */
3313
  false, /* isEliminatable.  Not relevant for setters. */
3314
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3315
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3316
  false,  /* isTypedMethod.  Only relevant for methods. */
3317
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3318
};
3319
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3320
static_assert(0 < 1, "There is no slot for us");
3321
3322
MOZ_CAN_RUN_SCRIPT static bool
3323
time(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3324
0
{
3325
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.time", DOM, cx);
3326
0
3327
0
  binding_detail::FakeString arg0;
3328
0
  if (args.hasDefined(0)) {
3329
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3330
0
      return false;
3331
0
    }
3332
0
  } else {
3333
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
3334
0
    arg0.Rebind(data, ArrayLength(data) - 1);
3335
0
  }
3336
0
  self->Time(cx, NonNullHelper(Constify(arg0)));
3337
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3338
0
  args.rval().setUndefined();
3339
0
  return true;
3340
0
}
3341
3342
static const JSJitInfo time_methodinfo = {
3343
  { (JSJitGetterOp)time },
3344
  { prototypes::id::ConsoleInstance },
3345
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3346
  JSJitInfo::Method,
3347
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3348
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3349
  false,  /* isInfallible. False in setters. */
3350
  false,  /* isMovable.  Not relevant for setters. */
3351
  false, /* isEliminatable.  Not relevant for setters. */
3352
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3353
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3354
  false,  /* isTypedMethod.  Only relevant for methods. */
3355
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3356
};
3357
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3358
static_assert(0 < 1, "There is no slot for us");
3359
3360
MOZ_CAN_RUN_SCRIPT static bool
3361
timeLog(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3362
0
{
3363
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.timeLog", DOM, cx);
3364
0
3365
0
  binding_detail::FakeString arg0;
3366
0
  if (args.hasDefined(0)) {
3367
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3368
0
      return false;
3369
0
    }
3370
0
  } else {
3371
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
3372
0
    arg0.Rebind(data, ArrayLength(data) - 1);
3373
0
  }
3374
0
  AutoSequence<JS::Value> arg1;
3375
0
  SequenceRooter<JS::Value> arg1_holder(cx, &arg1);
3376
0
  if (args.length() > 1) {
3377
0
    if (!arg1.SetCapacity(args.length() - 1, mozilla::fallible)) {
3378
0
      JS_ReportOutOfMemory(cx);
3379
0
      return false;
3380
0
    }
3381
0
    for (uint32_t variadicArg = 1; variadicArg < args.length(); ++variadicArg) {
3382
0
      JS::Value& slot = *arg1.AppendElement(mozilla::fallible);
3383
0
      slot = args[variadicArg];
3384
0
    }
3385
0
  }
3386
0
  self->TimeLog(cx, NonNullHelper(Constify(arg0)), Constify(arg1));
3387
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3388
0
  args.rval().setUndefined();
3389
0
  return true;
3390
0
}
3391
3392
static const JSJitInfo timeLog_methodinfo = {
3393
  { (JSJitGetterOp)timeLog },
3394
  { prototypes::id::ConsoleInstance },
3395
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3396
  JSJitInfo::Method,
3397
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3398
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3399
  false,  /* isInfallible. False in setters. */
3400
  false,  /* isMovable.  Not relevant for setters. */
3401
  false, /* isEliminatable.  Not relevant for setters. */
3402
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3403
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3404
  false,  /* isTypedMethod.  Only relevant for methods. */
3405
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3406
};
3407
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3408
static_assert(0 < 1, "There is no slot for us");
3409
3410
MOZ_CAN_RUN_SCRIPT static bool
3411
timeEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3412
0
{
3413
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.timeEnd", DOM, cx);
3414
0
3415
0
  binding_detail::FakeString arg0;
3416
0
  if (args.hasDefined(0)) {
3417
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3418
0
      return false;
3419
0
    }
3420
0
  } else {
3421
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
3422
0
    arg0.Rebind(data, ArrayLength(data) - 1);
3423
0
  }
3424
0
  self->TimeEnd(cx, NonNullHelper(Constify(arg0)));
3425
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3426
0
  args.rval().setUndefined();
3427
0
  return true;
3428
0
}
3429
3430
static const JSJitInfo timeEnd_methodinfo = {
3431
  { (JSJitGetterOp)timeEnd },
3432
  { prototypes::id::ConsoleInstance },
3433
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3434
  JSJitInfo::Method,
3435
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3436
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3437
  false,  /* isInfallible. False in setters. */
3438
  false,  /* isMovable.  Not relevant for setters. */
3439
  false, /* isEliminatable.  Not relevant for setters. */
3440
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3441
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3442
  false,  /* isTypedMethod.  Only relevant for methods. */
3443
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3444
};
3445
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3446
static_assert(0 < 1, "There is no slot for us");
3447
3448
MOZ_CAN_RUN_SCRIPT static bool
3449
exception(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3450
0
{
3451
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.exception", DOM, cx);
3452
0
3453
0
  AutoSequence<JS::Value> arg0;
3454
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3455
0
  if (args.length() > 0) {
3456
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3457
0
      JS_ReportOutOfMemory(cx);
3458
0
      return false;
3459
0
    }
3460
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3461
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3462
0
      slot = args[variadicArg];
3463
0
    }
3464
0
  }
3465
0
  self->Exception(cx, Constify(arg0));
3466
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3467
0
  args.rval().setUndefined();
3468
0
  return true;
3469
0
}
3470
3471
static const JSJitInfo exception_methodinfo = {
3472
  { (JSJitGetterOp)exception },
3473
  { prototypes::id::ConsoleInstance },
3474
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3475
  JSJitInfo::Method,
3476
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3477
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3478
  false,  /* isInfallible. False in setters. */
3479
  false,  /* isMovable.  Not relevant for setters. */
3480
  false, /* isEliminatable.  Not relevant for setters. */
3481
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3482
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3483
  false,  /* isTypedMethod.  Only relevant for methods. */
3484
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3485
};
3486
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3487
static_assert(0 < 1, "There is no slot for us");
3488
3489
MOZ_CAN_RUN_SCRIPT static bool
3490
timeStamp(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3491
0
{
3492
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.timeStamp", DOM, cx);
3493
0
3494
0
  JS::Rooted<JS::Value> arg0(cx);
3495
0
  if (args.hasDefined(0)) {
3496
0
    arg0 = args[0];
3497
0
  } else {
3498
0
    arg0 = JS::UndefinedValue();
3499
0
  }
3500
0
  self->TimeStamp(cx, arg0);
3501
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3502
0
  args.rval().setUndefined();
3503
0
  return true;
3504
0
}
3505
3506
static const JSJitInfo timeStamp_methodinfo = {
3507
  { (JSJitGetterOp)timeStamp },
3508
  { prototypes::id::ConsoleInstance },
3509
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3510
  JSJitInfo::Method,
3511
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3512
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3513
  false,  /* isInfallible. False in setters. */
3514
  false,  /* isMovable.  Not relevant for setters. */
3515
  false, /* isEliminatable.  Not relevant for setters. */
3516
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3517
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3518
  false,  /* isTypedMethod.  Only relevant for methods. */
3519
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3520
};
3521
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3522
static_assert(0 < 1, "There is no slot for us");
3523
3524
MOZ_CAN_RUN_SCRIPT static bool
3525
profile(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3526
0
{
3527
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.profile", DOM, cx);
3528
0
3529
0
  AutoSequence<JS::Value> arg0;
3530
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3531
0
  if (args.length() > 0) {
3532
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3533
0
      JS_ReportOutOfMemory(cx);
3534
0
      return false;
3535
0
    }
3536
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3537
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3538
0
      slot = args[variadicArg];
3539
0
    }
3540
0
  }
3541
0
  self->Profile(cx, Constify(arg0));
3542
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3543
0
  args.rval().setUndefined();
3544
0
  return true;
3545
0
}
3546
3547
static const JSJitInfo profile_methodinfo = {
3548
  { (JSJitGetterOp)profile },
3549
  { prototypes::id::ConsoleInstance },
3550
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3551
  JSJitInfo::Method,
3552
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3553
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3554
  false,  /* isInfallible. False in setters. */
3555
  false,  /* isMovable.  Not relevant for setters. */
3556
  false, /* isEliminatable.  Not relevant for setters. */
3557
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3558
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3559
  false,  /* isTypedMethod.  Only relevant for methods. */
3560
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3561
};
3562
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3563
static_assert(0 < 1, "There is no slot for us");
3564
3565
MOZ_CAN_RUN_SCRIPT static bool
3566
profileEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3567
0
{
3568
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.profileEnd", DOM, cx);
3569
0
3570
0
  AutoSequence<JS::Value> arg0;
3571
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
3572
0
  if (args.length() > 0) {
3573
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
3574
0
      JS_ReportOutOfMemory(cx);
3575
0
      return false;
3576
0
    }
3577
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
3578
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
3579
0
      slot = args[variadicArg];
3580
0
    }
3581
0
  }
3582
0
  self->ProfileEnd(cx, Constify(arg0));
3583
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3584
0
  args.rval().setUndefined();
3585
0
  return true;
3586
0
}
3587
3588
static const JSJitInfo profileEnd_methodinfo = {
3589
  { (JSJitGetterOp)profileEnd },
3590
  { prototypes::id::ConsoleInstance },
3591
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3592
  JSJitInfo::Method,
3593
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3594
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3595
  false,  /* isInfallible. False in setters. */
3596
  false,  /* isMovable.  Not relevant for setters. */
3597
  false, /* isEliminatable.  Not relevant for setters. */
3598
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3599
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3600
  false,  /* isTypedMethod.  Only relevant for methods. */
3601
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3602
};
3603
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3604
static_assert(0 < 1, "There is no slot for us");
3605
3606
MOZ_CAN_RUN_SCRIPT static bool
3607
reportForServiceWorkerScope(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConsoleInstance* self, const JSJitMethodCallArgs& args)
3608
0
{
3609
0
  AUTO_PROFILER_LABEL_FAST("ConsoleInstance.reportForServiceWorkerScope", DOM, cx);
3610
0
3611
0
  if (MOZ_UNLIKELY(args.length() < 6)) {
3612
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ConsoleInstance.reportForServiceWorkerScope");
3613
0
  }
3614
0
  binding_detail::FakeString arg0;
3615
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3616
0
    return false;
3617
0
  }
3618
0
  binding_detail::FakeString arg1;
3619
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
3620
0
    return false;
3621
0
  }
3622
0
  binding_detail::FakeString arg2;
3623
0
  if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
3624
0
    return false;
3625
0
  }
3626
0
  uint32_t arg3;
3627
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[3], &arg3)) {
3628
0
    return false;
3629
0
  }
3630
0
  uint32_t arg4;
3631
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[4], &arg4)) {
3632
0
    return false;
3633
0
  }
3634
0
  ConsoleLevel arg5;
3635
0
  {
3636
0
    int index;
3637
0
    if (!FindEnumStringIndex<true>(cx, args[5], ConsoleLevelValues::strings, "ConsoleLevel", "Argument 6 of ConsoleInstance.reportForServiceWorkerScope", &index)) {
3638
0
      return false;
3639
0
    }
3640
0
    MOZ_ASSERT(index >= 0);
3641
0
    arg5 = static_cast<ConsoleLevel>(index);
3642
0
  }
3643
0
  self->ReportForServiceWorkerScope(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), arg3, arg4, arg5);
3644
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3645
0
  args.rval().setUndefined();
3646
0
  return true;
3647
0
}
3648
3649
static const JSJitInfo reportForServiceWorkerScope_methodinfo = {
3650
  { (JSJitGetterOp)reportForServiceWorkerScope },
3651
  { prototypes::id::ConsoleInstance },
3652
  { PrototypeTraits<prototypes::id::ConsoleInstance>::Depth },
3653
  JSJitInfo::Method,
3654
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3655
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3656
  false,  /* isInfallible. False in setters. */
3657
  false,  /* isMovable.  Not relevant for setters. */
3658
  false, /* isEliminatable.  Not relevant for setters. */
3659
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3660
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3661
  false,  /* isTypedMethod.  Only relevant for methods. */
3662
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3663
};
3664
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3665
static_assert(0 < 1, "There is no slot for us");
3666
3667
static bool
3668
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
3669
0
{
3670
0
  mozilla::dom::ConsoleInstance* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ConsoleInstance>(obj);
3671
0
  // We don't want to preserve if we don't have a wrapper, and we
3672
0
  // obviously can't preserve if we're not initialized.
3673
0
  if (self && self->GetWrapperPreserveColor()) {
3674
0
    PreserveWrapper(self);
3675
0
  }
3676
0
  return true;
3677
0
}
3678
3679
static void
3680
_finalize(js::FreeOp* fop, JSObject* obj)
3681
0
{
3682
0
  mozilla::dom::ConsoleInstance* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ConsoleInstance>(obj);
3683
0
  if (self) {
3684
0
    ClearWrapper(self, self, obj);
3685
0
    AddForDeferredFinalization<mozilla::dom::ConsoleInstance>(self);
3686
0
  }
3687
0
}
3688
3689
static size_t
3690
_objectMoved(JSObject* obj, JSObject* old)
3691
0
{
3692
0
  mozilla::dom::ConsoleInstance* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ConsoleInstance>(obj);
3693
0
  if (self) {
3694
0
    UpdateWrapper(self, self, obj, old);
3695
0
  }
3696
0
3697
0
  return 0;
3698
0
}
3699
3700
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3701
#if defined(__clang__)
3702
#pragma clang diagnostic push
3703
#pragma clang diagnostic ignored "-Wmissing-braces"
3704
#endif
3705
static const JSFunctionSpec sMethods_specs[] = {
3706
  JS_FNSPEC("assert", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&assert_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3707
  JS_FNSPEC("clear", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clear_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3708
  JS_FNSPEC("count", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&count_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3709
  JS_FNSPEC("countReset", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&countReset_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3710
  JS_FNSPEC("debug", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&debug_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3711
  JS_FNSPEC("error", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&error_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3712
  JS_FNSPEC("info", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&info_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3713
  JS_FNSPEC("log", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&log_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3714
  JS_FNSPEC("table", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&table_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3715
  JS_FNSPEC("trace", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&trace_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3716
  JS_FNSPEC("warn", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&warn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3717
  JS_FNSPEC("dir", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&dir_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3718
  JS_FNSPEC("dirxml", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&dirxml_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3719
  JS_FNSPEC("group", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&group_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3720
  JS_FNSPEC("groupCollapsed", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&groupCollapsed_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3721
  JS_FNSPEC("groupEnd", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&groupEnd_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3722
  JS_FNSPEC("time", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&time_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3723
  JS_FNSPEC("timeLog", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&timeLog_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3724
  JS_FNSPEC("timeEnd", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&timeEnd_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3725
  JS_FNSPEC("exception", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&exception_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3726
  JS_FNSPEC("timeStamp", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&timeStamp_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3727
  JS_FNSPEC("profile", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&profile_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3728
  JS_FNSPEC("profileEnd", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&profileEnd_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3729
  JS_FS_END
3730
};
3731
#if defined(__clang__)
3732
#pragma clang diagnostic pop
3733
#endif
3734
3735
3736
static const Prefable<const JSFunctionSpec> sMethods[] = {
3737
  { nullptr, &sMethods_specs[0] },
3738
  { nullptr, nullptr }
3739
};
3740
3741
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3742
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3743
static_assert(23 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3744
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3745
3746
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3747
#if defined(__clang__)
3748
#pragma clang diagnostic push
3749
#pragma clang diagnostic ignored "-Wmissing-braces"
3750
#endif
3751
static const JSFunctionSpec sChromeMethods_specs[] = {
3752
  JS_FNSPEC("reportForServiceWorkerScope", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&reportForServiceWorkerScope_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
3753
  JS_FS_END
3754
};
3755
#if defined(__clang__)
3756
#pragma clang diagnostic pop
3757
#endif
3758
3759
3760
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
3761
  { nullptr, &sChromeMethods_specs[0] },
3762
  { nullptr, nullptr }
3763
};
3764
3765
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3766
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3767
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3768
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3769
3770
3771
static uint16_t sNativeProperties_sortedPropertyIndices[23];
3772
static PropertyInfo sNativeProperties_propertyInfos[23];
3773
3774
static const NativePropertiesN<1> sNativeProperties = {
3775
  false, 0,
3776
  false, 0,
3777
  true,  0 /* sMethods */,
3778
  false, 0,
3779
  false, 0,
3780
  false, 0,
3781
  false, 0,
3782
  -1,
3783
  23,
3784
  sNativeProperties_sortedPropertyIndices,
3785
  {
3786
    { sMethods, &sNativeProperties_propertyInfos[0] }
3787
  }
3788
};
3789
static_assert(23 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
3790
    "We have a property info count that is oversized");
3791
3792
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
3793
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
3794
3795
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
3796
  false, 0,
3797
  false, 0,
3798
  true,  0 /* sChromeMethods */,
3799
  false, 0,
3800
  false, 0,
3801
  false, 0,
3802
  false, 0,
3803
  -1,
3804
  1,
3805
  sChromeOnlyNativeProperties_sortedPropertyIndices,
3806
  {
3807
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
3808
  }
3809
};
3810
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
3811
    "We have a property info count that is oversized");
3812
3813
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
3814
  {
3815
    "Function",
3816
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
3817
    &sBoringInterfaceObjectClassClassOps,
3818
    JS_NULL_CLASS_SPEC,
3819
    JS_NULL_CLASS_EXT,
3820
    &sInterfaceObjectClassObjectOps
3821
  },
3822
  eInterface,
3823
  true,
3824
  prototypes::id::ConsoleInstance,
3825
  PrototypeTraits<prototypes::id::ConsoleInstance>::Depth,
3826
  sNativePropertyHooks,
3827
  "function ConsoleInstance() {\n    [native code]\n}",
3828
  JS::GetRealmFunctionPrototype
3829
};
3830
3831
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
3832
  {
3833
    "ConsoleInstancePrototype",
3834
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
3835
    JS_NULL_CLASS_OPS,
3836
    JS_NULL_CLASS_SPEC,
3837
    JS_NULL_CLASS_EXT,
3838
    JS_NULL_OBJECT_OPS
3839
  },
3840
  eInterfacePrototype,
3841
  false,
3842
  prototypes::id::ConsoleInstance,
3843
  PrototypeTraits<prototypes::id::ConsoleInstance>::Depth,
3844
  sNativePropertyHooks,
3845
  "[object ConsoleInstancePrototype]",
3846
  JS::GetRealmObjectPrototype
3847
};
3848
3849
bool
3850
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
3851
0
{
3852
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
3853
0
}
3854
3855
static const js::ClassOps sClassOps = {
3856
  _addProperty, /* addProperty */
3857
  nullptr,               /* delProperty */
3858
  nullptr,               /* enumerate */
3859
  nullptr, /* newEnumerate */
3860
  nullptr, /* resolve */
3861
  nullptr, /* mayResolve */
3862
  _finalize, /* finalize */
3863
  nullptr, /* call */
3864
  nullptr,               /* hasInstance */
3865
  nullptr,               /* construct */
3866
  nullptr, /* trace */
3867
};
3868
3869
static const js::ClassExtension sClassExtension = {
3870
  nullptr, /* weakmapKeyDelegateOp */
3871
  _objectMoved /* objectMovedOp */
3872
};
3873
3874
static const DOMJSClass sClass = {
3875
  { "ConsoleInstance",
3876
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
3877
    &sClassOps,
3878
    JS_NULL_CLASS_SPEC,
3879
    &sClassExtension,
3880
    JS_NULL_OBJECT_OPS
3881
  },
3882
  { prototypes::id::ConsoleInstance, 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 },
3883
  IsBaseOf<nsISupports, mozilla::dom::ConsoleInstance >::value,
3884
  sNativePropertyHooks,
3885
  FindAssociatedGlobalForNative<mozilla::dom::ConsoleInstance>::Get,
3886
  GetProtoObjectHandle,
3887
  GetCCParticipant<mozilla::dom::ConsoleInstance>::Get()
3888
};
3889
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
3890
              "Must have the right minimal number of reserved slots.");
3891
static_assert(1 >= 1,
3892
              "Must have enough reserved slots.");
3893
3894
const JSClass*
3895
GetJSClass()
3896
0
{
3897
0
  return sClass.ToJSClass();
3898
0
}
3899
3900
bool
3901
Wrap(JSContext* aCx, mozilla::dom::ConsoleInstance* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
3902
0
{
3903
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ConsoleInstance>::value,
3904
0
                "Shouldn't have wrappercached things that are not refcounted.");
3905
0
  MOZ_ASSERT(static_cast<mozilla::dom::ConsoleInstance*>(aObject) ==
3906
0
             reinterpret_cast<mozilla::dom::ConsoleInstance*>(aObject),
3907
0
             "Multiple inheritance for mozilla::dom::ConsoleInstance is broken.");
3908
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
3909
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
3910
0
  MOZ_ASSERT(!aCache->GetWrapper(),
3911
0
             "You should probably not be using Wrap() directly; use "
3912
0
             "GetOrCreateDOMReflector instead");
3913
0
3914
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
3915
0
             "nsISupports must be on our primary inheritance chain");
3916
0
3917
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
3918
0
  if (!global) {
3919
0
    return false;
3920
0
  }
3921
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
3922
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
3923
0
3924
0
  // That might have ended up wrapping us already, due to the wonders
3925
0
  // of XBL.  Check for that, and bail out as needed.
3926
0
  aReflector.set(aCache->GetWrapper());
3927
0
  if (aReflector) {
3928
#ifdef DEBUG
3929
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
3930
#endif // DEBUG
3931
    return true;
3932
0
  }
3933
0
3934
0
  JSAutoRealm ar(aCx, global);
3935
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
3936
0
  if (!canonicalProto) {
3937
0
    return false;
3938
0
  }
3939
0
  JS::Rooted<JSObject*> proto(aCx);
3940
0
  if (aGivenProto) {
3941
0
    proto = aGivenProto;
3942
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
3943
0
    // coming in, we changed compartments to that of "parent" so may need
3944
0
    // to wrap the proto here.
3945
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
3946
0
      if (!JS_WrapObject(aCx, &proto)) {
3947
0
        return false;
3948
0
      }
3949
0
    }
3950
0
  } else {
3951
0
    proto = canonicalProto;
3952
0
  }
3953
0
3954
0
  BindingJSObjectCreator<mozilla::dom::ConsoleInstance> creator(aCx);
3955
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
3956
0
  if (!aReflector) {
3957
0
    return false;
3958
0
  }
3959
0
3960
0
  aCache->SetWrapper(aReflector);
3961
0
  creator.InitializationSucceeded();
3962
0
3963
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
3964
0
             aCache->GetWrapperPreserveColor() == aReflector);
3965
0
  // If proto != canonicalProto, we have to preserve our wrapper;
3966
0
  // otherwise we won't be able to properly recreate it later, since
3967
0
  // we won't know what proto to use.  Note that we don't check
3968
0
  // aGivenProto here, since it's entirely possible (and even
3969
0
  // somewhat common) to have a non-null aGivenProto which is the
3970
0
  // same as canonicalProto.
3971
0
  if (proto != canonicalProto) {
3972
0
    PreserveWrapper(aObject);
3973
0
  }
3974
0
3975
0
  return true;
3976
0
}
3977
3978
const NativePropertyHooks sNativePropertyHooks[] = { {
3979
  nullptr,
3980
  nullptr,
3981
  nullptr,
3982
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
3983
  prototypes::id::ConsoleInstance,
3984
  constructors::id::ConsoleInstance,
3985
  nullptr,
3986
  &DefaultXrayExpandoObjectClass
3987
} };
3988
3989
void
3990
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
3991
0
{
3992
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
3993
0
  if (!parentProto) {
3994
0
    return;
3995
0
  }
3996
0
3997
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
3998
0
  if (!constructorProto) {
3999
0
    return;
4000
0
  }
4001
0
4002
0
  static bool sIdsInited = false;
4003
0
  if (!sIdsInited && NS_IsMainThread()) {
4004
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
4005
0
      return;
4006
0
    }
4007
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
4008
0
      return;
4009
0
    }
4010
0
    sIdsInited = true;
4011
0
  }
4012
0
4013
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ConsoleInstance);
4014
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ConsoleInstance);
4015
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
4016
0
                              &sPrototypeClass.mBase, protoCache,
4017
0
                              nullptr,
4018
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
4019
0
                              interfaceCache,
4020
0
                              sNativeProperties.Upcast(),
4021
0
                              sChromeOnlyNativeProperties.Upcast(),
4022
0
                              "ConsoleInstance", aDefineOnGlobal,
4023
0
                              nullptr,
4024
0
                              false);
4025
0
}
4026
4027
JSObject*
4028
GetConstructorObject(JSContext* aCx)
4029
0
{
4030
0
  return GetConstructorObjectHandle(aCx);
4031
0
}
4032
4033
} // namespace ConsoleInstance_Binding
4034
4035
4036
4037
namespace console_Binding {
4038
4039
static bool
4040
_assert_(JSContext* cx, unsigned argc, JS::Value* vp)
4041
0
{
4042
0
  AUTO_PROFILER_LABEL_FAST("console.assert", DOM, cx);
4043
0
4044
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4045
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4046
0
4047
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4048
0
  if (global.Failed()) {
4049
0
    return false;
4050
0
  }
4051
0
4052
0
  bool arg0;
4053
0
  if (args.hasDefined(0)) {
4054
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
4055
0
      return false;
4056
0
    }
4057
0
  } else {
4058
0
    arg0 = false;
4059
0
  }
4060
0
  AutoSequence<JS::Value> arg1;
4061
0
  SequenceRooter<JS::Value> arg1_holder(cx, &arg1);
4062
0
  if (args.length() > 1) {
4063
0
    if (!arg1.SetCapacity(args.length() - 1, mozilla::fallible)) {
4064
0
      JS_ReportOutOfMemory(cx);
4065
0
      return false;
4066
0
    }
4067
0
    for (uint32_t variadicArg = 1; variadicArg < args.length(); ++variadicArg) {
4068
0
      JS::Value& slot = *arg1.AppendElement(mozilla::fallible);
4069
0
      slot = args[variadicArg];
4070
0
    }
4071
0
  }
4072
0
  mozilla::dom::Console::Assert(global, arg0, Constify(arg1));
4073
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4074
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_assert);
4075
0
  args.rval().setUndefined();
4076
0
  return true;
4077
0
}
4078
4079
static bool
4080
clear(JSContext* cx, unsigned argc, JS::Value* vp)
4081
0
{
4082
0
  AUTO_PROFILER_LABEL_FAST("console.clear", DOM, cx);
4083
0
4084
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4085
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4086
0
4087
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4088
0
  if (global.Failed()) {
4089
0
    return false;
4090
0
  }
4091
0
4092
0
  mozilla::dom::Console::Clear(global);
4093
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4094
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_clear);
4095
0
  args.rval().setUndefined();
4096
0
  return true;
4097
0
}
4098
4099
static bool
4100
count(JSContext* cx, unsigned argc, JS::Value* vp)
4101
0
{
4102
0
  AUTO_PROFILER_LABEL_FAST("console.count", DOM, cx);
4103
0
4104
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4105
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4106
0
4107
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4108
0
  if (global.Failed()) {
4109
0
    return false;
4110
0
  }
4111
0
4112
0
  binding_detail::FakeString arg0;
4113
0
  if (args.hasDefined(0)) {
4114
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
4115
0
      return false;
4116
0
    }
4117
0
  } else {
4118
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
4119
0
    arg0.Rebind(data, ArrayLength(data) - 1);
4120
0
  }
4121
0
  mozilla::dom::Console::Count(global, NonNullHelper(Constify(arg0)));
4122
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4123
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_count);
4124
0
  args.rval().setUndefined();
4125
0
  return true;
4126
0
}
4127
4128
static bool
4129
countReset(JSContext* cx, unsigned argc, JS::Value* vp)
4130
0
{
4131
0
  AUTO_PROFILER_LABEL_FAST("console.countReset", DOM, cx);
4132
0
4133
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4134
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4135
0
4136
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4137
0
  if (global.Failed()) {
4138
0
    return false;
4139
0
  }
4140
0
4141
0
  binding_detail::FakeString arg0;
4142
0
  if (args.hasDefined(0)) {
4143
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
4144
0
      return false;
4145
0
    }
4146
0
  } else {
4147
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
4148
0
    arg0.Rebind(data, ArrayLength(data) - 1);
4149
0
  }
4150
0
  mozilla::dom::Console::CountReset(global, NonNullHelper(Constify(arg0)));
4151
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4152
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_countReset);
4153
0
  args.rval().setUndefined();
4154
0
  return true;
4155
0
}
4156
4157
static bool
4158
debug(JSContext* cx, unsigned argc, JS::Value* vp)
4159
0
{
4160
0
  AUTO_PROFILER_LABEL_FAST("console.debug", DOM, cx);
4161
0
4162
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4163
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4164
0
4165
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4166
0
  if (global.Failed()) {
4167
0
    return false;
4168
0
  }
4169
0
4170
0
  AutoSequence<JS::Value> arg0;
4171
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4172
0
  if (args.length() > 0) {
4173
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4174
0
      JS_ReportOutOfMemory(cx);
4175
0
      return false;
4176
0
    }
4177
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4178
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4179
0
      slot = args[variadicArg];
4180
0
    }
4181
0
  }
4182
0
  mozilla::dom::Console::Debug(global, Constify(arg0));
4183
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4184
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_debug);
4185
0
  args.rval().setUndefined();
4186
0
  return true;
4187
0
}
4188
4189
static bool
4190
error(JSContext* cx, unsigned argc, JS::Value* vp)
4191
0
{
4192
0
  AUTO_PROFILER_LABEL_FAST("console.error", DOM, cx);
4193
0
4194
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4195
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4196
0
4197
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4198
0
  if (global.Failed()) {
4199
0
    return false;
4200
0
  }
4201
0
4202
0
  AutoSequence<JS::Value> arg0;
4203
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4204
0
  if (args.length() > 0) {
4205
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4206
0
      JS_ReportOutOfMemory(cx);
4207
0
      return false;
4208
0
    }
4209
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4210
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4211
0
      slot = args[variadicArg];
4212
0
    }
4213
0
  }
4214
0
  mozilla::dom::Console::Error(global, Constify(arg0));
4215
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4216
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_error);
4217
0
  args.rval().setUndefined();
4218
0
  return true;
4219
0
}
4220
4221
static bool
4222
info(JSContext* cx, unsigned argc, JS::Value* vp)
4223
0
{
4224
0
  AUTO_PROFILER_LABEL_FAST("console.info", DOM, cx);
4225
0
4226
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4227
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4228
0
4229
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4230
0
  if (global.Failed()) {
4231
0
    return false;
4232
0
  }
4233
0
4234
0
  AutoSequence<JS::Value> arg0;
4235
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4236
0
  if (args.length() > 0) {
4237
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4238
0
      JS_ReportOutOfMemory(cx);
4239
0
      return false;
4240
0
    }
4241
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4242
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4243
0
      slot = args[variadicArg];
4244
0
    }
4245
0
  }
4246
0
  mozilla::dom::Console::Info(global, Constify(arg0));
4247
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4248
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_info);
4249
0
  args.rval().setUndefined();
4250
0
  return true;
4251
0
}
4252
4253
static bool
4254
log(JSContext* cx, unsigned argc, JS::Value* vp)
4255
0
{
4256
0
  AUTO_PROFILER_LABEL_FAST("console.log", DOM, cx);
4257
0
4258
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4259
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4260
0
4261
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4262
0
  if (global.Failed()) {
4263
0
    return false;
4264
0
  }
4265
0
4266
0
  AutoSequence<JS::Value> arg0;
4267
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4268
0
  if (args.length() > 0) {
4269
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4270
0
      JS_ReportOutOfMemory(cx);
4271
0
      return false;
4272
0
    }
4273
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4274
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4275
0
      slot = args[variadicArg];
4276
0
    }
4277
0
  }
4278
0
  mozilla::dom::Console::Log(global, Constify(arg0));
4279
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4280
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_log);
4281
0
  args.rval().setUndefined();
4282
0
  return true;
4283
0
}
4284
4285
static bool
4286
table(JSContext* cx, unsigned argc, JS::Value* vp)
4287
0
{
4288
0
  AUTO_PROFILER_LABEL_FAST("console.table", DOM, cx);
4289
0
4290
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4291
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4292
0
4293
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4294
0
  if (global.Failed()) {
4295
0
    return false;
4296
0
  }
4297
0
4298
0
  AutoSequence<JS::Value> arg0;
4299
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4300
0
  if (args.length() > 0) {
4301
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4302
0
      JS_ReportOutOfMemory(cx);
4303
0
      return false;
4304
0
    }
4305
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4306
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4307
0
      slot = args[variadicArg];
4308
0
    }
4309
0
  }
4310
0
  mozilla::dom::Console::Table(global, Constify(arg0));
4311
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4312
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_table);
4313
0
  args.rval().setUndefined();
4314
0
  return true;
4315
0
}
4316
4317
static bool
4318
trace(JSContext* cx, unsigned argc, JS::Value* vp)
4319
0
{
4320
0
  AUTO_PROFILER_LABEL_FAST("console.trace", DOM, cx);
4321
0
4322
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4323
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4324
0
4325
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4326
0
  if (global.Failed()) {
4327
0
    return false;
4328
0
  }
4329
0
4330
0
  AutoSequence<JS::Value> arg0;
4331
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4332
0
  if (args.length() > 0) {
4333
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4334
0
      JS_ReportOutOfMemory(cx);
4335
0
      return false;
4336
0
    }
4337
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4338
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4339
0
      slot = args[variadicArg];
4340
0
    }
4341
0
  }
4342
0
  mozilla::dom::Console::Trace(global, Constify(arg0));
4343
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4344
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_trace);
4345
0
  args.rval().setUndefined();
4346
0
  return true;
4347
0
}
4348
4349
static bool
4350
warn(JSContext* cx, unsigned argc, JS::Value* vp)
4351
0
{
4352
0
  AUTO_PROFILER_LABEL_FAST("console.warn", DOM, cx);
4353
0
4354
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4355
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4356
0
4357
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4358
0
  if (global.Failed()) {
4359
0
    return false;
4360
0
  }
4361
0
4362
0
  AutoSequence<JS::Value> arg0;
4363
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4364
0
  if (args.length() > 0) {
4365
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4366
0
      JS_ReportOutOfMemory(cx);
4367
0
      return false;
4368
0
    }
4369
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4370
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4371
0
      slot = args[variadicArg];
4372
0
    }
4373
0
  }
4374
0
  mozilla::dom::Console::Warn(global, Constify(arg0));
4375
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4376
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_warn);
4377
0
  args.rval().setUndefined();
4378
0
  return true;
4379
0
}
4380
4381
static bool
4382
dir(JSContext* cx, unsigned argc, JS::Value* vp)
4383
0
{
4384
0
  AUTO_PROFILER_LABEL_FAST("console.dir", DOM, cx);
4385
0
4386
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4387
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4388
0
4389
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4390
0
  if (global.Failed()) {
4391
0
    return false;
4392
0
  }
4393
0
4394
0
  AutoSequence<JS::Value> arg0;
4395
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4396
0
  if (args.length() > 0) {
4397
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4398
0
      JS_ReportOutOfMemory(cx);
4399
0
      return false;
4400
0
    }
4401
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4402
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4403
0
      slot = args[variadicArg];
4404
0
    }
4405
0
  }
4406
0
  mozilla::dom::Console::Dir(global, Constify(arg0));
4407
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4408
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_dir);
4409
0
  args.rval().setUndefined();
4410
0
  return true;
4411
0
}
4412
4413
static bool
4414
dirxml(JSContext* cx, unsigned argc, JS::Value* vp)
4415
0
{
4416
0
  AUTO_PROFILER_LABEL_FAST("console.dirxml", DOM, cx);
4417
0
4418
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4419
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4420
0
4421
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4422
0
  if (global.Failed()) {
4423
0
    return false;
4424
0
  }
4425
0
4426
0
  AutoSequence<JS::Value> arg0;
4427
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4428
0
  if (args.length() > 0) {
4429
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4430
0
      JS_ReportOutOfMemory(cx);
4431
0
      return false;
4432
0
    }
4433
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4434
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4435
0
      slot = args[variadicArg];
4436
0
    }
4437
0
  }
4438
0
  mozilla::dom::Console::Dirxml(global, Constify(arg0));
4439
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4440
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_dirxml);
4441
0
  args.rval().setUndefined();
4442
0
  return true;
4443
0
}
4444
4445
static bool
4446
group(JSContext* cx, unsigned argc, JS::Value* vp)
4447
0
{
4448
0
  AUTO_PROFILER_LABEL_FAST("console.group", DOM, cx);
4449
0
4450
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4451
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4452
0
4453
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4454
0
  if (global.Failed()) {
4455
0
    return false;
4456
0
  }
4457
0
4458
0
  AutoSequence<JS::Value> arg0;
4459
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4460
0
  if (args.length() > 0) {
4461
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4462
0
      JS_ReportOutOfMemory(cx);
4463
0
      return false;
4464
0
    }
4465
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4466
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4467
0
      slot = args[variadicArg];
4468
0
    }
4469
0
  }
4470
0
  mozilla::dom::Console::Group(global, Constify(arg0));
4471
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4472
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_group);
4473
0
  args.rval().setUndefined();
4474
0
  return true;
4475
0
}
4476
4477
static bool
4478
groupCollapsed(JSContext* cx, unsigned argc, JS::Value* vp)
4479
0
{
4480
0
  AUTO_PROFILER_LABEL_FAST("console.groupCollapsed", DOM, cx);
4481
0
4482
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4483
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4484
0
4485
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4486
0
  if (global.Failed()) {
4487
0
    return false;
4488
0
  }
4489
0
4490
0
  AutoSequence<JS::Value> arg0;
4491
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4492
0
  if (args.length() > 0) {
4493
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4494
0
      JS_ReportOutOfMemory(cx);
4495
0
      return false;
4496
0
    }
4497
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4498
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4499
0
      slot = args[variadicArg];
4500
0
    }
4501
0
  }
4502
0
  mozilla::dom::Console::GroupCollapsed(global, Constify(arg0));
4503
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4504
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_groupCollapsed);
4505
0
  args.rval().setUndefined();
4506
0
  return true;
4507
0
}
4508
4509
static bool
4510
groupEnd(JSContext* cx, unsigned argc, JS::Value* vp)
4511
0
{
4512
0
  AUTO_PROFILER_LABEL_FAST("console.groupEnd", DOM, cx);
4513
0
4514
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4515
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4516
0
4517
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4518
0
  if (global.Failed()) {
4519
0
    return false;
4520
0
  }
4521
0
4522
0
  mozilla::dom::Console::GroupEnd(global);
4523
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4524
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_groupEnd);
4525
0
  args.rval().setUndefined();
4526
0
  return true;
4527
0
}
4528
4529
static bool
4530
time(JSContext* cx, unsigned argc, JS::Value* vp)
4531
0
{
4532
0
  AUTO_PROFILER_LABEL_FAST("console.time", DOM, cx);
4533
0
4534
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4535
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4536
0
4537
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4538
0
  if (global.Failed()) {
4539
0
    return false;
4540
0
  }
4541
0
4542
0
  binding_detail::FakeString arg0;
4543
0
  if (args.hasDefined(0)) {
4544
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
4545
0
      return false;
4546
0
    }
4547
0
  } else {
4548
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
4549
0
    arg0.Rebind(data, ArrayLength(data) - 1);
4550
0
  }
4551
0
  mozilla::dom::Console::Time(global, NonNullHelper(Constify(arg0)));
4552
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4553
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_time);
4554
0
  args.rval().setUndefined();
4555
0
  return true;
4556
0
}
4557
4558
static bool
4559
timeLog(JSContext* cx, unsigned argc, JS::Value* vp)
4560
0
{
4561
0
  AUTO_PROFILER_LABEL_FAST("console.timeLog", DOM, cx);
4562
0
4563
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4564
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4565
0
4566
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4567
0
  if (global.Failed()) {
4568
0
    return false;
4569
0
  }
4570
0
4571
0
  binding_detail::FakeString arg0;
4572
0
  if (args.hasDefined(0)) {
4573
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
4574
0
      return false;
4575
0
    }
4576
0
  } else {
4577
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
4578
0
    arg0.Rebind(data, ArrayLength(data) - 1);
4579
0
  }
4580
0
  AutoSequence<JS::Value> arg1;
4581
0
  SequenceRooter<JS::Value> arg1_holder(cx, &arg1);
4582
0
  if (args.length() > 1) {
4583
0
    if (!arg1.SetCapacity(args.length() - 1, mozilla::fallible)) {
4584
0
      JS_ReportOutOfMemory(cx);
4585
0
      return false;
4586
0
    }
4587
0
    for (uint32_t variadicArg = 1; variadicArg < args.length(); ++variadicArg) {
4588
0
      JS::Value& slot = *arg1.AppendElement(mozilla::fallible);
4589
0
      slot = args[variadicArg];
4590
0
    }
4591
0
  }
4592
0
  mozilla::dom::Console::TimeLog(global, NonNullHelper(Constify(arg0)), Constify(arg1));
4593
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4594
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_timeLog);
4595
0
  args.rval().setUndefined();
4596
0
  return true;
4597
0
}
4598
4599
static bool
4600
timeEnd(JSContext* cx, unsigned argc, JS::Value* vp)
4601
0
{
4602
0
  AUTO_PROFILER_LABEL_FAST("console.timeEnd", DOM, cx);
4603
0
4604
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4605
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4606
0
4607
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4608
0
  if (global.Failed()) {
4609
0
    return false;
4610
0
  }
4611
0
4612
0
  binding_detail::FakeString arg0;
4613
0
  if (args.hasDefined(0)) {
4614
0
    if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
4615
0
      return false;
4616
0
    }
4617
0
  } else {
4618
0
    static const char16_t data[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', 0 };
4619
0
    arg0.Rebind(data, ArrayLength(data) - 1);
4620
0
  }
4621
0
  mozilla::dom::Console::TimeEnd(global, NonNullHelper(Constify(arg0)));
4622
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4623
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_timeEnd);
4624
0
  args.rval().setUndefined();
4625
0
  return true;
4626
0
}
4627
4628
static bool
4629
exception(JSContext* cx, unsigned argc, JS::Value* vp)
4630
0
{
4631
0
  AUTO_PROFILER_LABEL_FAST("console.exception", DOM, cx);
4632
0
4633
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4634
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4635
0
4636
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4637
0
  if (global.Failed()) {
4638
0
    return false;
4639
0
  }
4640
0
4641
0
  AutoSequence<JS::Value> arg0;
4642
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4643
0
  if (args.length() > 0) {
4644
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4645
0
      JS_ReportOutOfMemory(cx);
4646
0
      return false;
4647
0
    }
4648
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4649
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4650
0
      slot = args[variadicArg];
4651
0
    }
4652
0
  }
4653
0
  mozilla::dom::Console::Exception(global, Constify(arg0));
4654
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4655
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_exception);
4656
0
  args.rval().setUndefined();
4657
0
  return true;
4658
0
}
4659
4660
static bool
4661
timeStamp(JSContext* cx, unsigned argc, JS::Value* vp)
4662
0
{
4663
0
  AUTO_PROFILER_LABEL_FAST("console.timeStamp", DOM, cx);
4664
0
4665
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4666
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4667
0
4668
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4669
0
  if (global.Failed()) {
4670
0
    return false;
4671
0
  }
4672
0
4673
0
  JS::Rooted<JS::Value> arg0(cx);
4674
0
  if (args.hasDefined(0)) {
4675
0
    arg0 = args[0];
4676
0
  } else {
4677
0
    arg0 = JS::UndefinedValue();
4678
0
  }
4679
0
  mozilla::dom::Console::TimeStamp(global, arg0);
4680
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4681
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_timeStamp);
4682
0
  args.rval().setUndefined();
4683
0
  return true;
4684
0
}
4685
4686
static bool
4687
profile(JSContext* cx, unsigned argc, JS::Value* vp)
4688
0
{
4689
0
  AUTO_PROFILER_LABEL_FAST("console.profile", DOM, cx);
4690
0
4691
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4692
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4693
0
4694
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4695
0
  if (global.Failed()) {
4696
0
    return false;
4697
0
  }
4698
0
4699
0
  AutoSequence<JS::Value> arg0;
4700
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4701
0
  if (args.length() > 0) {
4702
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4703
0
      JS_ReportOutOfMemory(cx);
4704
0
      return false;
4705
0
    }
4706
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4707
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4708
0
      slot = args[variadicArg];
4709
0
    }
4710
0
  }
4711
0
  mozilla::dom::Console::Profile(global, Constify(arg0));
4712
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4713
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_profile);
4714
0
  args.rval().setUndefined();
4715
0
  return true;
4716
0
}
4717
4718
static bool
4719
profileEnd(JSContext* cx, unsigned argc, JS::Value* vp)
4720
0
{
4721
0
  AUTO_PROFILER_LABEL_FAST("console.profileEnd", DOM, cx);
4722
0
4723
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4724
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4725
0
4726
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4727
0
  if (global.Failed()) {
4728
0
    return false;
4729
0
  }
4730
0
4731
0
  AutoSequence<JS::Value> arg0;
4732
0
  SequenceRooter<JS::Value> arg0_holder(cx, &arg0);
4733
0
  if (args.length() > 0) {
4734
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
4735
0
      JS_ReportOutOfMemory(cx);
4736
0
      return false;
4737
0
    }
4738
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
4739
0
      JS::Value& slot = *arg0.AppendElement(mozilla::fallible);
4740
0
      slot = args[variadicArg];
4741
0
    }
4742
0
  }
4743
0
  mozilla::dom::Console::ProfileEnd(global, Constify(arg0));
4744
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4745
0
  SetDocumentAndPageUseCounter(obj, eUseCounter_console_profileEnd);
4746
0
  args.rval().setUndefined();
4747
0
  return true;
4748
0
}
4749
4750
static bool
4751
createInstance(JSContext* cx, unsigned argc, JS::Value* vp)
4752
0
{
4753
0
  AUTO_PROFILER_LABEL_FAST("console.createInstance", DOM, cx);
4754
0
4755
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4756
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4757
0
4758
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4759
0
  if (global.Failed()) {
4760
0
    return false;
4761
0
  }
4762
0
4763
0
  binding_detail::FastConsoleInstanceOptions arg0;
4764
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of console.createInstance", false)) {
4765
0
    return false;
4766
0
  }
4767
0
  auto result(StrongOrRawPtr<mozilla::dom::ConsoleInstance>(mozilla::dom::Console::CreateInstance(global, Constify(arg0))));
4768
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4769
0
  static_assert(!IsPointer<decltype(result)>::value,
4770
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
4771
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
4772
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
4773
0
    return false;
4774
0
  }
4775
0
  return true;
4776
0
}
4777
4778
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
4779
#if defined(__clang__)
4780
#pragma clang diagnostic push
4781
#pragma clang diagnostic ignored "-Wmissing-braces"
4782
#endif
4783
static const JSFunctionSpec sStaticMethods_specs[] = {
4784
  JS_FNSPEC("assert", _assert_, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4785
  JS_FNSPEC("clear", clear, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4786
  JS_FNSPEC("count", count, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4787
  JS_FNSPEC("countReset", countReset, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4788
  JS_FNSPEC("debug", debug, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4789
  JS_FNSPEC("error", error, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4790
  JS_FNSPEC("info", info, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4791
  JS_FNSPEC("log", log, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4792
  JS_FNSPEC("table", table, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4793
  JS_FNSPEC("trace", trace, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4794
  JS_FNSPEC("warn", warn, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4795
  JS_FNSPEC("dir", dir, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4796
  JS_FNSPEC("dirxml", dirxml, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4797
  JS_FNSPEC("group", group, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4798
  JS_FNSPEC("groupCollapsed", groupCollapsed, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4799
  JS_FNSPEC("groupEnd", groupEnd, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4800
  JS_FNSPEC("time", time, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4801
  JS_FNSPEC("timeLog", timeLog, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4802
  JS_FNSPEC("timeEnd", timeEnd, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4803
  JS_FNSPEC("exception", exception, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4804
  JS_FNSPEC("timeStamp", timeStamp, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4805
  JS_FNSPEC("profile", profile, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4806
  JS_FNSPEC("profileEnd", profileEnd, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4807
  JS_FS_END
4808
};
4809
#if defined(__clang__)
4810
#pragma clang diagnostic pop
4811
#endif
4812
4813
4814
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
4815
  { nullptr, &sStaticMethods_specs[0] },
4816
  { nullptr, nullptr }
4817
};
4818
4819
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
4820
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
4821
static_assert(23 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
4822
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
4823
4824
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
4825
#if defined(__clang__)
4826
#pragma clang diagnostic push
4827
#pragma clang diagnostic ignored "-Wmissing-braces"
4828
#endif
4829
static const JSFunctionSpec sChromeStaticMethods_specs[] = {
4830
  JS_FNSPEC("createInstance", createInstance, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4831
  JS_FS_END
4832
};
4833
#if defined(__clang__)
4834
#pragma clang diagnostic pop
4835
#endif
4836
4837
4838
static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = {
4839
  { nullptr, &sChromeStaticMethods_specs[0] },
4840
  { nullptr, nullptr }
4841
};
4842
4843
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
4844
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
4845
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
4846
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
4847
4848
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
4849
#if defined(__clang__)
4850
#pragma clang diagnostic push
4851
#pragma clang diagnostic ignored "-Wmissing-braces"
4852
#endif
4853
static const ConstantSpec sChromeConstants_specs[] = {
4854
  { "IS_NATIVE_CONSOLE", JS::BooleanValue(true) },
4855
  { 0, JS::UndefinedValue() }
4856
};
4857
#if defined(__clang__)
4858
#pragma clang diagnostic pop
4859
#endif
4860
4861
4862
static const Prefable<const ConstantSpec> sChromeConstants[] = {
4863
  { nullptr, &sChromeConstants_specs[0] },
4864
  { nullptr, nullptr }
4865
};
4866
4867
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
4868
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
4869
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
4870
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
4871
4872
4873
static uint16_t sNativeProperties_sortedPropertyIndices[23];
4874
static PropertyInfo sNativeProperties_propertyInfos[23];
4875
4876
static const NativePropertiesN<1> sNativeProperties = {
4877
  true,  0 /* sStaticMethods */,
4878
  false, 0,
4879
  false, 0,
4880
  false, 0,
4881
  false, 0,
4882
  false, 0,
4883
  false, 0,
4884
  -1,
4885
  23,
4886
  sNativeProperties_sortedPropertyIndices,
4887
  {
4888
    { sStaticMethods, &sNativeProperties_propertyInfos[0] }
4889
  }
4890
};
4891
static_assert(23 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
4892
    "We have a property info count that is oversized");
4893
4894
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2];
4895
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2];
4896
4897
static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
4898
  true,  0 /* sChromeStaticMethods */,
4899
  false, 0,
4900
  false, 0,
4901
  false, 0,
4902
  false, 0,
4903
  false, 0,
4904
  true,  1 /* sChromeConstants */,
4905
  -1,
4906
  2,
4907
  sChromeOnlyNativeProperties_sortedPropertyIndices,
4908
  {
4909
    { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
4910
    { sChromeConstants, &sChromeOnlyNativeProperties_propertyInfos[1] }
4911
  }
4912
};
4913
static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
4914
    "We have a property info count that is oversized");
4915
4916
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
4917
  {
4918
    "Console",
4919
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
4920
    JS_NULL_CLASS_OPS,
4921
    JS_NULL_CLASS_SPEC,
4922
    JS_NULL_CLASS_EXT,
4923
    JS_NULL_OBJECT_OPS
4924
  },
4925
  eInterface,
4926
  false,
4927
  prototypes::id::_ID_Count,
4928
  0,
4929
  sNativePropertyHooks,
4930
  "[object Console]",
4931
  JS::GetRealmObjectPrototype
4932
};
4933
4934
const NativePropertyHooks sNativePropertyHooks[] = { {
4935
  nullptr,
4936
  nullptr,
4937
  nullptr,
4938
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
4939
  prototypes::id::_ID_Count,
4940
  constructors::id::console,
4941
  nullptr,
4942
  &DefaultXrayExpandoObjectClass
4943
} };
4944
4945
void
4946
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
4947
0
{
4948
0
  JS::Rooted<JSObject*> constructorProto(aCx, GetHackedNamespaceProtoObject(aCx));
4949
0
  if (!constructorProto) {
4950
0
    return;
4951
0
  }
4952
0
4953
0
  static bool sIdsInited = false;
4954
0
  if (!sIdsInited && NS_IsMainThread()) {
4955
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
4956
0
      return;
4957
0
    }
4958
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
4959
0
      return;
4960
0
    }
4961
0
    sIdsInited = true;
4962
0
  }
4963
0
4964
0
  JS::Heap<JSObject*>* protoCache = nullptr;
4965
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::console);
4966
0
  dom::CreateInterfaceObjects(aCx, aGlobal, nullptr,
4967
0
                              nullptr, protoCache,
4968
0
                              nullptr,
4969
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
4970
0
                              interfaceCache,
4971
0
                              sNativeProperties.Upcast(),
4972
0
                              sChromeOnlyNativeProperties.Upcast(),
4973
0
                              "console", aDefineOnGlobal,
4974
0
                              nullptr,
4975
0
                              false);
4976
0
}
4977
4978
JSObject*
4979
GetConstructorObject(JSContext* aCx)
4980
0
{
4981
0
  return GetConstructorObjectHandle(aCx);
4982
0
}
4983
4984
} // namespace console_Binding
4985
4986
4987
4988
} // namespace dom
4989
} // namespace mozilla