Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/ChannelWrapperBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM ChannelWrapper.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "ChannelWrapperBinding.h"
5
#include "EventHandlerBinding.h"
6
#include "EventTargetBinding.h"
7
#include "WrapperFactory.h"
8
#include "jsapi.h"
9
#include "mozilla/OwningNonNull.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/Nullable.h"
14
#include "mozilla/dom/PrimitiveConversions.h"
15
#include "mozilla/dom/ScriptSettings.h"
16
#include "mozilla/dom/SimpleGlobalObject.h"
17
#include "mozilla/extensions/ChannelWrapper.h"
18
#include "mozilla/extensions/WebExtensionPolicy.h"
19
#include "nsContentUtils.h"
20
#include "nsIChannel.h"
21
#include "nsILoadInfo.h"
22
#include "nsISupports.h"
23
#include "nsITabParent.h"
24
#include "nsIURI.h"
25
#include "nsJSUtils.h"
26
#include "nsThreadUtils.h"
27
28
namespace mozilla {
29
namespace dom {
30
31
namespace binding_detail {}; // Just to make sure it's known as a namespace
32
using namespace mozilla::dom::binding_detail;
33
34
35
namespace MozContentPolicyTypeValues {
36
extern const EnumEntry strings[23] = {
37
  {"main_frame", 10},
38
  {"sub_frame", 9},
39
  {"stylesheet", 10},
40
  {"script", 6},
41
  {"image", 5},
42
  {"object", 6},
43
  {"object_subrequest", 17},
44
  {"xmlhttprequest", 14},
45
  {"fetch", 5},
46
  {"xbl", 3},
47
  {"xslt", 4},
48
  {"ping", 4},
49
  {"beacon", 6},
50
  {"xml_dtd", 7},
51
  {"font", 4},
52
  {"media", 5},
53
  {"websocket", 9},
54
  {"csp_report", 10},
55
  {"imageset", 8},
56
  {"web_manifest", 12},
57
  {"speculative", 11},
58
  {"other", 5},
59
  { nullptr, 0 }
60
};
61
} // namespace MozContentPolicyTypeValues
62
63
bool
64
ToJSValue(JSContext* aCx, MozContentPolicyType aArgument, JS::MutableHandle<JS::Value> aValue)
65
0
{
66
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(MozContentPolicyTypeValues::strings));
67
0
  JSString* resultStr =
68
0
    JS_NewStringCopyN(aCx, MozContentPolicyTypeValues::strings[uint32_t(aArgument)].value,
69
0
                      MozContentPolicyTypeValues::strings[uint32_t(aArgument)].length);
70
0
  if (!resultStr) {
71
0
    return false;
72
0
  }
73
0
  aValue.setString(resultStr);
74
0
  return true;
75
0
}
76
77
78
79
MozFrameAncestorInfo::MozFrameAncestorInfo()
80
0
{
81
0
  // Safe to pass a null context if we pass a null value
82
0
  Init(nullptr, JS::NullHandleValue);
83
0
}
84
85
86
87
bool
88
MozFrameAncestorInfo::InitIds(JSContext* cx, MozFrameAncestorInfoAtoms* atomsCache)
89
0
{
90
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
91
0
92
0
  // Initialize these in reverse order so that any failure leaves the first one
93
0
  // uninitialized.
94
0
  if (!atomsCache->url_id.init(cx, "url") ||
95
0
      !atomsCache->frameId_id.init(cx, "frameId")) {
96
0
    return false;
97
0
  }
98
0
  return true;
99
0
}
100
101
bool
102
MozFrameAncestorInfo::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
103
0
{
104
0
  // Passing a null JSContext is OK only if we're initing from null,
105
0
  // Since in that case we will not have to do any property gets
106
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
107
0
  // checkers by static analysis tools
108
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
109
0
  MozFrameAncestorInfoAtoms* atomsCache = nullptr;
110
0
  if (cx) {
111
0
    atomsCache = GetAtomCache<MozFrameAncestorInfoAtoms>(cx);
112
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
113
0
      return false;
114
0
    }
115
0
  }
116
0
117
0
  if (!IsConvertibleToDictionary(val)) {
118
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
119
0
  }
120
0
121
0
  bool isNull = val.isNullOrUndefined();
122
0
  // We only need these if !isNull, in which case we have |cx|.
123
0
  Maybe<JS::Rooted<JSObject *> > object;
124
0
  Maybe<JS::Rooted<JS::Value> > temp;
125
0
  if (!isNull) {
126
0
    MOZ_ASSERT(cx);
127
0
    object.emplace(cx, &val.toObject());
128
0
    temp.emplace(cx);
129
0
  }
130
0
  if (!isNull) {
131
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->frameId_id, temp.ptr())) {
132
0
      return false;
133
0
    }
134
0
  }
135
0
  if (!isNull && !temp->isUndefined()) {
136
0
    if (!ValueToPrimitive<uint64_t, eDefault>(cx, temp.ref(), &mFrameId)) {
137
0
      return false;
138
0
    }
139
0
    mIsAnyMemberPresent = true;
140
0
  } else if (cx) {
141
0
    // Don't error out if we have no cx.  In that
142
0
    // situation the caller is default-constructing us and we'll
143
0
    // just assume they know what they're doing.
144
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
145
0
                             "'frameId' member of MozFrameAncestorInfo");
146
0
  }
147
0
148
0
  if (!isNull) {
149
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->url_id, temp.ptr())) {
150
0
      return false;
151
0
    }
152
0
  }
153
0
  if (!isNull && !temp->isUndefined()) {
154
0
    if (!ConvertJSValueToByteString(cx, temp.ref(), false, mUrl)) {
155
0
      return false;
156
0
    }
157
0
    mIsAnyMemberPresent = true;
158
0
  } else if (cx) {
159
0
    // Don't error out if we have no cx.  In that
160
0
    // situation the caller is default-constructing us and we'll
161
0
    // just assume they know what they're doing.
162
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
163
0
                             "'url' member of MozFrameAncestorInfo");
164
0
  }
165
0
  return true;
166
0
}
167
168
bool
169
MozFrameAncestorInfo::Init(const nsAString& aJSON)
170
0
{
171
0
  AutoJSAPI jsapi;
172
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
173
0
  if (!cleanGlobal) {
174
0
    return false;
175
0
  }
176
0
  if (!jsapi.Init(cleanGlobal)) {
177
0
    return false;
178
0
  }
179
0
  JSContext* cx = jsapi.cx();
180
0
  JS::Rooted<JS::Value> json(cx);
181
0
  bool ok = ParseJSON(cx, aJSON, &json);
182
0
  NS_ENSURE_TRUE(ok, false);
183
0
  return Init(cx, json);
184
0
}
185
186
bool
187
MozFrameAncestorInfo::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
188
0
{
189
0
  MozFrameAncestorInfoAtoms* atomsCache = GetAtomCache<MozFrameAncestorInfoAtoms>(cx);
190
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
191
0
    return false;
192
0
  }
193
0
194
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
195
0
  if (!obj) {
196
0
    return false;
197
0
  }
198
0
  rval.set(JS::ObjectValue(*obj));
199
0
200
0
  do {
201
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
202
0
    JS::Rooted<JS::Value> temp(cx);
203
0
    uint64_t const & currentValue = mFrameId;
204
0
    temp.set(JS_NumberValue(double(currentValue)));
205
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->frameId_id, temp, JSPROP_ENUMERATE)) {
206
0
      return false;
207
0
    }
208
0
    break;
209
0
  } while(false);
210
0
211
0
  do {
212
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
213
0
    JS::Rooted<JS::Value> temp(cx);
214
0
    nsCString const & currentValue = mUrl;
215
0
    if (!NonVoidByteStringToJsval(cx, currentValue, &temp)) {
216
0
      return false;
217
0
    }
218
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->url_id, temp, JSPROP_ENUMERATE)) {
219
0
      return false;
220
0
    }
221
0
    break;
222
0
  } while(false);
223
0
224
0
  return true;
225
0
}
226
227
bool
228
MozFrameAncestorInfo::ToJSON(nsAString& aJSON) const
229
0
{
230
0
  AutoJSAPI jsapi;
231
0
  jsapi.Init();
232
0
  JSContext *cx = jsapi.cx();
233
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
234
0
  // because we'll only be creating objects, in ways that have no
235
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
236
0
  // which likewise guarantees no side-effects for the sorts of
237
0
  // things we will pass it.
238
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
239
0
  JS::Rooted<JS::Value> val(cx);
240
0
  if (!ToObjectInternal(cx, &val)) {
241
0
    return false;
242
0
  }
243
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
244
0
  return StringifyToJSON(cx, obj, aJSON);
245
0
}
246
247
void
248
MozFrameAncestorInfo::TraceDictionary(JSTracer* trc)
249
0
{
250
0
}
251
252
MozFrameAncestorInfo&
253
MozFrameAncestorInfo::operator=(const MozFrameAncestorInfo& aOther)
254
0
{
255
0
  DictionaryBase::operator=(aOther);
256
0
  mFrameId = aOther.mFrameId;
257
0
  mUrl = aOther.mUrl;
258
0
  return *this;
259
0
}
260
261
namespace binding_detail {
262
} // namespace binding_detail
263
264
265
266
MozHTTPHeader::MozHTTPHeader()
267
0
{
268
0
  // Safe to pass a null context if we pass a null value
269
0
  Init(nullptr, JS::NullHandleValue);
270
0
}
271
272
273
274
bool
275
MozHTTPHeader::InitIds(JSContext* cx, MozHTTPHeaderAtoms* atomsCache)
276
0
{
277
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
278
0
279
0
  // Initialize these in reverse order so that any failure leaves the first one
280
0
  // uninitialized.
281
0
  if (!atomsCache->value_id.init(cx, "value") ||
282
0
      !atomsCache->name_id.init(cx, "name")) {
283
0
    return false;
284
0
  }
285
0
  return true;
286
0
}
287
288
bool
289
MozHTTPHeader::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
290
0
{
291
0
  // Passing a null JSContext is OK only if we're initing from null,
292
0
  // Since in that case we will not have to do any property gets
293
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
294
0
  // checkers by static analysis tools
295
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
296
0
  MozHTTPHeaderAtoms* atomsCache = nullptr;
297
0
  if (cx) {
298
0
    atomsCache = GetAtomCache<MozHTTPHeaderAtoms>(cx);
299
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
300
0
      return false;
301
0
    }
302
0
  }
303
0
304
0
  if (!IsConvertibleToDictionary(val)) {
305
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
306
0
  }
307
0
308
0
  bool isNull = val.isNullOrUndefined();
309
0
  // We only need these if !isNull, in which case we have |cx|.
310
0
  Maybe<JS::Rooted<JSObject *> > object;
311
0
  Maybe<JS::Rooted<JS::Value> > temp;
312
0
  if (!isNull) {
313
0
    MOZ_ASSERT(cx);
314
0
    object.emplace(cx, &val.toObject());
315
0
    temp.emplace(cx);
316
0
  }
317
0
  if (!isNull) {
318
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
319
0
      return false;
320
0
    }
321
0
  }
322
0
  if (!isNull && !temp->isUndefined()) {
323
0
    if (!ConvertJSValueToByteString(cx, temp.ref(), false, mName)) {
324
0
      return false;
325
0
    }
326
0
    mIsAnyMemberPresent = true;
327
0
  } else if (cx) {
328
0
    // Don't error out if we have no cx.  In that
329
0
    // situation the caller is default-constructing us and we'll
330
0
    // just assume they know what they're doing.
331
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
332
0
                             "'name' member of MozHTTPHeader");
333
0
  }
334
0
335
0
  if (!isNull) {
336
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->value_id, temp.ptr())) {
337
0
      return false;
338
0
    }
339
0
  }
340
0
  if (!isNull && !temp->isUndefined()) {
341
0
    if (!ConvertJSValueToByteString(cx, temp.ref(), false, mValue)) {
342
0
      return false;
343
0
    }
344
0
    mIsAnyMemberPresent = true;
345
0
  } else if (cx) {
346
0
    // Don't error out if we have no cx.  In that
347
0
    // situation the caller is default-constructing us and we'll
348
0
    // just assume they know what they're doing.
349
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
350
0
                             "'value' member of MozHTTPHeader");
351
0
  }
352
0
  return true;
353
0
}
354
355
bool
356
MozHTTPHeader::Init(const nsAString& aJSON)
357
0
{
358
0
  AutoJSAPI jsapi;
359
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
360
0
  if (!cleanGlobal) {
361
0
    return false;
362
0
  }
363
0
  if (!jsapi.Init(cleanGlobal)) {
364
0
    return false;
365
0
  }
366
0
  JSContext* cx = jsapi.cx();
367
0
  JS::Rooted<JS::Value> json(cx);
368
0
  bool ok = ParseJSON(cx, aJSON, &json);
369
0
  NS_ENSURE_TRUE(ok, false);
370
0
  return Init(cx, json);
371
0
}
372
373
bool
374
MozHTTPHeader::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
375
0
{
376
0
  MozHTTPHeaderAtoms* atomsCache = GetAtomCache<MozHTTPHeaderAtoms>(cx);
377
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
378
0
    return false;
379
0
  }
380
0
381
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
382
0
  if (!obj) {
383
0
    return false;
384
0
  }
385
0
  rval.set(JS::ObjectValue(*obj));
386
0
387
0
  do {
388
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
389
0
    JS::Rooted<JS::Value> temp(cx);
390
0
    nsCString const & currentValue = mName;
391
0
    if (!NonVoidByteStringToJsval(cx, currentValue, &temp)) {
392
0
      return false;
393
0
    }
394
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
395
0
      return false;
396
0
    }
397
0
    break;
398
0
  } while(false);
399
0
400
0
  do {
401
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
402
0
    JS::Rooted<JS::Value> temp(cx);
403
0
    nsCString const & currentValue = mValue;
404
0
    if (!NonVoidByteStringToJsval(cx, currentValue, &temp)) {
405
0
      return false;
406
0
    }
407
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->value_id, temp, JSPROP_ENUMERATE)) {
408
0
      return false;
409
0
    }
410
0
    break;
411
0
  } while(false);
412
0
413
0
  return true;
414
0
}
415
416
bool
417
MozHTTPHeader::ToJSON(nsAString& aJSON) const
418
0
{
419
0
  AutoJSAPI jsapi;
420
0
  jsapi.Init();
421
0
  JSContext *cx = jsapi.cx();
422
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
423
0
  // because we'll only be creating objects, in ways that have no
424
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
425
0
  // which likewise guarantees no side-effects for the sorts of
426
0
  // things we will pass it.
427
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
428
0
  JS::Rooted<JS::Value> val(cx);
429
0
  if (!ToObjectInternal(cx, &val)) {
430
0
    return false;
431
0
  }
432
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
433
0
  return StringifyToJSON(cx, obj, aJSON);
434
0
}
435
436
void
437
MozHTTPHeader::TraceDictionary(JSTracer* trc)
438
0
{
439
0
}
440
441
MozHTTPHeader&
442
MozHTTPHeader::operator=(const MozHTTPHeader& aOther)
443
0
{
444
0
  DictionaryBase::operator=(aOther);
445
0
  mName = aOther.mName;
446
0
  mValue = aOther.mValue;
447
0
  return *this;
448
0
}
449
450
namespace binding_detail {
451
} // namespace binding_detail
452
453
454
455
MozProxyInfo::MozProxyInfo()
456
0
{
457
0
  // Safe to pass a null context if we pass a null value
458
0
  Init(nullptr, JS::NullHandleValue);
459
0
}
460
461
462
463
bool
464
MozProxyInfo::InitIds(JSContext* cx, MozProxyInfoAtoms* 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->username_id.init(cx, "username") ||
471
0
      !atomsCache->type_id.init(cx, "type") ||
472
0
      !atomsCache->proxyDNS_id.init(cx, "proxyDNS") ||
473
0
      !atomsCache->port_id.init(cx, "port") ||
474
0
      !atomsCache->host_id.init(cx, "host") ||
475
0
      !atomsCache->failoverTimeout_id.init(cx, "failoverTimeout")) {
476
0
    return false;
477
0
  }
478
0
  return true;
479
0
}
480
481
bool
482
MozProxyInfo::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
  MozProxyInfoAtoms* atomsCache = nullptr;
490
0
  if (cx) {
491
0
    atomsCache = GetAtomCache<MozProxyInfoAtoms>(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->failoverTimeout_id, temp.ptr())) {
512
0
      return false;
513
0
    }
514
0
  }
515
0
  if (!isNull && !temp->isUndefined()) {
516
0
    mFailoverTimeout.Construct();
517
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &(mFailoverTimeout.Value()))) {
518
0
      return false;
519
0
    }
520
0
    mIsAnyMemberPresent = true;
521
0
  }
522
0
523
0
  if (!isNull) {
524
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->host_id, temp.ptr())) {
525
0
      return false;
526
0
    }
527
0
  }
528
0
  if (!isNull && !temp->isUndefined()) {
529
0
    if (!ConvertJSValueToByteString(cx, temp.ref(), false, mHost)) {
530
0
      return false;
531
0
    }
532
0
    mIsAnyMemberPresent = true;
533
0
  } else if (cx) {
534
0
    // Don't error out if we have no cx.  In that
535
0
    // situation the caller is default-constructing us and we'll
536
0
    // just assume they know what they're doing.
537
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
538
0
                             "'host' member of MozProxyInfo");
539
0
  }
540
0
541
0
  if (!isNull) {
542
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->port_id, temp.ptr())) {
543
0
      return false;
544
0
    }
545
0
  }
546
0
  if (!isNull && !temp->isUndefined()) {
547
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mPort)) {
548
0
      return false;
549
0
    }
550
0
    mIsAnyMemberPresent = true;
551
0
  } else if (cx) {
552
0
    // Don't error out if we have no cx.  In that
553
0
    // situation the caller is default-constructing us and we'll
554
0
    // just assume they know what they're doing.
555
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
556
0
                             "'port' member of MozProxyInfo");
557
0
  }
558
0
559
0
  if (!isNull) {
560
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->proxyDNS_id, temp.ptr())) {
561
0
      return false;
562
0
    }
563
0
  }
564
0
  if (!isNull && !temp->isUndefined()) {
565
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mProxyDNS)) {
566
0
      return false;
567
0
    }
568
0
    mIsAnyMemberPresent = true;
569
0
  } else if (cx) {
570
0
    // Don't error out if we have no cx.  In that
571
0
    // situation the caller is default-constructing us and we'll
572
0
    // just assume they know what they're doing.
573
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
574
0
                             "'proxyDNS' member of MozProxyInfo");
575
0
  }
576
0
577
0
  if (!isNull) {
578
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->type_id, temp.ptr())) {
579
0
      return false;
580
0
    }
581
0
  }
582
0
  if (!isNull && !temp->isUndefined()) {
583
0
    if (!ConvertJSValueToByteString(cx, temp.ref(), false, mType)) {
584
0
      return false;
585
0
    }
586
0
    mIsAnyMemberPresent = true;
587
0
  } else if (cx) {
588
0
    // Don't error out if we have no cx.  In that
589
0
    // situation the caller is default-constructing us and we'll
590
0
    // just assume they know what they're doing.
591
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
592
0
                             "'type' member of MozProxyInfo");
593
0
  }
594
0
595
0
  if (!isNull) {
596
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->username_id, temp.ptr())) {
597
0
      return false;
598
0
    }
599
0
  }
600
0
  if (!isNull && !temp->isUndefined()) {
601
0
    if (!ConvertJSValueToByteString(cx, temp.ref(), true, mUsername)) {
602
0
      return false;
603
0
    }
604
0
  } else {
605
0
    mUsername.SetIsVoid(true);
606
0
  }
607
0
  mIsAnyMemberPresent = true;
608
0
  return true;
609
0
}
610
611
bool
612
MozProxyInfo::Init(const nsAString& aJSON)
613
0
{
614
0
  AutoJSAPI jsapi;
615
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
616
0
  if (!cleanGlobal) {
617
0
    return false;
618
0
  }
619
0
  if (!jsapi.Init(cleanGlobal)) {
620
0
    return false;
621
0
  }
622
0
  JSContext* cx = jsapi.cx();
623
0
  JS::Rooted<JS::Value> json(cx);
624
0
  bool ok = ParseJSON(cx, aJSON, &json);
625
0
  NS_ENSURE_TRUE(ok, false);
626
0
  return Init(cx, json);
627
0
}
628
629
bool
630
MozProxyInfo::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
631
0
{
632
0
  MozProxyInfoAtoms* atomsCache = GetAtomCache<MozProxyInfoAtoms>(cx);
633
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
634
0
    return false;
635
0
  }
636
0
637
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
638
0
  if (!obj) {
639
0
    return false;
640
0
  }
641
0
  rval.set(JS::ObjectValue(*obj));
642
0
643
0
  if (mFailoverTimeout.WasPassed()) {
644
0
    do {
645
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
646
0
      JS::Rooted<JS::Value> temp(cx);
647
0
      uint32_t const & currentValue = mFailoverTimeout.InternalValue();
648
0
      temp.setNumber(currentValue);
649
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->failoverTimeout_id, temp, JSPROP_ENUMERATE)) {
650
0
        return false;
651
0
      }
652
0
      break;
653
0
    } while(false);
654
0
  }
655
0
656
0
  do {
657
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
658
0
    JS::Rooted<JS::Value> temp(cx);
659
0
    nsCString const & currentValue = mHost;
660
0
    if (!NonVoidByteStringToJsval(cx, currentValue, &temp)) {
661
0
      return false;
662
0
    }
663
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->host_id, temp, JSPROP_ENUMERATE)) {
664
0
      return false;
665
0
    }
666
0
    break;
667
0
  } while(false);
668
0
669
0
  do {
670
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
671
0
    JS::Rooted<JS::Value> temp(cx);
672
0
    int32_t const & currentValue = mPort;
673
0
    temp.setInt32(int32_t(currentValue));
674
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->port_id, temp, JSPROP_ENUMERATE)) {
675
0
      return false;
676
0
    }
677
0
    break;
678
0
  } while(false);
679
0
680
0
  do {
681
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
682
0
    JS::Rooted<JS::Value> temp(cx);
683
0
    bool const & currentValue = mProxyDNS;
684
0
    temp.setBoolean(currentValue);
685
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->proxyDNS_id, temp, JSPROP_ENUMERATE)) {
686
0
      return false;
687
0
    }
688
0
    break;
689
0
  } while(false);
690
0
691
0
  do {
692
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
693
0
    JS::Rooted<JS::Value> temp(cx);
694
0
    nsCString const & currentValue = mType;
695
0
    if (!NonVoidByteStringToJsval(cx, currentValue, &temp)) {
696
0
      return false;
697
0
    }
698
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->type_id, temp, JSPROP_ENUMERATE)) {
699
0
      return false;
700
0
    }
701
0
    break;
702
0
  } while(false);
703
0
704
0
  do {
705
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
706
0
    JS::Rooted<JS::Value> temp(cx);
707
0
    nsCString const & currentValue = mUsername;
708
0
    if (!ByteStringToJsval(cx, currentValue, &temp)) {
709
0
      return false;
710
0
    }
711
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->username_id, temp, JSPROP_ENUMERATE)) {
712
0
      return false;
713
0
    }
714
0
    break;
715
0
  } while(false);
716
0
717
0
  return true;
718
0
}
719
720
bool
721
MozProxyInfo::ToJSON(nsAString& aJSON) const
722
0
{
723
0
  AutoJSAPI jsapi;
724
0
  jsapi.Init();
725
0
  JSContext *cx = jsapi.cx();
726
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
727
0
  // because we'll only be creating objects, in ways that have no
728
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
729
0
  // which likewise guarantees no side-effects for the sorts of
730
0
  // things we will pass it.
731
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
732
0
  JS::Rooted<JS::Value> val(cx);
733
0
  if (!ToObjectInternal(cx, &val)) {
734
0
    return false;
735
0
  }
736
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
737
0
  return StringifyToJSON(cx, obj, aJSON);
738
0
}
739
740
void
741
MozProxyInfo::TraceDictionary(JSTracer* trc)
742
0
{
743
0
}
744
745
MozProxyInfo&
746
MozProxyInfo::operator=(const MozProxyInfo& aOther)
747
0
{
748
0
  DictionaryBase::operator=(aOther);
749
0
  mFailoverTimeout.Reset();
750
0
  if (aOther.mFailoverTimeout.WasPassed()) {
751
0
    mFailoverTimeout.Construct(aOther.mFailoverTimeout.Value());
752
0
  }
753
0
  mHost = aOther.mHost;
754
0
  mPort = aOther.mPort;
755
0
  mProxyDNS = aOther.mProxyDNS;
756
0
  mType = aOther.mType;
757
0
  mUsername = aOther.mUsername;
758
0
  return *this;
759
0
}
760
761
namespace binding_detail {
762
} // namespace binding_detail
763
764
765
766
MozRequestFilter::MozRequestFilter()
767
0
{
768
0
  // Safe to pass a null context if we pass a null value
769
0
  Init(nullptr, JS::NullHandleValue);
770
0
}
771
772
773
774
bool
775
MozRequestFilter::InitIds(JSContext* cx, MozRequestFilterAtoms* atomsCache)
776
0
{
777
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
778
0
779
0
  // Initialize these in reverse order so that any failure leaves the first one
780
0
  // uninitialized.
781
0
  if (!atomsCache->urls_id.init(cx, "urls") ||
782
0
      !atomsCache->types_id.init(cx, "types")) {
783
0
    return false;
784
0
  }
785
0
  return true;
786
0
}
787
788
bool
789
MozRequestFilter::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
790
0
{
791
0
  // Passing a null JSContext is OK only if we're initing from null,
792
0
  // Since in that case we will not have to do any property gets
793
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
794
0
  // checkers by static analysis tools
795
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
796
0
  MozRequestFilterAtoms* atomsCache = nullptr;
797
0
  if (cx) {
798
0
    atomsCache = GetAtomCache<MozRequestFilterAtoms>(cx);
799
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
800
0
      return false;
801
0
    }
802
0
  }
803
0
804
0
  if (!IsConvertibleToDictionary(val)) {
805
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
806
0
  }
807
0
808
0
  bool isNull = val.isNullOrUndefined();
809
0
  // We only need these if !isNull, in which case we have |cx|.
810
0
  Maybe<JS::Rooted<JSObject *> > object;
811
0
  Maybe<JS::Rooted<JS::Value> > temp;
812
0
  if (!isNull) {
813
0
    MOZ_ASSERT(cx);
814
0
    object.emplace(cx, &val.toObject());
815
0
    temp.emplace(cx);
816
0
  }
817
0
  if (!isNull) {
818
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->types_id, temp.ptr())) {
819
0
      return false;
820
0
    }
821
0
  }
822
0
  if (!isNull && !temp->isUndefined()) {
823
0
    if (temp.ref().isObject()) {
824
0
      JS::ForOfIterator iter(cx);
825
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
826
0
        return false;
827
0
      }
828
0
      if (!iter.valueIsIterable()) {
829
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'types' member of MozRequestFilter");
830
0
        return false;
831
0
      }
832
0
      Sequence<MozContentPolicyType> &arr = mTypes.SetValue();
833
0
      JS::Rooted<JS::Value> temp(cx);
834
0
      while (true) {
835
0
        bool done;
836
0
        if (!iter.next(&temp, &done)) {
837
0
          return false;
838
0
        }
839
0
        if (done) {
840
0
          break;
841
0
        }
842
0
        MozContentPolicyType* slotPtr = arr.AppendElement(mozilla::fallible);
843
0
        if (!slotPtr) {
844
0
          JS_ReportOutOfMemory(cx);
845
0
          return false;
846
0
        }
847
0
        MozContentPolicyType& slot = *slotPtr;
848
0
        {
849
0
          int index;
850
0
          if (!FindEnumStringIndex<true>(cx, temp, MozContentPolicyTypeValues::strings, "MozContentPolicyType", "Element of 'types' member of MozRequestFilter", &index)) {
851
0
            return false;
852
0
          }
853
0
          MOZ_ASSERT(index >= 0);
854
0
          slot = static_cast<MozContentPolicyType>(index);
855
0
        }
856
0
      }
857
0
    } else if (temp.ref().isNullOrUndefined()) {
858
0
      mTypes.SetNull();
859
0
    } else {
860
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'types' member of MozRequestFilter");
861
0
      return false;
862
0
    }
863
0
  } else {
864
0
    mTypes.SetNull();
865
0
  }
866
0
  mIsAnyMemberPresent = true;
867
0
868
0
  if (!isNull) {
869
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->urls_id, temp.ptr())) {
870
0
      return false;
871
0
    }
872
0
  }
873
0
  if (!isNull && !temp->isUndefined()) {
874
0
    if (temp.ref().isObject()) {
875
0
      static_assert(IsRefcounted<mozilla::extensions::MatchPatternSet>::value, "We can only store refcounted classes.");{
876
0
        nsresult rv = UnwrapObject<prototypes::id::MatchPatternSet, mozilla::extensions::MatchPatternSet>(temp.ptr(), mUrls);
877
0
        if (NS_FAILED(rv)) {
878
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'urls' member of MozRequestFilter", "MatchPatternSet");
879
0
          return false;
880
0
        }
881
0
      }
882
0
    } else if (temp.ref().isNullOrUndefined()) {
883
0
      mUrls = nullptr;
884
0
    } else {
885
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'urls' member of MozRequestFilter");
886
0
      return false;
887
0
    }
888
0
  } else {
889
0
    mUrls = nullptr;
890
0
  }
891
0
  mIsAnyMemberPresent = true;
892
0
  return true;
893
0
}
894
895
bool
896
MozRequestFilter::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
897
0
{
898
0
  MozRequestFilterAtoms* atomsCache = GetAtomCache<MozRequestFilterAtoms>(cx);
899
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
900
0
    return false;
901
0
  }
902
0
903
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
904
0
  if (!obj) {
905
0
    return false;
906
0
  }
907
0
  rval.set(JS::ObjectValue(*obj));
908
0
909
0
  do {
910
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
911
0
    JS::Rooted<JS::Value> temp(cx);
912
0
    Nullable<Sequence<MozContentPolicyType>> const & currentValue = mTypes;
913
0
914
0
    if (currentValue.IsNull()) {
915
0
      temp.setNull();
916
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->types_id, temp, JSPROP_ENUMERATE)) {
917
0
        return false;
918
0
      }
919
0
      break;
920
0
    }
921
0
922
0
    uint32_t length = currentValue.Value().Length();
923
0
    JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
924
0
    if (!returnArray) {
925
0
      return false;
926
0
    }
927
0
    // Scope for 'tmp'
928
0
    {
929
0
      JS::Rooted<JS::Value> tmp(cx);
930
0
      for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
931
0
        // Control block to let us common up the JS_DefineElement calls when there
932
0
        // are different ways to succeed at wrapping the object.
933
0
        do {
934
0
          if (!ToJSValue(cx, currentValue.Value()[sequenceIdx0], &tmp)) {
935
0
            return false;
936
0
          }
937
0
          break;
938
0
        } while (false);
939
0
        if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
940
0
                              JSPROP_ENUMERATE)) {
941
0
          return false;
942
0
        }
943
0
      }
944
0
    }
945
0
    temp.setObject(*returnArray);
946
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->types_id, temp, JSPROP_ENUMERATE)) {
947
0
      return false;
948
0
    }
949
0
    break;
950
0
  } while(false);
951
0
952
0
  do {
953
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
954
0
    JS::Rooted<JS::Value> temp(cx);
955
0
    RefPtr<mozilla::extensions::MatchPatternSet> const & currentValue = mUrls;
956
0
    if (!currentValue) {
957
0
      temp.setNull();
958
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->urls_id, temp, JSPROP_ENUMERATE)) {
959
0
        return false;
960
0
      }
961
0
      break;
962
0
    }
963
0
    if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
964
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
965
0
      return false;
966
0
    }
967
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->urls_id, temp, JSPROP_ENUMERATE)) {
968
0
      return false;
969
0
    }
970
0
    break;
971
0
  } while(false);
972
0
973
0
  return true;
974
0
}
975
976
void
977
MozRequestFilter::TraceDictionary(JSTracer* trc)
978
0
{
979
0
}
980
981
982
983
MozRequestFilter&
984
MozRequestFilter::operator=(const MozRequestFilter& aOther)
985
0
{
986
0
  DictionaryBase::operator=(aOther);
987
0
  mTypes = aOther.mTypes;
988
0
  mUrls = aOther.mUrls;
989
0
  return *this;
990
0
}
991
992
namespace binding_detail {
993
} // namespace binding_detail
994
995
996
997
MozRequestMatchOptions::MozRequestMatchOptions()
998
0
{
999
0
  // Safe to pass a null context if we pass a null value
1000
0
  Init(nullptr, JS::NullHandleValue);
1001
0
}
1002
1003
1004
1005
bool
1006
MozRequestMatchOptions::InitIds(JSContext* cx, MozRequestMatchOptionsAtoms* atomsCache)
1007
0
{
1008
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1009
0
1010
0
  // Initialize these in reverse order so that any failure leaves the first one
1011
0
  // uninitialized.
1012
0
  if (!atomsCache->isProxy_id.init(cx, "isProxy")) {
1013
0
    return false;
1014
0
  }
1015
0
  return true;
1016
0
}
1017
1018
bool
1019
MozRequestMatchOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1020
0
{
1021
0
  // Passing a null JSContext is OK only if we're initing from null,
1022
0
  // Since in that case we will not have to do any property gets
1023
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1024
0
  // checkers by static analysis tools
1025
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1026
0
  MozRequestMatchOptionsAtoms* atomsCache = nullptr;
1027
0
  if (cx) {
1028
0
    atomsCache = GetAtomCache<MozRequestMatchOptionsAtoms>(cx);
1029
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1030
0
      return false;
1031
0
    }
1032
0
  }
1033
0
1034
0
  if (!IsConvertibleToDictionary(val)) {
1035
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1036
0
  }
1037
0
1038
0
  bool isNull = val.isNullOrUndefined();
1039
0
  // We only need these if !isNull, in which case we have |cx|.
1040
0
  Maybe<JS::Rooted<JSObject *> > object;
1041
0
  Maybe<JS::Rooted<JS::Value> > temp;
1042
0
  if (!isNull) {
1043
0
    MOZ_ASSERT(cx);
1044
0
    object.emplace(cx, &val.toObject());
1045
0
    temp.emplace(cx);
1046
0
  }
1047
0
  if (!isNull) {
1048
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->isProxy_id, temp.ptr())) {
1049
0
      return false;
1050
0
    }
1051
0
  }
1052
0
  if (!isNull && !temp->isUndefined()) {
1053
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mIsProxy)) {
1054
0
      return false;
1055
0
    }
1056
0
  } else {
1057
0
    mIsProxy = false;
1058
0
  }
1059
0
  mIsAnyMemberPresent = true;
1060
0
  return true;
1061
0
}
1062
1063
bool
1064
MozRequestMatchOptions::Init(const nsAString& aJSON)
1065
0
{
1066
0
  AutoJSAPI jsapi;
1067
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1068
0
  if (!cleanGlobal) {
1069
0
    return false;
1070
0
  }
1071
0
  if (!jsapi.Init(cleanGlobal)) {
1072
0
    return false;
1073
0
  }
1074
0
  JSContext* cx = jsapi.cx();
1075
0
  JS::Rooted<JS::Value> json(cx);
1076
0
  bool ok = ParseJSON(cx, aJSON, &json);
1077
0
  NS_ENSURE_TRUE(ok, false);
1078
0
  return Init(cx, json);
1079
0
}
1080
1081
bool
1082
MozRequestMatchOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1083
0
{
1084
0
  MozRequestMatchOptionsAtoms* atomsCache = GetAtomCache<MozRequestMatchOptionsAtoms>(cx);
1085
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1086
0
    return false;
1087
0
  }
1088
0
1089
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1090
0
  if (!obj) {
1091
0
    return false;
1092
0
  }
1093
0
  rval.set(JS::ObjectValue(*obj));
1094
0
1095
0
  do {
1096
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1097
0
    JS::Rooted<JS::Value> temp(cx);
1098
0
    bool const & currentValue = mIsProxy;
1099
0
    temp.setBoolean(currentValue);
1100
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->isProxy_id, temp, JSPROP_ENUMERATE)) {
1101
0
      return false;
1102
0
    }
1103
0
    break;
1104
0
  } while(false);
1105
0
1106
0
  return true;
1107
0
}
1108
1109
bool
1110
MozRequestMatchOptions::ToJSON(nsAString& aJSON) const
1111
0
{
1112
0
  AutoJSAPI jsapi;
1113
0
  jsapi.Init();
1114
0
  JSContext *cx = jsapi.cx();
1115
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1116
0
  // because we'll only be creating objects, in ways that have no
1117
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1118
0
  // which likewise guarantees no side-effects for the sorts of
1119
0
  // things we will pass it.
1120
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1121
0
  JS::Rooted<JS::Value> val(cx);
1122
0
  if (!ToObjectInternal(cx, &val)) {
1123
0
    return false;
1124
0
  }
1125
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1126
0
  return StringifyToJSON(cx, obj, aJSON);
1127
0
}
1128
1129
void
1130
MozRequestMatchOptions::TraceDictionary(JSTracer* trc)
1131
0
{
1132
0
}
1133
1134
MozRequestMatchOptions&
1135
MozRequestMatchOptions::operator=(const MozRequestMatchOptions& aOther)
1136
0
{
1137
0
  DictionaryBase::operator=(aOther);
1138
0
  mIsProxy = aOther.mIsProxy;
1139
0
  return *this;
1140
0
}
1141
1142
namespace binding_detail {
1143
} // namespace binding_detail
1144
1145
1146
namespace ChannelWrapper_Binding {
1147
1148
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
1149
              "Can't inherit from an interface with a different ownership model.");
1150
1151
static bool
1152
get(JSContext* cx, unsigned argc, JS::Value* vp)
1153
0
{
1154
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.get", DOM, cx);
1155
0
1156
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1157
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1158
0
1159
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1160
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelWrapper.get");
1161
0
  }
1162
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
1163
0
  if (global.Failed()) {
1164
0
    return false;
1165
0
  }
1166
0
1167
0
  nsIChannel* arg0;
1168
0
  RefPtr<nsIChannel> arg0_holder;
1169
0
  if (args[0].isObject()) {
1170
0
    JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1171
0
    if (NS_FAILED(UnwrapArg<nsIChannel>(cx, source, getter_AddRefs(arg0_holder)))) {
1172
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ChannelWrapper.get", "MozChannel");
1173
0
      return false;
1174
0
    }
1175
0
    MOZ_ASSERT(arg0_holder);
1176
0
    arg0 = arg0_holder;
1177
0
  } else {
1178
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ChannelWrapper.get");
1179
0
    return false;
1180
0
  }
1181
0
  auto result(StrongOrRawPtr<mozilla::extensions::ChannelWrapper>(mozilla::extensions::ChannelWrapper::Get(global, MOZ_KnownLive(NonNullHelper(arg0)))));
1182
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1183
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1184
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1185
0
    return false;
1186
0
  }
1187
0
  return true;
1188
0
}
1189
1190
static bool
1191
getRegisteredChannel(JSContext* cx, unsigned argc, JS::Value* vp)
1192
0
{
1193
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.getRegisteredChannel", DOM, cx);
1194
0
1195
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1196
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1197
0
1198
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
1199
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelWrapper.getRegisteredChannel");
1200
0
  }
1201
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
1202
0
  if (global.Failed()) {
1203
0
    return false;
1204
0
  }
1205
0
1206
0
  uint64_t arg0;
1207
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[0], &arg0)) {
1208
0
    return false;
1209
0
  }
1210
0
  NonNull<mozilla::extensions::WebExtensionPolicy> arg1;
1211
0
  if (args[1].isObject()) {
1212
0
    {
1213
0
      nsresult rv = UnwrapObject<prototypes::id::WebExtensionPolicy, mozilla::extensions::WebExtensionPolicy>(args[1], arg1);
1214
0
      if (NS_FAILED(rv)) {
1215
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of ChannelWrapper.getRegisteredChannel", "WebExtensionPolicy");
1216
0
        return false;
1217
0
      }
1218
0
    }
1219
0
  } else {
1220
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of ChannelWrapper.getRegisteredChannel");
1221
0
    return false;
1222
0
  }
1223
0
  nsITabParent* arg2;
1224
0
  RefPtr<nsITabParent> arg2_holder;
1225
0
  if (args[2].isObject()) {
1226
0
    JS::Rooted<JSObject*> source(cx, &args[2].toObject());
1227
0
    if (NS_FAILED(UnwrapArg<nsITabParent>(cx, source, getter_AddRefs(arg2_holder)))) {
1228
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 3 of ChannelWrapper.getRegisteredChannel", "TabParent");
1229
0
      return false;
1230
0
    }
1231
0
    MOZ_ASSERT(arg2_holder);
1232
0
    arg2 = arg2_holder;
1233
0
  } else if (args[2].isNullOrUndefined()) {
1234
0
    arg2 = nullptr;
1235
0
  } else {
1236
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 3 of ChannelWrapper.getRegisteredChannel");
1237
0
    return false;
1238
0
  }
1239
0
  auto result(StrongOrRawPtr<mozilla::extensions::ChannelWrapper>(mozilla::extensions::ChannelWrapper::GetRegisteredChannel(global, arg0, MOZ_KnownLive(NonNullHelper(arg1)), MOZ_KnownLive(Constify(arg2)))));
1240
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1241
0
  if (!result) {
1242
0
    args.rval().setNull();
1243
0
    return true;
1244
0
  }
1245
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1246
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1247
0
    return false;
1248
0
  }
1249
0
  return true;
1250
0
}
1251
1252
static bool
1253
get_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1254
0
{
1255
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.id", DOM, cx);
1256
0
1257
0
  // Have to either root across the getter call or reget after.
1258
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
1259
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
1260
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 0);
1261
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1262
0
  {
1263
0
    // Scope for cachedVal
1264
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1265
0
    if (!cachedVal.isUndefined()) {
1266
0
      args.rval().set(cachedVal);
1267
0
      // The cached value is in the compartment of slotStorage,
1268
0
      // so wrap into the caller compartment as needed.
1269
0
      if (MaybeWrapValue(cx, args.rval())) {
1270
0
        return true;
1271
0
      }
1272
0
      return false;
1273
0
    }
1274
0
  }
1275
0
1276
0
  uint64_t result(self->Id());
1277
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1278
0
  {
1279
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
1280
0
    JSAutoRealm ar(cx, conversionScope);
1281
0
    do { // block we break out of when done wrapping
1282
0
      args.rval().set(JS_NumberValue(double(result)));
1283
0
      break;
1284
0
    } while (false);
1285
0
  }
1286
0
  { // And now store things in the realm of our slotStorage.
1287
0
    JSAutoRealm ar(cx, slotStorage);
1288
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1289
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1290
0
    if (!MaybeWrapValue(cx, &storedVal)) {
1291
0
      return false;
1292
0
    }
1293
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1294
0
  }
1295
0
  // And now make sure args.rval() is in the caller realm.
1296
0
  if (MaybeWrapValue(cx, args.rval())) {
1297
0
    return true;
1298
0
  }
1299
0
  return false;
1300
0
}
1301
1302
static const JSJitInfo id_getterinfo = {
1303
  { (JSJitGetterOp)get_id },
1304
  { prototypes::id::ChannelWrapper },
1305
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1306
  JSJitInfo::Getter,
1307
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
1308
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1309
  true,  /* isInfallible. False in setters. */
1310
  true,  /* isMovable.  Not relevant for setters. */
1311
  true, /* isEliminatable.  Not relevant for setters. */
1312
  true, /* isAlwaysInSlot.  Only relevant for getters. */
1313
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1314
  false,  /* isTypedMethod.  Only relevant for methods. */
1315
  (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
1316
};
1317
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
1318
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 20, "There is no slot for us");
1319
1320
MOZ_CAN_RUN_SCRIPT static bool
1321
get_channel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1322
0
{
1323
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.channel", DOM, cx);
1324
0
1325
0
  auto result(StrongOrRawPtr<nsIChannel>(self->GetChannel()));
1326
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1327
0
  if (!result) {
1328
0
    args.rval().setNull();
1329
0
    return true;
1330
0
  }
1331
0
  if (!WrapObject(cx, result, &NS_GET_IID(nsIChannel), args.rval())) {
1332
0
    return false;
1333
0
  }
1334
0
  return true;
1335
0
}
1336
1337
MOZ_CAN_RUN_SCRIPT static bool
1338
set_channel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitSetterCallArgs args)
1339
0
{
1340
0
  AUTO_PROFILER_LABEL_FAST("set ChannelWrapper.channel", DOM, cx);
1341
0
1342
0
  nsIChannel* arg0;
1343
0
  RefPtr<nsIChannel> arg0_holder;
1344
0
  if (args[0].isObject()) {
1345
0
    JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1346
0
    if (NS_FAILED(UnwrapArg<nsIChannel>(cx, source, getter_AddRefs(arg0_holder)))) {
1347
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to ChannelWrapper.channel", "MozChannel");
1348
0
      return false;
1349
0
    }
1350
0
    MOZ_ASSERT(arg0_holder);
1351
0
    arg0 = arg0_holder;
1352
0
  } else if (args[0].isNullOrUndefined()) {
1353
0
    arg0 = nullptr;
1354
0
  } else {
1355
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to ChannelWrapper.channel");
1356
0
    return false;
1357
0
  }
1358
0
  self->SetChannel(MOZ_KnownLive(Constify(arg0)));
1359
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1360
0
1361
0
  return true;
1362
0
}
1363
1364
static const JSJitInfo channel_getterinfo = {
1365
  { (JSJitGetterOp)get_channel },
1366
  { prototypes::id::ChannelWrapper },
1367
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1368
  JSJitInfo::Getter,
1369
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1370
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1371
  false,  /* isInfallible. False in setters. */
1372
  true,  /* isMovable.  Not relevant for setters. */
1373
  true, /* isEliminatable.  Not relevant for setters. */
1374
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1375
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1376
  false,  /* isTypedMethod.  Only relevant for methods. */
1377
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1378
};
1379
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1380
static_assert(0 < 20, "There is no slot for us");
1381
static const JSJitInfo channel_setterinfo = {
1382
  { (JSJitGetterOp)set_channel },
1383
  { prototypes::id::ChannelWrapper },
1384
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1385
  JSJitInfo::Setter,
1386
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1387
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1388
  false,  /* isInfallible. False in setters. */
1389
  false,  /* isMovable.  Not relevant for setters. */
1390
  false, /* isEliminatable.  Not relevant for setters. */
1391
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1392
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1393
  false,  /* isTypedMethod.  Only relevant for methods. */
1394
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1395
};
1396
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1397
static_assert(0 < 20, "There is no slot for us");
1398
1399
MOZ_CAN_RUN_SCRIPT static bool
1400
cancel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
1401
0
{
1402
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.cancel", DOM, cx);
1403
0
1404
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1405
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelWrapper.cancel");
1406
0
  }
1407
0
  uint32_t arg0;
1408
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
1409
0
    return false;
1410
0
  }
1411
0
  FastErrorResult rv;
1412
0
  self->Cancel(arg0, rv);
1413
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1414
0
    return false;
1415
0
  }
1416
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1417
0
  args.rval().setUndefined();
1418
0
  return true;
1419
0
}
1420
1421
static const JSJitInfo cancel_methodinfo = {
1422
  { (JSJitGetterOp)cancel },
1423
  { prototypes::id::ChannelWrapper },
1424
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1425
  JSJitInfo::Method,
1426
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1427
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1428
  false,  /* isInfallible. False in setters. */
1429
  false,  /* isMovable.  Not relevant for setters. */
1430
  false, /* isEliminatable.  Not relevant for setters. */
1431
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1432
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1433
  false,  /* isTypedMethod.  Only relevant for methods. */
1434
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1435
};
1436
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1437
static_assert(0 < 20, "There is no slot for us");
1438
1439
MOZ_CAN_RUN_SCRIPT static bool
1440
redirectTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
1441
0
{
1442
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.redirectTo", DOM, cx);
1443
0
1444
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1445
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelWrapper.redirectTo");
1446
0
  }
1447
0
  nsIURI* arg0;
1448
0
  RefPtr<nsIURI> arg0_holder;
1449
0
  if (args[0].isObject()) {
1450
0
    JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1451
0
    if (NS_FAILED(UnwrapArg<nsIURI>(cx, source, getter_AddRefs(arg0_holder)))) {
1452
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ChannelWrapper.redirectTo", "URI");
1453
0
      return false;
1454
0
    }
1455
0
    MOZ_ASSERT(arg0_holder);
1456
0
    arg0 = arg0_holder;
1457
0
  } else {
1458
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ChannelWrapper.redirectTo");
1459
0
    return false;
1460
0
  }
1461
0
  FastErrorResult rv;
1462
0
  self->RedirectTo(MOZ_KnownLive(NonNullHelper(arg0)), rv);
1463
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1464
0
    return false;
1465
0
  }
1466
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1467
0
  args.rval().setUndefined();
1468
0
  return true;
1469
0
}
1470
1471
static const JSJitInfo redirectTo_methodinfo = {
1472
  { (JSJitGetterOp)redirectTo },
1473
  { prototypes::id::ChannelWrapper },
1474
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1475
  JSJitInfo::Method,
1476
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1477
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1478
  false,  /* isInfallible. False in setters. */
1479
  false,  /* isMovable.  Not relevant for setters. */
1480
  false, /* isEliminatable.  Not relevant for setters. */
1481
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1482
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1483
  false,  /* isTypedMethod.  Only relevant for methods. */
1484
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1485
};
1486
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1487
static_assert(0 < 20, "There is no slot for us");
1488
1489
MOZ_CAN_RUN_SCRIPT static bool
1490
upgradeToSecure(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
1491
0
{
1492
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.upgradeToSecure", DOM, cx);
1493
0
1494
0
  FastErrorResult rv;
1495
0
  self->UpgradeToSecure(rv);
1496
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1497
0
    return false;
1498
0
  }
1499
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1500
0
  args.rval().setUndefined();
1501
0
  return true;
1502
0
}
1503
1504
static const JSJitInfo upgradeToSecure_methodinfo = {
1505
  { (JSJitGetterOp)upgradeToSecure },
1506
  { prototypes::id::ChannelWrapper },
1507
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1508
  JSJitInfo::Method,
1509
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1510
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1511
  false,  /* isInfallible. False in setters. */
1512
  false,  /* isMovable.  Not relevant for setters. */
1513
  false, /* isEliminatable.  Not relevant for setters. */
1514
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1515
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1516
  false,  /* isTypedMethod.  Only relevant for methods. */
1517
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1518
};
1519
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1520
static_assert(0 < 20, "There is no slot for us");
1521
1522
MOZ_CAN_RUN_SCRIPT static bool
1523
get_contentType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1524
0
{
1525
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.contentType", DOM, cx);
1526
0
1527
0
  nsCString result;
1528
0
  self->GetContentType(result);
1529
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1530
0
  if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
1531
0
    return false;
1532
0
  }
1533
0
  return true;
1534
0
}
1535
1536
MOZ_CAN_RUN_SCRIPT static bool
1537
set_contentType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitSetterCallArgs args)
1538
0
{
1539
0
  AUTO_PROFILER_LABEL_FAST("set ChannelWrapper.contentType", DOM, cx);
1540
0
1541
0
  nsCString arg0;
1542
0
  if (!ConvertJSValueToByteString(cx, args[0], false, arg0)) {
1543
0
    return false;
1544
0
  }
1545
0
  self->SetContentType(Constify(arg0));
1546
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1547
0
1548
0
  return true;
1549
0
}
1550
1551
static const JSJitInfo contentType_getterinfo = {
1552
  { (JSJitGetterOp)get_contentType },
1553
  { prototypes::id::ChannelWrapper },
1554
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1555
  JSJitInfo::Getter,
1556
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1557
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1558
  false,  /* isInfallible. False in setters. */
1559
  true,  /* isMovable.  Not relevant for setters. */
1560
  true, /* isEliminatable.  Not relevant for setters. */
1561
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1562
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1563
  false,  /* isTypedMethod.  Only relevant for methods. */
1564
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1565
};
1566
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1567
static_assert(0 < 20, "There is no slot for us");
1568
static const JSJitInfo contentType_setterinfo = {
1569
  { (JSJitGetterOp)set_contentType },
1570
  { prototypes::id::ChannelWrapper },
1571
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1572
  JSJitInfo::Setter,
1573
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1574
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1575
  false,  /* isInfallible. False in setters. */
1576
  false,  /* isMovable.  Not relevant for setters. */
1577
  false, /* isEliminatable.  Not relevant for setters. */
1578
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1579
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1580
  false,  /* isTypedMethod.  Only relevant for methods. */
1581
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1582
};
1583
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1584
static_assert(0 < 20, "There is no slot for us");
1585
1586
MOZ_CAN_RUN_SCRIPT static bool
1587
get_method(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1588
0
{
1589
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.method", DOM, cx);
1590
0
1591
0
  // Have to either root across the getter call or reget after.
1592
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
1593
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
1594
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 1);
1595
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1596
0
  {
1597
0
    // Scope for cachedVal
1598
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1599
0
    if (!cachedVal.isUndefined()) {
1600
0
      args.rval().set(cachedVal);
1601
0
      // The cached value is in the compartment of slotStorage,
1602
0
      // so wrap into the caller compartment as needed.
1603
0
      if (MaybeWrapValue(cx, args.rval())) {
1604
0
        return true;
1605
0
      }
1606
0
      return false;
1607
0
    }
1608
0
  }
1609
0
1610
0
  nsCString result;
1611
0
  self->GetMethod(result);
1612
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1613
0
  {
1614
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
1615
0
    JSAutoRealm ar(cx, conversionScope);
1616
0
    do { // block we break out of when done wrapping
1617
0
      if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
1618
0
        return false;
1619
0
      }
1620
0
      break;
1621
0
    } while (false);
1622
0
  }
1623
0
  { // And now store things in the realm of our slotStorage.
1624
0
    JSAutoRealm ar(cx, slotStorage);
1625
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1626
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1627
0
    if (!MaybeWrapValue(cx, &storedVal)) {
1628
0
      return false;
1629
0
    }
1630
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1631
0
    PreserveWrapper(self);
1632
0
  }
1633
0
  // And now make sure args.rval() is in the caller realm.
1634
0
  if (MaybeWrapValue(cx, args.rval())) {
1635
0
    return true;
1636
0
  }
1637
0
  return false;
1638
0
}
1639
1640
static const JSJitInfo method_getterinfo = {
1641
  { (JSJitGetterOp)get_method },
1642
  { prototypes::id::ChannelWrapper },
1643
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1644
  JSJitInfo::Getter,
1645
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1646
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1647
  false,  /* isInfallible. False in setters. */
1648
  true,  /* isMovable.  Not relevant for setters. */
1649
  true, /* isEliminatable.  Not relevant for setters. */
1650
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1651
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
1652
  false,  /* isTypedMethod.  Only relevant for methods. */
1653
  (DOM_INSTANCE_RESERVED_SLOTS + 1)   /* Reserved slot index, if we're stored in a slot, else 0. */
1654
};
1655
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 1) <= JSJitInfo::maxSlotIndex, "We won't fit");
1656
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 1) < 20, "There is no slot for us");
1657
1658
MOZ_CAN_RUN_SCRIPT static bool
1659
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1660
0
{
1661
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.type", DOM, cx);
1662
0
1663
0
  // Have to either root across the getter call or reget after.
1664
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
1665
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
1666
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 2);
1667
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1668
0
  {
1669
0
    // Scope for cachedVal
1670
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1671
0
    if (!cachedVal.isUndefined()) {
1672
0
      args.rval().set(cachedVal);
1673
0
      // The cached value is in the compartment of slotStorage,
1674
0
      // so wrap into the caller compartment as needed.
1675
0
      if (MaybeWrapValue(cx, args.rval())) {
1676
0
        return true;
1677
0
      }
1678
0
      return false;
1679
0
    }
1680
0
  }
1681
0
1682
0
  MozContentPolicyType result(self->Type());
1683
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1684
0
  {
1685
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
1686
0
    JSAutoRealm ar(cx, conversionScope);
1687
0
    do { // block we break out of when done wrapping
1688
0
      if (!ToJSValue(cx, result, args.rval())) {
1689
0
        return false;
1690
0
      }
1691
0
      break;
1692
0
    } while (false);
1693
0
  }
1694
0
  { // And now store things in the realm of our slotStorage.
1695
0
    JSAutoRealm ar(cx, slotStorage);
1696
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1697
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1698
0
    if (!MaybeWrapValue(cx, &storedVal)) {
1699
0
      return false;
1700
0
    }
1701
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1702
0
    PreserveWrapper(self);
1703
0
  }
1704
0
  // And now make sure args.rval() is in the caller realm.
1705
0
  if (MaybeWrapValue(cx, args.rval())) {
1706
0
    return true;
1707
0
  }
1708
0
  return false;
1709
0
}
1710
1711
static const JSJitInfo type_getterinfo = {
1712
  { (JSJitGetterOp)get_type },
1713
  { prototypes::id::ChannelWrapper },
1714
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1715
  JSJitInfo::Getter,
1716
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1717
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1718
  false,  /* isInfallible. False in setters. */
1719
  true,  /* isMovable.  Not relevant for setters. */
1720
  true, /* isEliminatable.  Not relevant for setters. */
1721
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1722
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
1723
  false,  /* isTypedMethod.  Only relevant for methods. */
1724
  (DOM_INSTANCE_RESERVED_SLOTS + 2)   /* Reserved slot index, if we're stored in a slot, else 0. */
1725
};
1726
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 2) <= JSJitInfo::maxSlotIndex, "We won't fit");
1727
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 2) < 20, "There is no slot for us");
1728
1729
MOZ_CAN_RUN_SCRIPT static bool
1730
get_suspended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1731
0
{
1732
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.suspended", DOM, cx);
1733
0
1734
0
  bool result(self->Suspended());
1735
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1736
0
  args.rval().setBoolean(result);
1737
0
  return true;
1738
0
}
1739
1740
MOZ_CAN_RUN_SCRIPT static bool
1741
set_suspended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitSetterCallArgs args)
1742
0
{
1743
0
  AUTO_PROFILER_LABEL_FAST("set ChannelWrapper.suspended", DOM, cx);
1744
0
1745
0
  bool arg0;
1746
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
1747
0
    return false;
1748
0
  }
1749
0
  FastErrorResult rv;
1750
0
  self->SetSuspended(arg0, rv);
1751
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1752
0
    return false;
1753
0
  }
1754
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1755
0
1756
0
  return true;
1757
0
}
1758
1759
static const JSJitInfo suspended_getterinfo = {
1760
  { (JSJitGetterOp)get_suspended },
1761
  { prototypes::id::ChannelWrapper },
1762
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1763
  JSJitInfo::Getter,
1764
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1765
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1766
  true,  /* isInfallible. False in setters. */
1767
  true,  /* isMovable.  Not relevant for setters. */
1768
  true, /* isEliminatable.  Not relevant for setters. */
1769
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1770
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1771
  false,  /* isTypedMethod.  Only relevant for methods. */
1772
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1773
};
1774
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1775
static_assert(0 < 20, "There is no slot for us");
1776
static const JSJitInfo suspended_setterinfo = {
1777
  { (JSJitGetterOp)set_suspended },
1778
  { prototypes::id::ChannelWrapper },
1779
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1780
  JSJitInfo::Setter,
1781
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1782
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1783
  false,  /* isInfallible. False in setters. */
1784
  false,  /* isMovable.  Not relevant for setters. */
1785
  false, /* isEliminatable.  Not relevant for setters. */
1786
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1787
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1788
  false,  /* isTypedMethod.  Only relevant for methods. */
1789
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1790
};
1791
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1792
static_assert(0 < 20, "There is no slot for us");
1793
1794
MOZ_CAN_RUN_SCRIPT static bool
1795
get_finalURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1796
0
{
1797
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.finalURI", DOM, cx);
1798
0
1799
0
  // Have to either root across the getter call or reget after.
1800
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
1801
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
1802
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 3);
1803
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1804
0
  {
1805
0
    // Scope for cachedVal
1806
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1807
0
    if (!cachedVal.isUndefined()) {
1808
0
      args.rval().set(cachedVal);
1809
0
      // The cached value is in the compartment of slotStorage,
1810
0
      // so wrap into the caller compartment as needed.
1811
0
      if (MaybeWrapValue(cx, args.rval())) {
1812
0
        return true;
1813
0
      }
1814
0
      return false;
1815
0
    }
1816
0
  }
1817
0
1818
0
  auto result(StrongOrRawPtr<nsIURI>(self->FinalURI()));
1819
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1820
0
  {
1821
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
1822
0
    JSAutoRealm ar(cx, conversionScope);
1823
0
    do { // block we break out of when done wrapping
1824
0
      if (!WrapObject(cx, result, &NS_GET_IID(nsIURI), args.rval())) {
1825
0
        return false;
1826
0
      }
1827
0
      break;
1828
0
    } while (false);
1829
0
  }
1830
0
  { // And now store things in the realm of our slotStorage.
1831
0
    JSAutoRealm ar(cx, slotStorage);
1832
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1833
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1834
0
    if (!MaybeWrapValue(cx, &storedVal)) {
1835
0
      return false;
1836
0
    }
1837
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1838
0
    PreserveWrapper(self);
1839
0
  }
1840
0
  // And now make sure args.rval() is in the caller realm.
1841
0
  if (MaybeWrapValue(cx, args.rval())) {
1842
0
    return true;
1843
0
  }
1844
0
  return false;
1845
0
}
1846
1847
static const JSJitInfo finalURI_getterinfo = {
1848
  { (JSJitGetterOp)get_finalURI },
1849
  { prototypes::id::ChannelWrapper },
1850
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1851
  JSJitInfo::Getter,
1852
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1853
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1854
  false,  /* isInfallible. False in setters. */
1855
  true,  /* isMovable.  Not relevant for setters. */
1856
  true, /* isEliminatable.  Not relevant for setters. */
1857
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1858
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
1859
  false,  /* isTypedMethod.  Only relevant for methods. */
1860
  (DOM_INSTANCE_RESERVED_SLOTS + 3)   /* Reserved slot index, if we're stored in a slot, else 0. */
1861
};
1862
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 3) <= JSJitInfo::maxSlotIndex, "We won't fit");
1863
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 3) < 20, "There is no slot for us");
1864
1865
MOZ_CAN_RUN_SCRIPT static bool
1866
get_finalURL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
1867
0
{
1868
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.finalURL", DOM, cx);
1869
0
1870
0
  // Have to either root across the getter call or reget after.
1871
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
1872
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
1873
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 4);
1874
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1875
0
  {
1876
0
    // Scope for cachedVal
1877
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1878
0
    if (!cachedVal.isUndefined()) {
1879
0
      args.rval().set(cachedVal);
1880
0
      // The cached value is in the compartment of slotStorage,
1881
0
      // so wrap into the caller compartment as needed.
1882
0
      if (MaybeWrapValue(cx, args.rval())) {
1883
0
        return true;
1884
0
      }
1885
0
      return false;
1886
0
    }
1887
0
  }
1888
0
1889
0
  DOMString result;
1890
0
  self->GetFinalURL(result);
1891
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1892
0
  {
1893
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
1894
0
    JSAutoRealm ar(cx, conversionScope);
1895
0
    do { // block we break out of when done wrapping
1896
0
      if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1897
0
        return false;
1898
0
      }
1899
0
      break;
1900
0
    } while (false);
1901
0
  }
1902
0
  { // And now store things in the realm of our slotStorage.
1903
0
    JSAutoRealm ar(cx, slotStorage);
1904
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1905
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1906
0
    if (!MaybeWrapValue(cx, &storedVal)) {
1907
0
      return false;
1908
0
    }
1909
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1910
0
    PreserveWrapper(self);
1911
0
  }
1912
0
  // And now make sure args.rval() is in the caller realm.
1913
0
  if (MaybeWrapValue(cx, args.rval())) {
1914
0
    return true;
1915
0
  }
1916
0
  return false;
1917
0
}
1918
1919
static const JSJitInfo finalURL_getterinfo = {
1920
  { (JSJitGetterOp)get_finalURL },
1921
  { prototypes::id::ChannelWrapper },
1922
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1923
  JSJitInfo::Getter,
1924
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1925
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1926
  false,  /* isInfallible. False in setters. */
1927
  true,  /* isMovable.  Not relevant for setters. */
1928
  true, /* isEliminatable.  Not relevant for setters. */
1929
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1930
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
1931
  false,  /* isTypedMethod.  Only relevant for methods. */
1932
  (DOM_INSTANCE_RESERVED_SLOTS + 4)   /* Reserved slot index, if we're stored in a slot, else 0. */
1933
};
1934
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 4) <= JSJitInfo::maxSlotIndex, "We won't fit");
1935
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 4) < 20, "There is no slot for us");
1936
1937
MOZ_CAN_RUN_SCRIPT static bool
1938
matches(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
1939
0
{
1940
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.matches", DOM, cx);
1941
0
1942
0
  binding_detail::FastMozRequestFilter arg0;
1943
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of ChannelWrapper.matches", false)) {
1944
0
    return false;
1945
0
  }
1946
0
  mozilla::extensions::WebExtensionPolicy* arg1;
1947
0
  if (args.hasDefined(1)) {
1948
0
    if (args[1].isObject()) {
1949
0
      {
1950
0
        nsresult rv = UnwrapObject<prototypes::id::WebExtensionPolicy, mozilla::extensions::WebExtensionPolicy>(args[1], arg1);
1951
0
        if (NS_FAILED(rv)) {
1952
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of ChannelWrapper.matches", "WebExtensionPolicy");
1953
0
          return false;
1954
0
        }
1955
0
      }
1956
0
    } else if (args[1].isNullOrUndefined()) {
1957
0
      arg1 = nullptr;
1958
0
    } else {
1959
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of ChannelWrapper.matches");
1960
0
      return false;
1961
0
    }
1962
0
  } else {
1963
0
    arg1 = nullptr;
1964
0
  }
1965
0
  binding_detail::FastMozRequestMatchOptions arg2;
1966
0
  if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of ChannelWrapper.matches", false)) {
1967
0
    return false;
1968
0
  }
1969
0
  bool result(self->Matches(Constify(arg0), MOZ_KnownLive(Constify(arg1)), Constify(arg2)));
1970
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1971
0
  args.rval().setBoolean(result);
1972
0
  return true;
1973
0
}
1974
1975
static const JSJitInfo matches_methodinfo = {
1976
  { (JSJitGetterOp)matches },
1977
  { prototypes::id::ChannelWrapper },
1978
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
1979
  JSJitInfo::Method,
1980
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1981
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1982
  false,  /* isInfallible. False in setters. */
1983
  false,  /* isMovable.  Not relevant for setters. */
1984
  false, /* isEliminatable.  Not relevant for setters. */
1985
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1986
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1987
  false,  /* isTypedMethod.  Only relevant for methods. */
1988
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1989
};
1990
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1991
static_assert(0 < 20, "There is no slot for us");
1992
1993
MOZ_CAN_RUN_SCRIPT static bool
1994
registerTraceableChannel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
1995
0
{
1996
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.registerTraceableChannel", DOM, cx);
1997
0
1998
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
1999
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelWrapper.registerTraceableChannel");
2000
0
  }
2001
0
  NonNull<mozilla::extensions::WebExtensionPolicy> arg0;
2002
0
  if (args[0].isObject()) {
2003
0
    {
2004
0
      nsresult rv = UnwrapObject<prototypes::id::WebExtensionPolicy, mozilla::extensions::WebExtensionPolicy>(args[0], arg0);
2005
0
      if (NS_FAILED(rv)) {
2006
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ChannelWrapper.registerTraceableChannel", "WebExtensionPolicy");
2007
0
        return false;
2008
0
      }
2009
0
    }
2010
0
  } else {
2011
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ChannelWrapper.registerTraceableChannel");
2012
0
    return false;
2013
0
  }
2014
0
  nsITabParent* arg1;
2015
0
  RefPtr<nsITabParent> arg1_holder;
2016
0
  if (args[1].isObject()) {
2017
0
    JS::Rooted<JSObject*> source(cx, &args[1].toObject());
2018
0
    if (NS_FAILED(UnwrapArg<nsITabParent>(cx, source, getter_AddRefs(arg1_holder)))) {
2019
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of ChannelWrapper.registerTraceableChannel", "TabParent");
2020
0
      return false;
2021
0
    }
2022
0
    MOZ_ASSERT(arg1_holder);
2023
0
    arg1 = arg1_holder;
2024
0
  } else if (args[1].isNullOrUndefined()) {
2025
0
    arg1 = nullptr;
2026
0
  } else {
2027
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of ChannelWrapper.registerTraceableChannel");
2028
0
    return false;
2029
0
  }
2030
0
  self->RegisterTraceableChannel(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(Constify(arg1)));
2031
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2032
0
  args.rval().setUndefined();
2033
0
  return true;
2034
0
}
2035
2036
static const JSJitInfo registerTraceableChannel_methodinfo = {
2037
  { (JSJitGetterOp)registerTraceableChannel },
2038
  { prototypes::id::ChannelWrapper },
2039
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2040
  JSJitInfo::Method,
2041
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2042
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2043
  false,  /* isInfallible. False in setters. */
2044
  false,  /* isMovable.  Not relevant for setters. */
2045
  false, /* isEliminatable.  Not relevant for setters. */
2046
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2047
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2048
  false,  /* isTypedMethod.  Only relevant for methods. */
2049
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2050
};
2051
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2052
static_assert(0 < 20, "There is no slot for us");
2053
2054
MOZ_CAN_RUN_SCRIPT static bool
2055
get_statusCode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2056
0
{
2057
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.statusCode", DOM, cx);
2058
0
2059
0
  // Have to either root across the getter call or reget after.
2060
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2061
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2062
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 5);
2063
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2064
0
  {
2065
0
    // Scope for cachedVal
2066
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2067
0
    if (!cachedVal.isUndefined()) {
2068
0
      args.rval().set(cachedVal);
2069
0
      // The cached value is in the compartment of slotStorage,
2070
0
      // so wrap into the caller compartment as needed.
2071
0
      if (MaybeWrapValue(cx, args.rval())) {
2072
0
        return true;
2073
0
      }
2074
0
      return false;
2075
0
    }
2076
0
  }
2077
0
2078
0
  uint32_t result(self->StatusCode());
2079
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2080
0
  {
2081
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2082
0
    JSAutoRealm ar(cx, conversionScope);
2083
0
    do { // block we break out of when done wrapping
2084
0
      args.rval().setNumber(result);
2085
0
      break;
2086
0
    } while (false);
2087
0
  }
2088
0
  { // And now store things in the realm of our slotStorage.
2089
0
    JSAutoRealm ar(cx, slotStorage);
2090
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2091
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2092
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2093
0
      return false;
2094
0
    }
2095
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2096
0
    PreserveWrapper(self);
2097
0
  }
2098
0
  // And now make sure args.rval() is in the caller realm.
2099
0
  if (MaybeWrapValue(cx, args.rval())) {
2100
0
    return true;
2101
0
  }
2102
0
  return false;
2103
0
}
2104
2105
static const JSJitInfo statusCode_getterinfo = {
2106
  { (JSJitGetterOp)get_statusCode },
2107
  { prototypes::id::ChannelWrapper },
2108
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2109
  JSJitInfo::Getter,
2110
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2111
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2112
  true,  /* isInfallible. False in setters. */
2113
  true,  /* isMovable.  Not relevant for setters. */
2114
  true, /* isEliminatable.  Not relevant for setters. */
2115
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2116
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2117
  false,  /* isTypedMethod.  Only relevant for methods. */
2118
  (DOM_INSTANCE_RESERVED_SLOTS + 5)   /* Reserved slot index, if we're stored in a slot, else 0. */
2119
};
2120
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 5) <= JSJitInfo::maxSlotIndex, "We won't fit");
2121
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 5) < 20, "There is no slot for us");
2122
2123
MOZ_CAN_RUN_SCRIPT static bool
2124
get_statusLine(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2125
0
{
2126
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.statusLine", DOM, cx);
2127
0
2128
0
  // Have to either root across the getter call or reget after.
2129
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2130
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2131
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 6);
2132
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2133
0
  {
2134
0
    // Scope for cachedVal
2135
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2136
0
    if (!cachedVal.isUndefined()) {
2137
0
      args.rval().set(cachedVal);
2138
0
      // The cached value is in the compartment of slotStorage,
2139
0
      // so wrap into the caller compartment as needed.
2140
0
      if (MaybeWrapValue(cx, args.rval())) {
2141
0
        return true;
2142
0
      }
2143
0
      return false;
2144
0
    }
2145
0
  }
2146
0
2147
0
  nsCString result;
2148
0
  self->GetStatusLine(result);
2149
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2150
0
  {
2151
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2152
0
    JSAutoRealm ar(cx, conversionScope);
2153
0
    do { // block we break out of when done wrapping
2154
0
      if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
2155
0
        return false;
2156
0
      }
2157
0
      break;
2158
0
    } while (false);
2159
0
  }
2160
0
  { // And now store things in the realm of our slotStorage.
2161
0
    JSAutoRealm ar(cx, slotStorage);
2162
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2163
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2164
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2165
0
      return false;
2166
0
    }
2167
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2168
0
    PreserveWrapper(self);
2169
0
  }
2170
0
  // And now make sure args.rval() is in the caller realm.
2171
0
  if (MaybeWrapValue(cx, args.rval())) {
2172
0
    return true;
2173
0
  }
2174
0
  return false;
2175
0
}
2176
2177
static const JSJitInfo statusLine_getterinfo = {
2178
  { (JSJitGetterOp)get_statusLine },
2179
  { prototypes::id::ChannelWrapper },
2180
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2181
  JSJitInfo::Getter,
2182
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2183
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2184
  false,  /* isInfallible. False in setters. */
2185
  true,  /* isMovable.  Not relevant for setters. */
2186
  true, /* isEliminatable.  Not relevant for setters. */
2187
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2188
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2189
  false,  /* isTypedMethod.  Only relevant for methods. */
2190
  (DOM_INSTANCE_RESERVED_SLOTS + 6)   /* Reserved slot index, if we're stored in a slot, else 0. */
2191
};
2192
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 6) <= JSJitInfo::maxSlotIndex, "We won't fit");
2193
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 6) < 20, "There is no slot for us");
2194
2195
MOZ_CAN_RUN_SCRIPT static bool
2196
get_errorString(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2197
0
{
2198
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.errorString", DOM, cx);
2199
0
2200
0
  // Have to either root across the getter call or reget after.
2201
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2202
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2203
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 7);
2204
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2205
0
  {
2206
0
    // Scope for cachedVal
2207
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2208
0
    if (!cachedVal.isUndefined()) {
2209
0
      args.rval().set(cachedVal);
2210
0
      // The cached value is in the compartment of slotStorage,
2211
0
      // so wrap into the caller compartment as needed.
2212
0
      if (MaybeWrapValue(cx, args.rval())) {
2213
0
        return true;
2214
0
      }
2215
0
      return false;
2216
0
    }
2217
0
  }
2218
0
2219
0
  DOMString result;
2220
0
  self->GetErrorString(result);
2221
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2222
0
  {
2223
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2224
0
    JSAutoRealm ar(cx, conversionScope);
2225
0
    do { // block we break out of when done wrapping
2226
0
      if (!xpc::StringToJsval(cx, result, args.rval())) {
2227
0
        return false;
2228
0
      }
2229
0
      break;
2230
0
    } while (false);
2231
0
  }
2232
0
  { // And now store things in the realm of our slotStorage.
2233
0
    JSAutoRealm ar(cx, slotStorage);
2234
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2235
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2236
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2237
0
      return false;
2238
0
    }
2239
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2240
0
    PreserveWrapper(self);
2241
0
  }
2242
0
  // And now make sure args.rval() is in the caller realm.
2243
0
  if (MaybeWrapValue(cx, args.rval())) {
2244
0
    return true;
2245
0
  }
2246
0
  return false;
2247
0
}
2248
2249
static const JSJitInfo errorString_getterinfo = {
2250
  { (JSJitGetterOp)get_errorString },
2251
  { prototypes::id::ChannelWrapper },
2252
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2253
  JSJitInfo::Getter,
2254
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2255
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2256
  false,  /* isInfallible. False in setters. */
2257
  true,  /* isMovable.  Not relevant for setters. */
2258
  true, /* isEliminatable.  Not relevant for setters. */
2259
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2260
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2261
  false,  /* isTypedMethod.  Only relevant for methods. */
2262
  (DOM_INSTANCE_RESERVED_SLOTS + 7)   /* Reserved slot index, if we're stored in a slot, else 0. */
2263
};
2264
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 7) <= JSJitInfo::maxSlotIndex, "We won't fit");
2265
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 7) < 20, "There is no slot for us");
2266
2267
MOZ_CAN_RUN_SCRIPT static bool
2268
get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2269
0
{
2270
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.onerror", DOM, cx);
2271
0
2272
0
  RefPtr<EventHandlerNonNull> result(self->GetOnerror());
2273
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2274
0
  if (result) {
2275
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
2276
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
2277
0
      return false;
2278
0
    }
2279
0
    return true;
2280
0
  } else {
2281
0
    args.rval().setNull();
2282
0
    return true;
2283
0
  }
2284
0
}
2285
2286
MOZ_CAN_RUN_SCRIPT static bool
2287
set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitSetterCallArgs args)
2288
0
{
2289
0
  AUTO_PROFILER_LABEL_FAST("set ChannelWrapper.onerror", DOM, cx);
2290
0
2291
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
2292
0
  if (args[0].isObject()) {
2293
0
    { // scope for tempRoot and tempGlobalRoot if needed
2294
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
2295
0
    }
2296
0
  } else {
2297
0
    arg0 = nullptr;
2298
0
  }
2299
0
  self->SetOnerror(Constify(arg0));
2300
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2301
0
2302
0
  return true;
2303
0
}
2304
2305
static const JSJitInfo onerror_getterinfo = {
2306
  { (JSJitGetterOp)get_onerror },
2307
  { prototypes::id::ChannelWrapper },
2308
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2309
  JSJitInfo::Getter,
2310
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2311
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2312
  false,  /* isInfallible. False in setters. */
2313
  false,  /* isMovable.  Not relevant for setters. */
2314
  false, /* isEliminatable.  Not relevant for setters. */
2315
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2316
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2317
  false,  /* isTypedMethod.  Only relevant for methods. */
2318
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2319
};
2320
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2321
static_assert(0 < 20, "There is no slot for us");
2322
static const JSJitInfo onerror_setterinfo = {
2323
  { (JSJitGetterOp)set_onerror },
2324
  { prototypes::id::ChannelWrapper },
2325
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2326
  JSJitInfo::Setter,
2327
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2328
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2329
  false,  /* isInfallible. False in setters. */
2330
  false,  /* isMovable.  Not relevant for setters. */
2331
  false, /* isEliminatable.  Not relevant for setters. */
2332
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2333
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2334
  false,  /* isTypedMethod.  Only relevant for methods. */
2335
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2336
};
2337
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2338
static_assert(0 < 20, "There is no slot for us");
2339
2340
MOZ_CAN_RUN_SCRIPT static bool
2341
errorCheck(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
2342
0
{
2343
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.errorCheck", DOM, cx);
2344
0
2345
0
  self->ErrorCheck();
2346
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2347
0
  args.rval().setUndefined();
2348
0
  return true;
2349
0
}
2350
2351
static const JSJitInfo errorCheck_methodinfo = {
2352
  { (JSJitGetterOp)errorCheck },
2353
  { prototypes::id::ChannelWrapper },
2354
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2355
  JSJitInfo::Method,
2356
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2357
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2358
  true,  /* isInfallible. False in setters. */
2359
  false,  /* isMovable.  Not relevant for setters. */
2360
  false, /* isEliminatable.  Not relevant for setters. */
2361
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2362
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2363
  false,  /* isTypedMethod.  Only relevant for methods. */
2364
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2365
};
2366
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2367
static_assert(0 < 20, "There is no slot for us");
2368
2369
MOZ_CAN_RUN_SCRIPT static bool
2370
get_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2371
0
{
2372
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.onstart", DOM, cx);
2373
0
2374
0
  RefPtr<EventHandlerNonNull> result(self->GetOnstart());
2375
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2376
0
  if (result) {
2377
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
2378
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
2379
0
      return false;
2380
0
    }
2381
0
    return true;
2382
0
  } else {
2383
0
    args.rval().setNull();
2384
0
    return true;
2385
0
  }
2386
0
}
2387
2388
MOZ_CAN_RUN_SCRIPT static bool
2389
set_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitSetterCallArgs args)
2390
0
{
2391
0
  AUTO_PROFILER_LABEL_FAST("set ChannelWrapper.onstart", DOM, cx);
2392
0
2393
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
2394
0
  if (args[0].isObject()) {
2395
0
    { // scope for tempRoot and tempGlobalRoot if needed
2396
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
2397
0
    }
2398
0
  } else {
2399
0
    arg0 = nullptr;
2400
0
  }
2401
0
  self->SetOnstart(Constify(arg0));
2402
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2403
0
2404
0
  return true;
2405
0
}
2406
2407
static const JSJitInfo onstart_getterinfo = {
2408
  { (JSJitGetterOp)get_onstart },
2409
  { prototypes::id::ChannelWrapper },
2410
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2411
  JSJitInfo::Getter,
2412
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2413
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2414
  false,  /* isInfallible. False in setters. */
2415
  false,  /* isMovable.  Not relevant for setters. */
2416
  false, /* isEliminatable.  Not relevant for setters. */
2417
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2418
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2419
  false,  /* isTypedMethod.  Only relevant for methods. */
2420
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2421
};
2422
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2423
static_assert(0 < 20, "There is no slot for us");
2424
static const JSJitInfo onstart_setterinfo = {
2425
  { (JSJitGetterOp)set_onstart },
2426
  { prototypes::id::ChannelWrapper },
2427
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2428
  JSJitInfo::Setter,
2429
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2430
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2431
  false,  /* isInfallible. False in setters. */
2432
  false,  /* isMovable.  Not relevant for setters. */
2433
  false, /* isEliminatable.  Not relevant for setters. */
2434
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2435
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2436
  false,  /* isTypedMethod.  Only relevant for methods. */
2437
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2438
};
2439
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2440
static_assert(0 < 20, "There is no slot for us");
2441
2442
MOZ_CAN_RUN_SCRIPT static bool
2443
get_onstop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2444
0
{
2445
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.onstop", DOM, cx);
2446
0
2447
0
  RefPtr<EventHandlerNonNull> result(self->GetOnstop());
2448
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2449
0
  if (result) {
2450
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
2451
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
2452
0
      return false;
2453
0
    }
2454
0
    return true;
2455
0
  } else {
2456
0
    args.rval().setNull();
2457
0
    return true;
2458
0
  }
2459
0
}
2460
2461
MOZ_CAN_RUN_SCRIPT static bool
2462
set_onstop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitSetterCallArgs args)
2463
0
{
2464
0
  AUTO_PROFILER_LABEL_FAST("set ChannelWrapper.onstop", DOM, cx);
2465
0
2466
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
2467
0
  if (args[0].isObject()) {
2468
0
    { // scope for tempRoot and tempGlobalRoot if needed
2469
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
2470
0
    }
2471
0
  } else {
2472
0
    arg0 = nullptr;
2473
0
  }
2474
0
  self->SetOnstop(Constify(arg0));
2475
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2476
0
2477
0
  return true;
2478
0
}
2479
2480
static const JSJitInfo onstop_getterinfo = {
2481
  { (JSJitGetterOp)get_onstop },
2482
  { prototypes::id::ChannelWrapper },
2483
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2484
  JSJitInfo::Getter,
2485
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2486
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2487
  false,  /* isInfallible. False in setters. */
2488
  false,  /* isMovable.  Not relevant for setters. */
2489
  false, /* isEliminatable.  Not relevant for setters. */
2490
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2491
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2492
  false,  /* isTypedMethod.  Only relevant for methods. */
2493
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2494
};
2495
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2496
static_assert(0 < 20, "There is no slot for us");
2497
static const JSJitInfo onstop_setterinfo = {
2498
  { (JSJitGetterOp)set_onstop },
2499
  { prototypes::id::ChannelWrapper },
2500
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2501
  JSJitInfo::Setter,
2502
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2503
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2504
  false,  /* isInfallible. False in setters. */
2505
  false,  /* isMovable.  Not relevant for setters. */
2506
  false, /* isEliminatable.  Not relevant for setters. */
2507
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2508
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2509
  false,  /* isTypedMethod.  Only relevant for methods. */
2510
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2511
};
2512
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2513
static_assert(0 < 20, "There is no slot for us");
2514
2515
MOZ_CAN_RUN_SCRIPT static bool
2516
get_proxyInfo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2517
0
{
2518
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.proxyInfo", DOM, cx);
2519
0
2520
0
  // Have to either root across the getter call or reget after.
2521
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2522
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2523
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 8);
2524
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2525
0
  {
2526
0
    // Scope for cachedVal
2527
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2528
0
    if (!cachedVal.isUndefined()) {
2529
0
      args.rval().set(cachedVal);
2530
0
      // The cached value is in the compartment of slotStorage,
2531
0
      // so wrap into the caller compartment as needed.
2532
0
      if (MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
2533
0
        return true;
2534
0
      }
2535
0
      return false;
2536
0
    }
2537
0
  }
2538
0
2539
0
  FastErrorResult rv;
2540
0
  Nullable<MozProxyInfo> result;
2541
0
  self->GetProxyInfo(result, rv);
2542
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2543
0
    return false;
2544
0
  }
2545
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2546
0
  {
2547
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2548
0
    JSAutoRealm ar(cx, conversionScope);
2549
0
    do { // block we break out of when done wrapping
2550
0
      if (result.IsNull()) {
2551
0
        args.rval().setNull();
2552
0
        break;
2553
0
      }
2554
0
      if (!result.Value().ToObjectInternal(cx, args.rval())) {
2555
0
        return false;
2556
0
      }
2557
0
      break;
2558
0
    } while (false);
2559
0
    if (args.rval().isObject()) {
2560
0
      JS::Rooted<JSObject*> rvalObj(cx, &args.rval().toObject());
2561
0
      if (!JS_FreezeObject(cx, rvalObj)) {
2562
0
        return false;
2563
0
      }
2564
0
    }
2565
0
  }
2566
0
  { // And now store things in the realm of our slotStorage.
2567
0
    JSAutoRealm ar(cx, slotStorage);
2568
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2569
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2570
0
    if (!MaybeWrapNonDOMObjectOrNullValue(cx, &storedVal)) {
2571
0
      return false;
2572
0
    }
2573
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2574
0
    PreserveWrapper(self);
2575
0
  }
2576
0
  // And now make sure args.rval() is in the caller realm.
2577
0
  if (MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
2578
0
    return true;
2579
0
  }
2580
0
  return false;
2581
0
}
2582
2583
static const JSJitInfo proxyInfo_getterinfo = {
2584
  { (JSJitGetterOp)get_proxyInfo },
2585
  { prototypes::id::ChannelWrapper },
2586
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2587
  JSJitInfo::Getter,
2588
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2589
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2590
  false,  /* isInfallible. False in setters. */
2591
  false,  /* isMovable.  Not relevant for setters. */
2592
  false, /* isEliminatable.  Not relevant for setters. */
2593
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2594
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2595
  false,  /* isTypedMethod.  Only relevant for methods. */
2596
  (DOM_INSTANCE_RESERVED_SLOTS + 8)   /* Reserved slot index, if we're stored in a slot, else 0. */
2597
};
2598
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 8) <= JSJitInfo::maxSlotIndex, "We won't fit");
2599
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 8) < 20, "There is no slot for us");
2600
2601
MOZ_CAN_RUN_SCRIPT static bool
2602
get_remoteAddress(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2603
0
{
2604
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.remoteAddress", DOM, cx);
2605
0
2606
0
  // Have to either root across the getter call or reget after.
2607
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2608
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2609
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 9);
2610
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2611
0
  {
2612
0
    // Scope for cachedVal
2613
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2614
0
    if (!cachedVal.isUndefined()) {
2615
0
      args.rval().set(cachedVal);
2616
0
      // The cached value is in the compartment of slotStorage,
2617
0
      // so wrap into the caller compartment as needed.
2618
0
      if (MaybeWrapValue(cx, args.rval())) {
2619
0
        return true;
2620
0
      }
2621
0
      return false;
2622
0
    }
2623
0
  }
2624
0
2625
0
  nsCString result;
2626
0
  self->GetRemoteAddress(result);
2627
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2628
0
  {
2629
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2630
0
    JSAutoRealm ar(cx, conversionScope);
2631
0
    do { // block we break out of when done wrapping
2632
0
      if (!ByteStringToJsval(cx, result, args.rval())) {
2633
0
        return false;
2634
0
      }
2635
0
      break;
2636
0
    } while (false);
2637
0
  }
2638
0
  { // And now store things in the realm of our slotStorage.
2639
0
    JSAutoRealm ar(cx, slotStorage);
2640
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2641
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2642
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2643
0
      return false;
2644
0
    }
2645
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2646
0
    PreserveWrapper(self);
2647
0
  }
2648
0
  // And now make sure args.rval() is in the caller realm.
2649
0
  if (MaybeWrapValue(cx, args.rval())) {
2650
0
    return true;
2651
0
  }
2652
0
  return false;
2653
0
}
2654
2655
static const JSJitInfo remoteAddress_getterinfo = {
2656
  { (JSJitGetterOp)get_remoteAddress },
2657
  { prototypes::id::ChannelWrapper },
2658
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2659
  JSJitInfo::Getter,
2660
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2661
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2662
  false,  /* isInfallible. False in setters. */
2663
  true,  /* isMovable.  Not relevant for setters. */
2664
  true, /* isEliminatable.  Not relevant for setters. */
2665
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2666
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2667
  false,  /* isTypedMethod.  Only relevant for methods. */
2668
  (DOM_INSTANCE_RESERVED_SLOTS + 9)   /* Reserved slot index, if we're stored in a slot, else 0. */
2669
};
2670
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 9) <= JSJitInfo::maxSlotIndex, "We won't fit");
2671
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 9) < 20, "There is no slot for us");
2672
2673
MOZ_CAN_RUN_SCRIPT static bool
2674
get_loadInfo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2675
0
{
2676
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.loadInfo", DOM, cx);
2677
0
2678
0
  // Have to either root across the getter call or reget after.
2679
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2680
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2681
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 10);
2682
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2683
0
  {
2684
0
    // Scope for cachedVal
2685
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2686
0
    if (!cachedVal.isUndefined()) {
2687
0
      args.rval().set(cachedVal);
2688
0
      // The cached value is in the compartment of slotStorage,
2689
0
      // so wrap into the caller compartment as needed.
2690
0
      if (MaybeWrapValue(cx, args.rval())) {
2691
0
        return true;
2692
0
      }
2693
0
      return false;
2694
0
    }
2695
0
  }
2696
0
2697
0
  auto result(StrongOrRawPtr<nsILoadInfo>(self->GetLoadInfo()));
2698
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2699
0
  {
2700
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2701
0
    JSAutoRealm ar(cx, conversionScope);
2702
0
    do { // block we break out of when done wrapping
2703
0
      if (!result) {
2704
0
        args.rval().setNull();
2705
0
        break;
2706
0
      }
2707
0
      if (!WrapObject(cx, result, &NS_GET_IID(nsILoadInfo), args.rval())) {
2708
0
        return false;
2709
0
      }
2710
0
      break;
2711
0
    } while (false);
2712
0
  }
2713
0
  { // And now store things in the realm of our slotStorage.
2714
0
    JSAutoRealm ar(cx, slotStorage);
2715
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2716
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2717
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2718
0
      return false;
2719
0
    }
2720
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2721
0
    PreserveWrapper(self);
2722
0
  }
2723
0
  // And now make sure args.rval() is in the caller realm.
2724
0
  if (MaybeWrapValue(cx, args.rval())) {
2725
0
    return true;
2726
0
  }
2727
0
  return false;
2728
0
}
2729
2730
static const JSJitInfo loadInfo_getterinfo = {
2731
  { (JSJitGetterOp)get_loadInfo },
2732
  { prototypes::id::ChannelWrapper },
2733
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2734
  JSJitInfo::Getter,
2735
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2736
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2737
  false,  /* isInfallible. False in setters. */
2738
  true,  /* isMovable.  Not relevant for setters. */
2739
  true, /* isEliminatable.  Not relevant for setters. */
2740
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2741
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2742
  false,  /* isTypedMethod.  Only relevant for methods. */
2743
  (DOM_INSTANCE_RESERVED_SLOTS + 10)   /* Reserved slot index, if we're stored in a slot, else 0. */
2744
};
2745
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 10) <= JSJitInfo::maxSlotIndex, "We won't fit");
2746
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 10) < 20, "There is no slot for us");
2747
2748
MOZ_CAN_RUN_SCRIPT static bool
2749
get_isSystemLoad(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2750
0
{
2751
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.isSystemLoad", DOM, cx);
2752
0
2753
0
  // Have to either root across the getter call or reget after.
2754
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2755
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2756
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 11);
2757
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2758
0
  {
2759
0
    // Scope for cachedVal
2760
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2761
0
    if (!cachedVal.isUndefined()) {
2762
0
      args.rval().set(cachedVal);
2763
0
      // The cached value is in the compartment of slotStorage,
2764
0
      // so wrap into the caller compartment as needed.
2765
0
      if (MaybeWrapValue(cx, args.rval())) {
2766
0
        return true;
2767
0
      }
2768
0
      return false;
2769
0
    }
2770
0
  }
2771
0
2772
0
  bool result(self->IsSystemLoad());
2773
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2774
0
  {
2775
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2776
0
    JSAutoRealm ar(cx, conversionScope);
2777
0
    do { // block we break out of when done wrapping
2778
0
      args.rval().setBoolean(result);
2779
0
      break;
2780
0
    } while (false);
2781
0
  }
2782
0
  { // And now store things in the realm of our slotStorage.
2783
0
    JSAutoRealm ar(cx, slotStorage);
2784
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2785
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2786
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2787
0
      return false;
2788
0
    }
2789
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2790
0
    PreserveWrapper(self);
2791
0
  }
2792
0
  // And now make sure args.rval() is in the caller realm.
2793
0
  if (MaybeWrapValue(cx, args.rval())) {
2794
0
    return true;
2795
0
  }
2796
0
  return false;
2797
0
}
2798
2799
static const JSJitInfo isSystemLoad_getterinfo = {
2800
  { (JSJitGetterOp)get_isSystemLoad },
2801
  { prototypes::id::ChannelWrapper },
2802
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2803
  JSJitInfo::Getter,
2804
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2805
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
2806
  true,  /* isInfallible. False in setters. */
2807
  true,  /* isMovable.  Not relevant for setters. */
2808
  true, /* isEliminatable.  Not relevant for setters. */
2809
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2810
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2811
  false,  /* isTypedMethod.  Only relevant for methods. */
2812
  (DOM_INSTANCE_RESERVED_SLOTS + 11)   /* Reserved slot index, if we're stored in a slot, else 0. */
2813
};
2814
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 11) <= JSJitInfo::maxSlotIndex, "We won't fit");
2815
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 11) < 20, "There is no slot for us");
2816
2817
MOZ_CAN_RUN_SCRIPT static bool
2818
get_originURL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2819
0
{
2820
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.originURL", DOM, cx);
2821
0
2822
0
  // Have to either root across the getter call or reget after.
2823
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2824
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2825
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 12);
2826
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2827
0
  {
2828
0
    // Scope for cachedVal
2829
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2830
0
    if (!cachedVal.isUndefined()) {
2831
0
      args.rval().set(cachedVal);
2832
0
      // The cached value is in the compartment of slotStorage,
2833
0
      // so wrap into the caller compartment as needed.
2834
0
      if (MaybeWrapValue(cx, args.rval())) {
2835
0
        return true;
2836
0
      }
2837
0
      return false;
2838
0
    }
2839
0
  }
2840
0
2841
0
  nsCString result;
2842
0
  self->GetOriginURL(result);
2843
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2844
0
  {
2845
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2846
0
    JSAutoRealm ar(cx, conversionScope);
2847
0
    do { // block we break out of when done wrapping
2848
0
      if (!ByteStringToJsval(cx, result, args.rval())) {
2849
0
        return false;
2850
0
      }
2851
0
      break;
2852
0
    } while (false);
2853
0
  }
2854
0
  { // And now store things in the realm of our slotStorage.
2855
0
    JSAutoRealm ar(cx, slotStorage);
2856
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2857
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2858
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2859
0
      return false;
2860
0
    }
2861
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2862
0
    PreserveWrapper(self);
2863
0
  }
2864
0
  // And now make sure args.rval() is in the caller realm.
2865
0
  if (MaybeWrapValue(cx, args.rval())) {
2866
0
    return true;
2867
0
  }
2868
0
  return false;
2869
0
}
2870
2871
static const JSJitInfo originURL_getterinfo = {
2872
  { (JSJitGetterOp)get_originURL },
2873
  { prototypes::id::ChannelWrapper },
2874
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2875
  JSJitInfo::Getter,
2876
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2877
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2878
  false,  /* isInfallible. False in setters. */
2879
  true,  /* isMovable.  Not relevant for setters. */
2880
  true, /* isEliminatable.  Not relevant for setters. */
2881
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2882
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2883
  false,  /* isTypedMethod.  Only relevant for methods. */
2884
  (DOM_INSTANCE_RESERVED_SLOTS + 12)   /* Reserved slot index, if we're stored in a slot, else 0. */
2885
};
2886
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 12) <= JSJitInfo::maxSlotIndex, "We won't fit");
2887
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 12) < 20, "There is no slot for us");
2888
2889
MOZ_CAN_RUN_SCRIPT static bool
2890
get_documentURL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2891
0
{
2892
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.documentURL", DOM, cx);
2893
0
2894
0
  // Have to either root across the getter call or reget after.
2895
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
2896
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
2897
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 13);
2898
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
2899
0
  {
2900
0
    // Scope for cachedVal
2901
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
2902
0
    if (!cachedVal.isUndefined()) {
2903
0
      args.rval().set(cachedVal);
2904
0
      // The cached value is in the compartment of slotStorage,
2905
0
      // so wrap into the caller compartment as needed.
2906
0
      if (MaybeWrapValue(cx, args.rval())) {
2907
0
        return true;
2908
0
      }
2909
0
      return false;
2910
0
    }
2911
0
  }
2912
0
2913
0
  nsCString result;
2914
0
  self->GetDocumentURL(result);
2915
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2916
0
  {
2917
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
2918
0
    JSAutoRealm ar(cx, conversionScope);
2919
0
    do { // block we break out of when done wrapping
2920
0
      if (!ByteStringToJsval(cx, result, args.rval())) {
2921
0
        return false;
2922
0
      }
2923
0
      break;
2924
0
    } while (false);
2925
0
  }
2926
0
  { // And now store things in the realm of our slotStorage.
2927
0
    JSAutoRealm ar(cx, slotStorage);
2928
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2929
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2930
0
    if (!MaybeWrapValue(cx, &storedVal)) {
2931
0
      return false;
2932
0
    }
2933
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2934
0
    PreserveWrapper(self);
2935
0
  }
2936
0
  // And now make sure args.rval() is in the caller realm.
2937
0
  if (MaybeWrapValue(cx, args.rval())) {
2938
0
    return true;
2939
0
  }
2940
0
  return false;
2941
0
}
2942
2943
static const JSJitInfo documentURL_getterinfo = {
2944
  { (JSJitGetterOp)get_documentURL },
2945
  { prototypes::id::ChannelWrapper },
2946
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2947
  JSJitInfo::Getter,
2948
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2949
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2950
  false,  /* isInfallible. False in setters. */
2951
  true,  /* isMovable.  Not relevant for setters. */
2952
  true, /* isEliminatable.  Not relevant for setters. */
2953
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2954
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2955
  false,  /* isTypedMethod.  Only relevant for methods. */
2956
  (DOM_INSTANCE_RESERVED_SLOTS + 13)   /* Reserved slot index, if we're stored in a slot, else 0. */
2957
};
2958
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 13) <= JSJitInfo::maxSlotIndex, "We won't fit");
2959
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 13) < 20, "There is no slot for us");
2960
2961
MOZ_CAN_RUN_SCRIPT static bool
2962
get_originURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2963
0
{
2964
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.originURI", DOM, cx);
2965
0
2966
0
  auto result(StrongOrRawPtr<nsIURI>(self->GetOriginURI()));
2967
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2968
0
  if (!result) {
2969
0
    args.rval().setNull();
2970
0
    return true;
2971
0
  }
2972
0
  if (!WrapObject(cx, result, &NS_GET_IID(nsIURI), args.rval())) {
2973
0
    return false;
2974
0
  }
2975
0
  return true;
2976
0
}
2977
2978
static const JSJitInfo originURI_getterinfo = {
2979
  { (JSJitGetterOp)get_originURI },
2980
  { prototypes::id::ChannelWrapper },
2981
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
2982
  JSJitInfo::Getter,
2983
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
2984
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2985
  false,  /* isInfallible. False in setters. */
2986
  true,  /* isMovable.  Not relevant for setters. */
2987
  true, /* isEliminatable.  Not relevant for setters. */
2988
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2989
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2990
  false,  /* isTypedMethod.  Only relevant for methods. */
2991
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2992
};
2993
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2994
static_assert(0 < 20, "There is no slot for us");
2995
2996
MOZ_CAN_RUN_SCRIPT static bool
2997
get_documentURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
2998
0
{
2999
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.documentURI", DOM, cx);
3000
0
3001
0
  auto result(StrongOrRawPtr<nsIURI>(self->GetDocumentURI()));
3002
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3003
0
  if (!result) {
3004
0
    args.rval().setNull();
3005
0
    return true;
3006
0
  }
3007
0
  if (!WrapObject(cx, result, &NS_GET_IID(nsIURI), args.rval())) {
3008
0
    return false;
3009
0
  }
3010
0
  return true;
3011
0
}
3012
3013
static const JSJitInfo documentURI_getterinfo = {
3014
  { (JSJitGetterOp)get_documentURI },
3015
  { prototypes::id::ChannelWrapper },
3016
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3017
  JSJitInfo::Getter,
3018
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3019
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3020
  false,  /* isInfallible. False in setters. */
3021
  true,  /* isMovable.  Not relevant for setters. */
3022
  true, /* isEliminatable.  Not relevant for setters. */
3023
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3024
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3025
  false,  /* isTypedMethod.  Only relevant for methods. */
3026
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3027
};
3028
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3029
static_assert(0 < 20, "There is no slot for us");
3030
3031
MOZ_CAN_RUN_SCRIPT static bool
3032
get_canModify(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
3033
0
{
3034
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.canModify", DOM, cx);
3035
0
3036
0
  // Have to either root across the getter call or reget after.
3037
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
3038
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
3039
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 14);
3040
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
3041
0
  {
3042
0
    // Scope for cachedVal
3043
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
3044
0
    if (!cachedVal.isUndefined()) {
3045
0
      args.rval().set(cachedVal);
3046
0
      // The cached value is in the compartment of slotStorage,
3047
0
      // so wrap into the caller compartment as needed.
3048
0
      if (MaybeWrapValue(cx, args.rval())) {
3049
0
        return true;
3050
0
      }
3051
0
      return false;
3052
0
    }
3053
0
  }
3054
0
3055
0
  FastErrorResult rv;
3056
0
  bool result(self->GetCanModify(rv));
3057
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3058
0
    return false;
3059
0
  }
3060
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3061
0
  {
3062
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
3063
0
    JSAutoRealm ar(cx, conversionScope);
3064
0
    do { // block we break out of when done wrapping
3065
0
      args.rval().setBoolean(result);
3066
0
      break;
3067
0
    } while (false);
3068
0
  }
3069
0
  { // And now store things in the realm of our slotStorage.
3070
0
    JSAutoRealm ar(cx, slotStorage);
3071
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
3072
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
3073
0
    if (!MaybeWrapValue(cx, &storedVal)) {
3074
0
      return false;
3075
0
    }
3076
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
3077
0
    PreserveWrapper(self);
3078
0
  }
3079
0
  // And now make sure args.rval() is in the caller realm.
3080
0
  if (MaybeWrapValue(cx, args.rval())) {
3081
0
    return true;
3082
0
  }
3083
0
  return false;
3084
0
}
3085
3086
static const JSJitInfo canModify_getterinfo = {
3087
  { (JSJitGetterOp)get_canModify },
3088
  { prototypes::id::ChannelWrapper },
3089
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3090
  JSJitInfo::Getter,
3091
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3092
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
3093
  false,  /* isInfallible. False in setters. */
3094
  false,  /* isMovable.  Not relevant for setters. */
3095
  false, /* isEliminatable.  Not relevant for setters. */
3096
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3097
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
3098
  false,  /* isTypedMethod.  Only relevant for methods. */
3099
  (DOM_INSTANCE_RESERVED_SLOTS + 14)   /* Reserved slot index, if we're stored in a slot, else 0. */
3100
};
3101
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 14) <= JSJitInfo::maxSlotIndex, "We won't fit");
3102
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 14) < 20, "There is no slot for us");
3103
3104
MOZ_CAN_RUN_SCRIPT static bool
3105
get_windowId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
3106
0
{
3107
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.windowId", DOM, cx);
3108
0
3109
0
  // Have to either root across the getter call or reget after.
3110
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
3111
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
3112
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 15);
3113
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
3114
0
  {
3115
0
    // Scope for cachedVal
3116
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
3117
0
    if (!cachedVal.isUndefined()) {
3118
0
      args.rval().set(cachedVal);
3119
0
      // The cached value is in the compartment of slotStorage,
3120
0
      // so wrap into the caller compartment as needed.
3121
0
      if (MaybeWrapValue(cx, args.rval())) {
3122
0
        return true;
3123
0
      }
3124
0
      return false;
3125
0
    }
3126
0
  }
3127
0
3128
0
  int64_t result(self->WindowId());
3129
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3130
0
  {
3131
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
3132
0
    JSAutoRealm ar(cx, conversionScope);
3133
0
    do { // block we break out of when done wrapping
3134
0
      args.rval().set(JS_NumberValue(double(result)));
3135
0
      break;
3136
0
    } while (false);
3137
0
  }
3138
0
  { // And now store things in the realm of our slotStorage.
3139
0
    JSAutoRealm ar(cx, slotStorage);
3140
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
3141
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
3142
0
    if (!MaybeWrapValue(cx, &storedVal)) {
3143
0
      return false;
3144
0
    }
3145
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
3146
0
    PreserveWrapper(self);
3147
0
  }
3148
0
  // And now make sure args.rval() is in the caller realm.
3149
0
  if (MaybeWrapValue(cx, args.rval())) {
3150
0
    return true;
3151
0
  }
3152
0
  return false;
3153
0
}
3154
3155
static const JSJitInfo windowId_getterinfo = {
3156
  { (JSJitGetterOp)get_windowId },
3157
  { prototypes::id::ChannelWrapper },
3158
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3159
  JSJitInfo::Getter,
3160
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3161
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
3162
  true,  /* isInfallible. False in setters. */
3163
  true,  /* isMovable.  Not relevant for setters. */
3164
  true, /* isEliminatable.  Not relevant for setters. */
3165
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3166
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
3167
  false,  /* isTypedMethod.  Only relevant for methods. */
3168
  (DOM_INSTANCE_RESERVED_SLOTS + 15)   /* Reserved slot index, if we're stored in a slot, else 0. */
3169
};
3170
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 15) <= JSJitInfo::maxSlotIndex, "We won't fit");
3171
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 15) < 20, "There is no slot for us");
3172
3173
MOZ_CAN_RUN_SCRIPT static bool
3174
get_parentWindowId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
3175
0
{
3176
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.parentWindowId", DOM, cx);
3177
0
3178
0
  // Have to either root across the getter call or reget after.
3179
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
3180
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
3181
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 16);
3182
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
3183
0
  {
3184
0
    // Scope for cachedVal
3185
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
3186
0
    if (!cachedVal.isUndefined()) {
3187
0
      args.rval().set(cachedVal);
3188
0
      // The cached value is in the compartment of slotStorage,
3189
0
      // so wrap into the caller compartment as needed.
3190
0
      if (MaybeWrapValue(cx, args.rval())) {
3191
0
        return true;
3192
0
      }
3193
0
      return false;
3194
0
    }
3195
0
  }
3196
0
3197
0
  int64_t result(self->ParentWindowId());
3198
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3199
0
  {
3200
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
3201
0
    JSAutoRealm ar(cx, conversionScope);
3202
0
    do { // block we break out of when done wrapping
3203
0
      args.rval().set(JS_NumberValue(double(result)));
3204
0
      break;
3205
0
    } while (false);
3206
0
  }
3207
0
  { // And now store things in the realm of our slotStorage.
3208
0
    JSAutoRealm ar(cx, slotStorage);
3209
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
3210
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
3211
0
    if (!MaybeWrapValue(cx, &storedVal)) {
3212
0
      return false;
3213
0
    }
3214
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
3215
0
    PreserveWrapper(self);
3216
0
  }
3217
0
  // And now make sure args.rval() is in the caller realm.
3218
0
  if (MaybeWrapValue(cx, args.rval())) {
3219
0
    return true;
3220
0
  }
3221
0
  return false;
3222
0
}
3223
3224
static const JSJitInfo parentWindowId_getterinfo = {
3225
  { (JSJitGetterOp)get_parentWindowId },
3226
  { prototypes::id::ChannelWrapper },
3227
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3228
  JSJitInfo::Getter,
3229
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3230
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
3231
  true,  /* isInfallible. False in setters. */
3232
  true,  /* isMovable.  Not relevant for setters. */
3233
  true, /* isEliminatable.  Not relevant for setters. */
3234
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3235
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
3236
  false,  /* isTypedMethod.  Only relevant for methods. */
3237
  (DOM_INSTANCE_RESERVED_SLOTS + 16)   /* Reserved slot index, if we're stored in a slot, else 0. */
3238
};
3239
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 16) <= JSJitInfo::maxSlotIndex, "We won't fit");
3240
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 16) < 20, "There is no slot for us");
3241
3242
MOZ_CAN_RUN_SCRIPT static bool
3243
get_browserElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
3244
0
{
3245
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.browserElement", DOM, cx);
3246
0
3247
0
  // Have to either root across the getter call or reget after.
3248
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
3249
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
3250
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 17);
3251
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
3252
0
  {
3253
0
    // Scope for cachedVal
3254
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
3255
0
    if (!cachedVal.isUndefined()) {
3256
0
      args.rval().set(cachedVal);
3257
0
      // The cached value is in the compartment of slotStorage,
3258
0
      // so wrap into the caller compartment as needed.
3259
0
      if (MaybeWrapValue(cx, args.rval())) {
3260
0
        return true;
3261
0
      }
3262
0
      return false;
3263
0
    }
3264
0
  }
3265
0
3266
0
  auto result(StrongOrRawPtr<nsISupports>(self->GetBrowserElement()));
3267
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3268
0
  {
3269
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
3270
0
    JSAutoRealm ar(cx, conversionScope);
3271
0
    do { // block we break out of when done wrapping
3272
0
      if (!result) {
3273
0
        args.rval().setNull();
3274
0
        break;
3275
0
      }
3276
0
      if (!WrapObject(cx, result, args.rval())) {
3277
0
        return false;
3278
0
      }
3279
0
      break;
3280
0
    } while (false);
3281
0
  }
3282
0
  { // And now store things in the realm of our slotStorage.
3283
0
    JSAutoRealm ar(cx, slotStorage);
3284
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
3285
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
3286
0
    if (!MaybeWrapValue(cx, &storedVal)) {
3287
0
      return false;
3288
0
    }
3289
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
3290
0
    PreserveWrapper(self);
3291
0
  }
3292
0
  // And now make sure args.rval() is in the caller realm.
3293
0
  if (MaybeWrapValue(cx, args.rval())) {
3294
0
    return true;
3295
0
  }
3296
0
  return false;
3297
0
}
3298
3299
static const JSJitInfo browserElement_getterinfo = {
3300
  { (JSJitGetterOp)get_browserElement },
3301
  { prototypes::id::ChannelWrapper },
3302
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3303
  JSJitInfo::Getter,
3304
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3305
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3306
  false,  /* isInfallible. False in setters. */
3307
  true,  /* isMovable.  Not relevant for setters. */
3308
  true, /* isEliminatable.  Not relevant for setters. */
3309
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3310
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
3311
  false,  /* isTypedMethod.  Only relevant for methods. */
3312
  (DOM_INSTANCE_RESERVED_SLOTS + 17)   /* Reserved slot index, if we're stored in a slot, else 0. */
3313
};
3314
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 17) <= JSJitInfo::maxSlotIndex, "We won't fit");
3315
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 17) < 20, "There is no slot for us");
3316
3317
MOZ_CAN_RUN_SCRIPT static bool
3318
get_frameAncestors(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, JSJitGetterCallArgs args)
3319
0
{
3320
0
  AUTO_PROFILER_LABEL_FAST("get ChannelWrapper.frameAncestors", DOM, cx);
3321
0
3322
0
  // Have to either root across the getter call or reget after.
3323
0
  JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
3324
0
  MOZ_ASSERT(IsDOMObject(slotStorage));
3325
0
  const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 18);
3326
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
3327
0
  {
3328
0
    // Scope for cachedVal
3329
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
3330
0
    if (!cachedVal.isUndefined()) {
3331
0
      args.rval().set(cachedVal);
3332
0
      // The cached value is in the compartment of slotStorage,
3333
0
      // so wrap into the caller compartment as needed.
3334
0
      if (MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3335
0
        return true;
3336
0
      }
3337
0
      return false;
3338
0
    }
3339
0
  }
3340
0
3341
0
  FastErrorResult rv;
3342
0
  Nullable<nsTArray<MozFrameAncestorInfo>> result;
3343
0
  self->GetFrameAncestors(result, rv);
3344
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3345
0
    return false;
3346
0
  }
3347
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3348
0
  {
3349
0
    JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
3350
0
    JSAutoRealm ar(cx, conversionScope);
3351
0
    do { // block we break out of when done wrapping
3352
0
3353
0
      if (result.IsNull()) {
3354
0
        args.rval().setNull();
3355
0
        break;
3356
0
      }
3357
0
3358
0
      uint32_t length = result.Value().Length();
3359
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3360
0
      if (!returnArray) {
3361
0
        return false;
3362
0
      }
3363
0
      // Scope for 'tmp'
3364
0
      {
3365
0
        JS::Rooted<JS::Value> tmp(cx);
3366
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3367
0
          // Control block to let us common up the JS_DefineElement calls when there
3368
0
          // are different ways to succeed at wrapping the object.
3369
0
          do {
3370
0
            if (!result.Value()[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
3371
0
              return false;
3372
0
            }
3373
0
            break;
3374
0
          } while (false);
3375
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3376
0
                                JSPROP_ENUMERATE)) {
3377
0
            return false;
3378
0
          }
3379
0
        }
3380
0
      }
3381
0
      args.rval().setObject(*returnArray);
3382
0
      break;
3383
0
    } while (false);
3384
0
    if (args.rval().isObject()) {
3385
0
      JS::Rooted<JSObject*> rvalObj(cx, &args.rval().toObject());
3386
0
      if (!JS_FreezeObject(cx, rvalObj)) {
3387
0
        return false;
3388
0
      }
3389
0
    }
3390
0
  }
3391
0
  { // And now store things in the realm of our slotStorage.
3392
0
    JSAutoRealm ar(cx, slotStorage);
3393
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
3394
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
3395
0
    if (!MaybeWrapNonDOMObjectOrNullValue(cx, &storedVal)) {
3396
0
      return false;
3397
0
    }
3398
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
3399
0
    PreserveWrapper(self);
3400
0
  }
3401
0
  // And now make sure args.rval() is in the caller realm.
3402
0
  if (MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3403
0
    return true;
3404
0
  }
3405
0
  return false;
3406
0
}
3407
3408
static const JSJitInfo frameAncestors_getterinfo = {
3409
  { (JSJitGetterOp)get_frameAncestors },
3410
  { prototypes::id::ChannelWrapper },
3411
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3412
  JSJitInfo::Getter,
3413
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3414
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3415
  false,  /* isInfallible. False in setters. */
3416
  false,  /* isMovable.  Not relevant for setters. */
3417
  false, /* isEliminatable.  Not relevant for setters. */
3418
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3419
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
3420
  false,  /* isTypedMethod.  Only relevant for methods. */
3421
  (DOM_INSTANCE_RESERVED_SLOTS + 18)   /* Reserved slot index, if we're stored in a slot, else 0. */
3422
};
3423
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 18) <= JSJitInfo::maxSlotIndex, "We won't fit");
3424
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 18) < 20, "There is no slot for us");
3425
3426
MOZ_CAN_RUN_SCRIPT static bool
3427
getRequestHeaders(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
3428
0
{
3429
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.getRequestHeaders", DOM, cx);
3430
0
3431
0
  FastErrorResult rv;
3432
0
  nsTArray<MozHTTPHeader> result;
3433
0
  self->GetRequestHeaders(result, rv);
3434
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3435
0
    return false;
3436
0
  }
3437
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3438
0
3439
0
  uint32_t length = result.Length();
3440
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3441
0
  if (!returnArray) {
3442
0
    return false;
3443
0
  }
3444
0
  // Scope for 'tmp'
3445
0
  {
3446
0
    JS::Rooted<JS::Value> tmp(cx);
3447
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3448
0
      // Control block to let us common up the JS_DefineElement calls when there
3449
0
      // are different ways to succeed at wrapping the object.
3450
0
      do {
3451
0
        if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
3452
0
          return false;
3453
0
        }
3454
0
        break;
3455
0
      } while (false);
3456
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3457
0
                            JSPROP_ENUMERATE)) {
3458
0
        return false;
3459
0
      }
3460
0
    }
3461
0
  }
3462
0
  args.rval().setObject(*returnArray);
3463
0
  return true;
3464
0
}
3465
3466
static const JSJitInfo getRequestHeaders_methodinfo = {
3467
  { (JSJitGetterOp)getRequestHeaders },
3468
  { prototypes::id::ChannelWrapper },
3469
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3470
  JSJitInfo::Method,
3471
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3472
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3473
  false,  /* isInfallible. False in setters. */
3474
  false,  /* isMovable.  Not relevant for setters. */
3475
  false, /* isEliminatable.  Not relevant for setters. */
3476
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3477
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3478
  false,  /* isTypedMethod.  Only relevant for methods. */
3479
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3480
};
3481
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3482
static_assert(0 < 20, "There is no slot for us");
3483
3484
MOZ_CAN_RUN_SCRIPT static bool
3485
getResponseHeaders(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
3486
0
{
3487
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.getResponseHeaders", DOM, cx);
3488
0
3489
0
  FastErrorResult rv;
3490
0
  nsTArray<MozHTTPHeader> result;
3491
0
  self->GetResponseHeaders(result, rv);
3492
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3493
0
    return false;
3494
0
  }
3495
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3496
0
3497
0
  uint32_t length = result.Length();
3498
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3499
0
  if (!returnArray) {
3500
0
    return false;
3501
0
  }
3502
0
  // Scope for 'tmp'
3503
0
  {
3504
0
    JS::Rooted<JS::Value> tmp(cx);
3505
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3506
0
      // Control block to let us common up the JS_DefineElement calls when there
3507
0
      // are different ways to succeed at wrapping the object.
3508
0
      do {
3509
0
        if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
3510
0
          return false;
3511
0
        }
3512
0
        break;
3513
0
      } while (false);
3514
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3515
0
                            JSPROP_ENUMERATE)) {
3516
0
        return false;
3517
0
      }
3518
0
    }
3519
0
  }
3520
0
  args.rval().setObject(*returnArray);
3521
0
  return true;
3522
0
}
3523
3524
static const JSJitInfo getResponseHeaders_methodinfo = {
3525
  { (JSJitGetterOp)getResponseHeaders },
3526
  { prototypes::id::ChannelWrapper },
3527
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3528
  JSJitInfo::Method,
3529
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3530
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3531
  false,  /* isInfallible. False in setters. */
3532
  false,  /* isMovable.  Not relevant for setters. */
3533
  false, /* isEliminatable.  Not relevant for setters. */
3534
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3535
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3536
  false,  /* isTypedMethod.  Only relevant for methods. */
3537
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3538
};
3539
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3540
static_assert(0 < 20, "There is no slot for us");
3541
3542
MOZ_CAN_RUN_SCRIPT static bool
3543
setRequestHeader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
3544
0
{
3545
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.setRequestHeader", DOM, cx);
3546
0
3547
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3548
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelWrapper.setRequestHeader");
3549
0
  }
3550
0
  nsCString arg0;
3551
0
  if (!ConvertJSValueToByteString(cx, args[0], false, arg0)) {
3552
0
    return false;
3553
0
  }
3554
0
  nsCString arg1;
3555
0
  if (!ConvertJSValueToByteString(cx, args[1], false, arg1)) {
3556
0
    return false;
3557
0
  }
3558
0
  bool arg2;
3559
0
  if (args.hasDefined(2)) {
3560
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
3561
0
      return false;
3562
0
    }
3563
0
  } else {
3564
0
    arg2 = false;
3565
0
  }
3566
0
  FastErrorResult rv;
3567
0
  self->SetRequestHeader(Constify(arg0), Constify(arg1), arg2, rv);
3568
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3569
0
    return false;
3570
0
  }
3571
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3572
0
  args.rval().setUndefined();
3573
0
  return true;
3574
0
}
3575
3576
static const JSJitInfo setRequestHeader_methodinfo = {
3577
  { (JSJitGetterOp)setRequestHeader },
3578
  { prototypes::id::ChannelWrapper },
3579
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3580
  JSJitInfo::Method,
3581
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3582
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3583
  false,  /* isInfallible. False in setters. */
3584
  false,  /* isMovable.  Not relevant for setters. */
3585
  false, /* isEliminatable.  Not relevant for setters. */
3586
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3587
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3588
  false,  /* isTypedMethod.  Only relevant for methods. */
3589
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3590
};
3591
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3592
static_assert(0 < 20, "There is no slot for us");
3593
3594
MOZ_CAN_RUN_SCRIPT static bool
3595
setResponseHeader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::extensions::ChannelWrapper* self, const JSJitMethodCallArgs& args)
3596
0
{
3597
0
  AUTO_PROFILER_LABEL_FAST("ChannelWrapper.setResponseHeader", DOM, cx);
3598
0
3599
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3600
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelWrapper.setResponseHeader");
3601
0
  }
3602
0
  nsCString arg0;
3603
0
  if (!ConvertJSValueToByteString(cx, args[0], false, arg0)) {
3604
0
    return false;
3605
0
  }
3606
0
  nsCString arg1;
3607
0
  if (!ConvertJSValueToByteString(cx, args[1], false, arg1)) {
3608
0
    return false;
3609
0
  }
3610
0
  bool arg2;
3611
0
  if (args.hasDefined(2)) {
3612
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
3613
0
      return false;
3614
0
    }
3615
0
  } else {
3616
0
    arg2 = false;
3617
0
  }
3618
0
  FastErrorResult rv;
3619
0
  self->SetResponseHeader(Constify(arg0), Constify(arg1), arg2, rv);
3620
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3621
0
    return false;
3622
0
  }
3623
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3624
0
  args.rval().setUndefined();
3625
0
  return true;
3626
0
}
3627
3628
static const JSJitInfo setResponseHeader_methodinfo = {
3629
  { (JSJitGetterOp)setResponseHeader },
3630
  { prototypes::id::ChannelWrapper },
3631
  { PrototypeTraits<prototypes::id::ChannelWrapper>::Depth },
3632
  JSJitInfo::Method,
3633
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3634
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3635
  false,  /* isInfallible. False in setters. */
3636
  false,  /* isMovable.  Not relevant for setters. */
3637
  false, /* isEliminatable.  Not relevant for setters. */
3638
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3639
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3640
  false,  /* isTypedMethod.  Only relevant for methods. */
3641
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3642
};
3643
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3644
static_assert(0 < 20, "There is no slot for us");
3645
3646
static bool
3647
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
3648
0
{
3649
0
  mozilla::extensions::ChannelWrapper* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::extensions::ChannelWrapper>(obj);
3650
0
  // We don't want to preserve if we don't have a wrapper, and we
3651
0
  // obviously can't preserve if we're not initialized.
3652
0
  if (self && self->GetWrapperPreserveColor()) {
3653
0
    PreserveWrapper(self);
3654
0
  }
3655
0
  return true;
3656
0
}
3657
3658
static void
3659
_finalize(js::FreeOp* fop, JSObject* obj)
3660
0
{
3661
0
  mozilla::extensions::ChannelWrapper* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::extensions::ChannelWrapper>(obj);
3662
0
  if (self) {
3663
0
    ClearWrapper(self, self, obj);
3664
0
    AddForDeferredFinalization<mozilla::extensions::ChannelWrapper>(self);
3665
0
  }
3666
0
}
3667
3668
static size_t
3669
_objectMoved(JSObject* obj, JSObject* old)
3670
0
{
3671
0
  mozilla::extensions::ChannelWrapper* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::extensions::ChannelWrapper>(obj);
3672
0
  if (self) {
3673
0
    UpdateWrapper(self, self, obj, old);
3674
0
  }
3675
0
3676
0
  return 0;
3677
0
}
3678
3679
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3680
#if defined(__clang__)
3681
#pragma clang diagnostic push
3682
#pragma clang diagnostic ignored "-Wmissing-braces"
3683
#endif
3684
static const JSFunctionSpec sStaticMethods_specs[] = {
3685
  JS_FNSPEC("get", get, nullptr, 1, JSPROP_ENUMERATE, nullptr),
3686
  JS_FNSPEC("getRegisteredChannel", getRegisteredChannel, nullptr, 3, JSPROP_ENUMERATE, nullptr),
3687
  JS_FS_END
3688
};
3689
#if defined(__clang__)
3690
#pragma clang diagnostic pop
3691
#endif
3692
3693
3694
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
3695
  { nullptr, &sStaticMethods_specs[0] },
3696
  { nullptr, nullptr }
3697
};
3698
3699
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3700
#if defined(__clang__)
3701
#pragma clang diagnostic push
3702
#pragma clang diagnostic ignored "-Wmissing-braces"
3703
#endif
3704
static const JSFunctionSpec sMethods_specs[] = {
3705
  JS_FNSPEC("cancel", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&cancel_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3706
  JS_FNSPEC("redirectTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&redirectTo_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3707
  JS_FNSPEC("upgradeToSecure", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&upgradeToSecure_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3708
  JS_FNSPEC("matches", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&matches_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3709
  JS_FNSPEC("registerTraceableChannel", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&registerTraceableChannel_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
3710
  JS_FNSPEC("errorCheck", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&errorCheck_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3711
  JS_FNSPEC("getRequestHeaders", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getRequestHeaders_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3712
  JS_FNSPEC("getResponseHeaders", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getResponseHeaders_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
3713
  JS_FNSPEC("setRequestHeader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setRequestHeader_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
3714
  JS_FNSPEC("setResponseHeader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setResponseHeader_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
3715
  JS_FS_END
3716
};
3717
#if defined(__clang__)
3718
#pragma clang diagnostic pop
3719
#endif
3720
3721
3722
static const Prefable<const JSFunctionSpec> sMethods[] = {
3723
  { nullptr, &sMethods_specs[0] },
3724
  { nullptr, nullptr }
3725
};
3726
3727
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3728
#if defined(__clang__)
3729
#pragma clang diagnostic push
3730
#pragma clang diagnostic ignored "-Wmissing-braces"
3731
#endif
3732
static const JSPropertySpec sAttributes_specs[] = {
3733
  { "id", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &id_getterinfo, nullptr, nullptr },
3734
  { "channel", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &channel_getterinfo, GenericSetter<NormalThisPolicy>, &channel_setterinfo },
3735
  { "contentType", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &contentType_getterinfo, GenericSetter<NormalThisPolicy>, &contentType_setterinfo },
3736
  { "method", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &method_getterinfo, nullptr, nullptr },
3737
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr },
3738
  { "suspended", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &suspended_getterinfo, GenericSetter<NormalThisPolicy>, &suspended_setterinfo },
3739
  { "finalURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &finalURI_getterinfo, nullptr, nullptr },
3740
  { "finalURL", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &finalURL_getterinfo, nullptr, nullptr },
3741
  { "statusCode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &statusCode_getterinfo, nullptr, nullptr },
3742
  { "statusLine", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &statusLine_getterinfo, nullptr, nullptr },
3743
  { "errorString", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &errorString_getterinfo, nullptr, nullptr },
3744
  { "onerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onerror_getterinfo, GenericSetter<NormalThisPolicy>, &onerror_setterinfo },
3745
  { "onstart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onstart_getterinfo, GenericSetter<NormalThisPolicy>, &onstart_setterinfo },
3746
  { "onstop", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onstop_getterinfo, GenericSetter<NormalThisPolicy>, &onstop_setterinfo },
3747
  { "proxyInfo", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &proxyInfo_getterinfo, nullptr, nullptr },
3748
  { "remoteAddress", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &remoteAddress_getterinfo, nullptr, nullptr },
3749
  { "loadInfo", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &loadInfo_getterinfo, nullptr, nullptr },
3750
  { "isSystemLoad", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isSystemLoad_getterinfo, nullptr, nullptr },
3751
  { "originURL", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &originURL_getterinfo, nullptr, nullptr },
3752
  { "documentURL", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &documentURL_getterinfo, nullptr, nullptr },
3753
  { "originURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &originURI_getterinfo, nullptr, nullptr },
3754
  { "documentURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &documentURI_getterinfo, nullptr, nullptr },
3755
  { "canModify", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &canModify_getterinfo, nullptr, nullptr },
3756
  { "windowId", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &windowId_getterinfo, nullptr, nullptr },
3757
  { "parentWindowId", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &parentWindowId_getterinfo, nullptr, nullptr },
3758
  { "browserElement", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &browserElement_getterinfo, nullptr, nullptr },
3759
  { "frameAncestors", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &frameAncestors_getterinfo, nullptr, nullptr },
3760
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
3761
};
3762
#if defined(__clang__)
3763
#pragma clang diagnostic pop
3764
#endif
3765
3766
3767
static const Prefable<const JSPropertySpec> sAttributes[] = {
3768
  { nullptr, &sAttributes_specs[0] },
3769
  { nullptr, nullptr }
3770
};
3771
3772
3773
static const NativePropertiesN<3> sNativeProperties = {
3774
  true,  0 /* sStaticMethods */,
3775
  false, 0,
3776
  true,  1 /* sMethods */,
3777
  true,  2 /* sAttributes */,
3778
  false, 0,
3779
  false, 0,
3780
  false, 0,
3781
  -1,
3782
  0,
3783
  nullptr,
3784
  {
3785
    { sStaticMethods, nullptr },
3786
    { sMethods, nullptr },
3787
    { sAttributes, nullptr }
3788
  }
3789
};
3790
3791
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
3792
  {
3793
    "Function",
3794
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
3795
    &sBoringInterfaceObjectClassClassOps,
3796
    JS_NULL_CLASS_SPEC,
3797
    JS_NULL_CLASS_EXT,
3798
    &sInterfaceObjectClassObjectOps
3799
  },
3800
  eInterface,
3801
  true,
3802
  prototypes::id::ChannelWrapper,
3803
  PrototypeTraits<prototypes::id::ChannelWrapper>::Depth,
3804
  &sEmptyNativePropertyHooks,
3805
  "function ChannelWrapper() {\n    [native code]\n}",
3806
  EventTarget_Binding::GetConstructorObject
3807
};
3808
3809
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
3810
  {
3811
    "ChannelWrapperPrototype",
3812
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
3813
    JS_NULL_CLASS_OPS,
3814
    JS_NULL_CLASS_SPEC,
3815
    JS_NULL_CLASS_EXT,
3816
    JS_NULL_OBJECT_OPS
3817
  },
3818
  eInterfacePrototype,
3819
  false,
3820
  prototypes::id::ChannelWrapper,
3821
  PrototypeTraits<prototypes::id::ChannelWrapper>::Depth,
3822
  &sEmptyNativePropertyHooks,
3823
  "[object ChannelWrapperPrototype]",
3824
  EventTarget_Binding::GetProtoObject
3825
};
3826
3827
bool
3828
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
3829
0
{
3830
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
3831
0
}
3832
3833
static const js::ClassOps sClassOps = {
3834
  _addProperty, /* addProperty */
3835
  nullptr,               /* delProperty */
3836
  nullptr,               /* enumerate */
3837
  nullptr, /* newEnumerate */
3838
  nullptr, /* resolve */
3839
  nullptr, /* mayResolve */
3840
  _finalize, /* finalize */
3841
  nullptr, /* call */
3842
  nullptr,               /* hasInstance */
3843
  nullptr,               /* construct */
3844
  nullptr, /* trace */
3845
};
3846
3847
static const js::ClassExtension sClassExtension = {
3848
  nullptr, /* weakmapKeyDelegateOp */
3849
  _objectMoved /* objectMovedOp */
3850
};
3851
3852
static const DOMJSClass sClass = {
3853
  { "ChannelWrapper",
3854
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(20),
3855
    &sClassOps,
3856
    JS_NULL_CLASS_SPEC,
3857
    &sClassExtension,
3858
    JS_NULL_OBJECT_OPS
3859
  },
3860
  { prototypes::id::EventTarget, prototypes::id::ChannelWrapper, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
3861
  IsBaseOf<nsISupports, mozilla::extensions::ChannelWrapper >::value,
3862
  &sEmptyNativePropertyHooks,
3863
  FindAssociatedGlobalForNative<mozilla::extensions::ChannelWrapper>::Get,
3864
  GetProtoObjectHandle,
3865
  GetCCParticipant<mozilla::extensions::ChannelWrapper>::Get()
3866
};
3867
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
3868
              "Must have the right minimal number of reserved slots.");
3869
static_assert(20 >= 20,
3870
              "Must have enough reserved slots.");
3871
3872
const JSClass*
3873
GetJSClass()
3874
0
{
3875
0
  return sClass.ToJSClass();
3876
0
}
3877
3878
static bool
3879
UpdateMemberSlots(JSContext* aCx, JS::Handle<JSObject*> aWrapper, mozilla::extensions::ChannelWrapper* aObject)
3880
0
{
3881
0
  JS::Rooted<JS::Value> temp(aCx);
3882
0
  JSJitGetterCallArgs args(&temp);
3883
0
3884
0
  static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < js::shadow::Object::MAX_FIXED_SLOTS,
3885
0
                "Not enough fixed slots to fit 'ChannelWrapper.id.  Ion's visitGetDOMMemberV/visitGetDOMMemberT assume StoreInSlot things are all in fixed slots.");
3886
0
  if (!get_id(aCx, aWrapper, aObject, args)) {
3887
0
    return false;
3888
0
  }
3889
0
  // Getter handled setting our reserved slots
3890
0
3891
0
  return true;
3892
0
}
3893
3894
bool
3895
Wrap(JSContext* aCx, mozilla::extensions::ChannelWrapper* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
3896
0
{
3897
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::extensions::ChannelWrapper>::value,
3898
0
                "Shouldn't have wrappercached things that are not refcounted.");
3899
0
  MOZ_ASSERT(static_cast<mozilla::extensions::ChannelWrapper*>(aObject) ==
3900
0
             reinterpret_cast<mozilla::extensions::ChannelWrapper*>(aObject),
3901
0
             "Multiple inheritance for mozilla::extensions::ChannelWrapper is broken.");
3902
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
3903
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
3904
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
3905
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
3906
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
3907
0
  MOZ_ASSERT(!aCache->GetWrapper(),
3908
0
             "You should probably not be using Wrap() directly; use "
3909
0
             "GetOrCreateDOMReflector instead");
3910
0
3911
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
3912
0
             "nsISupports must be on our primary inheritance chain");
3913
0
3914
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
3915
0
  if (!global) {
3916
0
    return false;
3917
0
  }
3918
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
3919
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
3920
0
3921
0
  // That might have ended up wrapping us already, due to the wonders
3922
0
  // of XBL.  Check for that, and bail out as needed.
3923
0
  aReflector.set(aCache->GetWrapper());
3924
0
  if (aReflector) {
3925
#ifdef DEBUG
3926
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
3927
#endif // DEBUG
3928
    return true;
3929
0
  }
3930
0
3931
0
  JSAutoRealm ar(aCx, global);
3932
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
3933
0
  if (!canonicalProto) {
3934
0
    return false;
3935
0
  }
3936
0
  JS::Rooted<JSObject*> proto(aCx);
3937
0
  if (aGivenProto) {
3938
0
    proto = aGivenProto;
3939
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
3940
0
    // coming in, we changed compartments to that of "parent" so may need
3941
0
    // to wrap the proto here.
3942
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
3943
0
      if (!JS_WrapObject(aCx, &proto)) {
3944
0
        return false;
3945
0
      }
3946
0
    }
3947
0
  } else {
3948
0
    proto = canonicalProto;
3949
0
  }
3950
0
3951
0
  BindingJSObjectCreator<mozilla::extensions::ChannelWrapper> creator(aCx);
3952
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
3953
0
  if (!aReflector) {
3954
0
    return false;
3955
0
  }
3956
0
3957
0
  aCache->SetWrapper(aReflector);
3958
0
  if (!UpdateMemberSlots(aCx, aReflector, aObject)) {
3959
0
    aCache->ReleaseWrapper(aObject);
3960
0
    aCache->ClearWrapper();
3961
0
    return false;
3962
0
  }
3963
0
  creator.InitializationSucceeded();
3964
0
3965
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
3966
0
             aCache->GetWrapperPreserveColor() == aReflector);
3967
0
  // If proto != canonicalProto, we have to preserve our wrapper;
3968
0
  // otherwise we won't be able to properly recreate it later, since
3969
0
  // we won't know what proto to use.  Note that we don't check
3970
0
  // aGivenProto here, since it's entirely possible (and even
3971
0
  // somewhat common) to have a non-null aGivenProto which is the
3972
0
  // same as canonicalProto.
3973
0
  if (proto != canonicalProto) {
3974
0
    PreserveWrapper(aObject);
3975
0
  }
3976
0
3977
0
  return true;
3978
0
}
3979
3980
void
3981
ClearCachedMethodValue(mozilla::extensions::ChannelWrapper* aObject)
3982
0
{
3983
0
  JSObject* obj;
3984
0
  obj = aObject->GetWrapper();
3985
0
  if (!obj) {
3986
0
    return;
3987
0
  }
3988
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 1), JS::UndefinedValue());
3989
0
}
3990
3991
void
3992
ClearCachedTypeValue(mozilla::extensions::ChannelWrapper* aObject)
3993
0
{
3994
0
  JSObject* obj;
3995
0
  obj = aObject->GetWrapper();
3996
0
  if (!obj) {
3997
0
    return;
3998
0
  }
3999
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 2), JS::UndefinedValue());
4000
0
}
4001
4002
void
4003
ClearCachedFinalURIValue(mozilla::extensions::ChannelWrapper* aObject)
4004
0
{
4005
0
  JSObject* obj;
4006
0
  obj = aObject->GetWrapper();
4007
0
  if (!obj) {
4008
0
    return;
4009
0
  }
4010
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 3), JS::UndefinedValue());
4011
0
}
4012
4013
void
4014
ClearCachedFinalURLValue(mozilla::extensions::ChannelWrapper* aObject)
4015
0
{
4016
0
  JSObject* obj;
4017
0
  obj = aObject->GetWrapper();
4018
0
  if (!obj) {
4019
0
    return;
4020
0
  }
4021
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 4), JS::UndefinedValue());
4022
0
}
4023
4024
void
4025
ClearCachedStatusCodeValue(mozilla::extensions::ChannelWrapper* aObject)
4026
0
{
4027
0
  JSObject* obj;
4028
0
  obj = aObject->GetWrapper();
4029
0
  if (!obj) {
4030
0
    return;
4031
0
  }
4032
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 5), JS::UndefinedValue());
4033
0
}
4034
4035
void
4036
ClearCachedStatusLineValue(mozilla::extensions::ChannelWrapper* aObject)
4037
0
{
4038
0
  JSObject* obj;
4039
0
  obj = aObject->GetWrapper();
4040
0
  if (!obj) {
4041
0
    return;
4042
0
  }
4043
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 6), JS::UndefinedValue());
4044
0
}
4045
4046
void
4047
ClearCachedErrorStringValue(mozilla::extensions::ChannelWrapper* aObject)
4048
0
{
4049
0
  JSObject* obj;
4050
0
  obj = aObject->GetWrapper();
4051
0
  if (!obj) {
4052
0
    return;
4053
0
  }
4054
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 7), JS::UndefinedValue());
4055
0
}
4056
4057
void
4058
ClearCachedProxyInfoValue(mozilla::extensions::ChannelWrapper* aObject)
4059
0
{
4060
0
  JSObject* obj;
4061
0
  obj = aObject->GetWrapper();
4062
0
  if (!obj) {
4063
0
    return;
4064
0
  }
4065
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 8), JS::UndefinedValue());
4066
0
}
4067
4068
void
4069
ClearCachedRemoteAddressValue(mozilla::extensions::ChannelWrapper* aObject)
4070
0
{
4071
0
  JSObject* obj;
4072
0
  obj = aObject->GetWrapper();
4073
0
  if (!obj) {
4074
0
    return;
4075
0
  }
4076
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 9), JS::UndefinedValue());
4077
0
}
4078
4079
void
4080
ClearCachedLoadInfoValue(mozilla::extensions::ChannelWrapper* aObject)
4081
0
{
4082
0
  JSObject* obj;
4083
0
  obj = aObject->GetWrapper();
4084
0
  if (!obj) {
4085
0
    return;
4086
0
  }
4087
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 10), JS::UndefinedValue());
4088
0
}
4089
4090
void
4091
ClearCachedIsSystemLoadValue(mozilla::extensions::ChannelWrapper* aObject)
4092
0
{
4093
0
  JSObject* obj;
4094
0
  obj = aObject->GetWrapper();
4095
0
  if (!obj) {
4096
0
    return;
4097
0
  }
4098
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 11), JS::UndefinedValue());
4099
0
}
4100
4101
void
4102
ClearCachedOriginURLValue(mozilla::extensions::ChannelWrapper* aObject)
4103
0
{
4104
0
  JSObject* obj;
4105
0
  obj = aObject->GetWrapper();
4106
0
  if (!obj) {
4107
0
    return;
4108
0
  }
4109
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 12), JS::UndefinedValue());
4110
0
}
4111
4112
void
4113
ClearCachedDocumentURLValue(mozilla::extensions::ChannelWrapper* aObject)
4114
0
{
4115
0
  JSObject* obj;
4116
0
  obj = aObject->GetWrapper();
4117
0
  if (!obj) {
4118
0
    return;
4119
0
  }
4120
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 13), JS::UndefinedValue());
4121
0
}
4122
4123
void
4124
ClearCachedCanModifyValue(mozilla::extensions::ChannelWrapper* aObject)
4125
0
{
4126
0
  JSObject* obj;
4127
0
  obj = aObject->GetWrapper();
4128
0
  if (!obj) {
4129
0
    return;
4130
0
  }
4131
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 14), JS::UndefinedValue());
4132
0
}
4133
4134
void
4135
ClearCachedBrowserElementValue(mozilla::extensions::ChannelWrapper* aObject)
4136
0
{
4137
0
  JSObject* obj;
4138
0
  obj = aObject->GetWrapper();
4139
0
  if (!obj) {
4140
0
    return;
4141
0
  }
4142
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 17), JS::UndefinedValue());
4143
0
}
4144
4145
void
4146
ClearCachedFrameAncestorsValue(mozilla::extensions::ChannelWrapper* aObject)
4147
0
{
4148
0
  JSObject* obj;
4149
0
  obj = aObject->GetWrapper();
4150
0
  if (!obj) {
4151
0
    return;
4152
0
  }
4153
0
  js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 18), JS::UndefinedValue());
4154
0
}
4155
4156
void
4157
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
4158
0
{
4159
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
4160
0
  if (!parentProto) {
4161
0
    return;
4162
0
  }
4163
0
4164
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
4165
0
  if (!constructorProto) {
4166
0
    return;
4167
0
  }
4168
0
4169
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ChannelWrapper);
4170
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ChannelWrapper);
4171
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
4172
0
                              &sPrototypeClass.mBase, protoCache,
4173
0
                              nullptr,
4174
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
4175
0
                              interfaceCache,
4176
0
                              sNativeProperties.Upcast(),
4177
0
                              nullptr,
4178
0
                              "ChannelWrapper", aDefineOnGlobal,
4179
0
                              nullptr,
4180
0
                              false);
4181
0
}
4182
4183
JSObject*
4184
GetConstructorObject(JSContext* aCx)
4185
0
{
4186
0
  return GetConstructorObjectHandle(aCx);
4187
0
}
4188
4189
} // namespace ChannelWrapper_Binding
4190
4191
4192
4193
} // namespace dom
4194
} // namespace mozilla