Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/URLBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM URL.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "URLBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/Blob.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/MediaSource.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/PrimitiveConversions.h"
12
#include "mozilla/dom/URL.h"
13
#include "mozilla/dom/URLSearchParams.h"
14
#include "mozilla/dom/XrayExpandoClass.h"
15
#include "nsContentUtils.h"
16
17
namespace mozilla {
18
namespace dom {
19
20
namespace binding_detail {}; // Just to make sure it's known as a namespace
21
using namespace mozilla::dom::binding_detail;
22
23
24
namespace URL_Binding {
25
26
MOZ_CAN_RUN_SCRIPT static bool
27
__stringifier(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, const JSJitMethodCallArgs& args)
28
0
{
29
0
  AUTO_PROFILER_LABEL_FAST("URL.__stringifier", DOM, cx);
30
0
31
0
  DOMString result;
32
0
  self->Stringify(result);
33
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
34
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
35
0
    return false;
36
0
  }
37
0
  return true;
38
0
}
39
40
static const JSJitInfo __stringifier_methodinfo = {
41
  { (JSJitGetterOp)__stringifier },
42
  { prototypes::id::URL },
43
  { PrototypeTraits<prototypes::id::URL>::Depth },
44
  JSJitInfo::Method,
45
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
46
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
47
  false,  /* isInfallible. False in setters. */
48
  false,  /* isMovable.  Not relevant for setters. */
49
  false, /* isEliminatable.  Not relevant for setters. */
50
  false, /* isAlwaysInSlot.  Only relevant for getters. */
51
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
52
  false,  /* isTypedMethod.  Only relevant for methods. */
53
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
54
};
55
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
56
static_assert(0 < 1, "There is no slot for us");
57
58
MOZ_CAN_RUN_SCRIPT static bool
59
get_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
60
0
{
61
0
  AUTO_PROFILER_LABEL_FAST("get URL.href", DOM, cx);
62
0
63
0
  DOMString result;
64
0
  self->GetHref(result);
65
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
66
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
67
0
    return false;
68
0
  }
69
0
  return true;
70
0
}
71
72
MOZ_CAN_RUN_SCRIPT static bool
73
set_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
74
0
{
75
0
  AUTO_PROFILER_LABEL_FAST("set URL.href", DOM, cx);
76
0
77
0
  binding_detail::FakeString arg0;
78
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
79
0
    return false;
80
0
  }
81
0
  NormalizeUSVString(arg0);
82
0
  FastErrorResult rv;
83
0
  self->SetHref(Constify(arg0), rv);
84
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
85
0
    return false;
86
0
  }
87
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
88
0
89
0
  return true;
90
0
}
91
92
static const JSJitInfo href_getterinfo = {
93
  { (JSJitGetterOp)get_href },
94
  { prototypes::id::URL },
95
  { PrototypeTraits<prototypes::id::URL>::Depth },
96
  JSJitInfo::Getter,
97
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
98
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
99
  false,  /* isInfallible. False in setters. */
100
  false,  /* isMovable.  Not relevant for setters. */
101
  false, /* isEliminatable.  Not relevant for setters. */
102
  false, /* isAlwaysInSlot.  Only relevant for getters. */
103
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
104
  false,  /* isTypedMethod.  Only relevant for methods. */
105
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
106
};
107
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
108
static_assert(0 < 1, "There is no slot for us");
109
static const JSJitInfo href_setterinfo = {
110
  { (JSJitGetterOp)set_href },
111
  { prototypes::id::URL },
112
  { PrototypeTraits<prototypes::id::URL>::Depth },
113
  JSJitInfo::Setter,
114
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
115
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
116
  false,  /* isInfallible. False in setters. */
117
  false,  /* isMovable.  Not relevant for setters. */
118
  false, /* isEliminatable.  Not relevant for setters. */
119
  false, /* isAlwaysInSlot.  Only relevant for getters. */
120
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
121
  false,  /* isTypedMethod.  Only relevant for methods. */
122
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
123
};
124
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
125
static_assert(0 < 1, "There is no slot for us");
126
127
MOZ_CAN_RUN_SCRIPT static bool
128
get_origin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
129
0
{
130
0
  AUTO_PROFILER_LABEL_FAST("get URL.origin", DOM, cx);
131
0
132
0
  FastErrorResult rv;
133
0
  DOMString result;
134
0
  self->GetOrigin(result, rv);
135
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
136
0
    return false;
137
0
  }
138
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
139
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
140
0
    return false;
141
0
  }
142
0
  return true;
143
0
}
144
145
static const JSJitInfo origin_getterinfo = {
146
  { (JSJitGetterOp)get_origin },
147
  { prototypes::id::URL },
148
  { PrototypeTraits<prototypes::id::URL>::Depth },
149
  JSJitInfo::Getter,
150
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
151
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
152
  false,  /* isInfallible. False in setters. */
153
  false,  /* isMovable.  Not relevant for setters. */
154
  false, /* isEliminatable.  Not relevant for setters. */
155
  false, /* isAlwaysInSlot.  Only relevant for getters. */
156
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
157
  false,  /* isTypedMethod.  Only relevant for methods. */
158
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
159
};
160
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
161
static_assert(0 < 1, "There is no slot for us");
162
163
MOZ_CAN_RUN_SCRIPT static bool
164
get_protocol(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
165
0
{
166
0
  AUTO_PROFILER_LABEL_FAST("get URL.protocol", DOM, cx);
167
0
168
0
  DOMString result;
169
0
  self->GetProtocol(result);
170
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
171
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
172
0
    return false;
173
0
  }
174
0
  return true;
175
0
}
176
177
MOZ_CAN_RUN_SCRIPT static bool
178
set_protocol(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
179
0
{
180
0
  AUTO_PROFILER_LABEL_FAST("set URL.protocol", DOM, cx);
181
0
182
0
  binding_detail::FakeString arg0;
183
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
184
0
    return false;
185
0
  }
186
0
  NormalizeUSVString(arg0);
187
0
  FastErrorResult rv;
188
0
  self->SetProtocol(Constify(arg0), rv);
189
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
190
0
    return false;
191
0
  }
192
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
193
0
194
0
  return true;
195
0
}
196
197
static const JSJitInfo protocol_getterinfo = {
198
  { (JSJitGetterOp)get_protocol },
199
  { prototypes::id::URL },
200
  { PrototypeTraits<prototypes::id::URL>::Depth },
201
  JSJitInfo::Getter,
202
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
203
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
204
  false,  /* isInfallible. False in setters. */
205
  false,  /* isMovable.  Not relevant for setters. */
206
  false, /* isEliminatable.  Not relevant for setters. */
207
  false, /* isAlwaysInSlot.  Only relevant for getters. */
208
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
209
  false,  /* isTypedMethod.  Only relevant for methods. */
210
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
211
};
212
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
213
static_assert(0 < 1, "There is no slot for us");
214
static const JSJitInfo protocol_setterinfo = {
215
  { (JSJitGetterOp)set_protocol },
216
  { prototypes::id::URL },
217
  { PrototypeTraits<prototypes::id::URL>::Depth },
218
  JSJitInfo::Setter,
219
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
220
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
221
  false,  /* isInfallible. False in setters. */
222
  false,  /* isMovable.  Not relevant for setters. */
223
  false, /* isEliminatable.  Not relevant for setters. */
224
  false, /* isAlwaysInSlot.  Only relevant for getters. */
225
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
226
  false,  /* isTypedMethod.  Only relevant for methods. */
227
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
228
};
229
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
230
static_assert(0 < 1, "There is no slot for us");
231
232
MOZ_CAN_RUN_SCRIPT static bool
233
get_username(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
234
0
{
235
0
  AUTO_PROFILER_LABEL_FAST("get URL.username", DOM, cx);
236
0
237
0
  DOMString result;
238
0
  self->GetUsername(result);
239
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
240
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
241
0
    return false;
242
0
  }
243
0
  return true;
244
0
}
245
246
MOZ_CAN_RUN_SCRIPT static bool
247
set_username(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
248
0
{
249
0
  AUTO_PROFILER_LABEL_FAST("set URL.username", DOM, cx);
250
0
251
0
  binding_detail::FakeString arg0;
252
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
253
0
    return false;
254
0
  }
255
0
  NormalizeUSVString(arg0);
256
0
  self->SetUsername(Constify(arg0));
257
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
258
0
259
0
  return true;
260
0
}
261
262
static const JSJitInfo username_getterinfo = {
263
  { (JSJitGetterOp)get_username },
264
  { prototypes::id::URL },
265
  { PrototypeTraits<prototypes::id::URL>::Depth },
266
  JSJitInfo::Getter,
267
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
268
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
269
  false,  /* isInfallible. False in setters. */
270
  false,  /* isMovable.  Not relevant for setters. */
271
  false, /* isEliminatable.  Not relevant for setters. */
272
  false, /* isAlwaysInSlot.  Only relevant for getters. */
273
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
274
  false,  /* isTypedMethod.  Only relevant for methods. */
275
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
276
};
277
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
278
static_assert(0 < 1, "There is no slot for us");
279
static const JSJitInfo username_setterinfo = {
280
  { (JSJitGetterOp)set_username },
281
  { prototypes::id::URL },
282
  { PrototypeTraits<prototypes::id::URL>::Depth },
283
  JSJitInfo::Setter,
284
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
285
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
286
  false,  /* isInfallible. False in setters. */
287
  false,  /* isMovable.  Not relevant for setters. */
288
  false, /* isEliminatable.  Not relevant for setters. */
289
  false, /* isAlwaysInSlot.  Only relevant for getters. */
290
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
291
  false,  /* isTypedMethod.  Only relevant for methods. */
292
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
293
};
294
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
295
static_assert(0 < 1, "There is no slot for us");
296
297
MOZ_CAN_RUN_SCRIPT static bool
298
get_password(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
299
0
{
300
0
  AUTO_PROFILER_LABEL_FAST("get URL.password", DOM, cx);
301
0
302
0
  DOMString result;
303
0
  self->GetPassword(result);
304
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
305
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
306
0
    return false;
307
0
  }
308
0
  return true;
309
0
}
310
311
MOZ_CAN_RUN_SCRIPT static bool
312
set_password(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
313
0
{
314
0
  AUTO_PROFILER_LABEL_FAST("set URL.password", DOM, cx);
315
0
316
0
  binding_detail::FakeString arg0;
317
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
318
0
    return false;
319
0
  }
320
0
  NormalizeUSVString(arg0);
321
0
  self->SetPassword(Constify(arg0));
322
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
323
0
324
0
  return true;
325
0
}
326
327
static const JSJitInfo password_getterinfo = {
328
  { (JSJitGetterOp)get_password },
329
  { prototypes::id::URL },
330
  { PrototypeTraits<prototypes::id::URL>::Depth },
331
  JSJitInfo::Getter,
332
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
333
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
334
  false,  /* isInfallible. False in setters. */
335
  false,  /* isMovable.  Not relevant for setters. */
336
  false, /* isEliminatable.  Not relevant for setters. */
337
  false, /* isAlwaysInSlot.  Only relevant for getters. */
338
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
339
  false,  /* isTypedMethod.  Only relevant for methods. */
340
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
341
};
342
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
343
static_assert(0 < 1, "There is no slot for us");
344
static const JSJitInfo password_setterinfo = {
345
  { (JSJitGetterOp)set_password },
346
  { prototypes::id::URL },
347
  { PrototypeTraits<prototypes::id::URL>::Depth },
348
  JSJitInfo::Setter,
349
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
350
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
351
  false,  /* isInfallible. False in setters. */
352
  false,  /* isMovable.  Not relevant for setters. */
353
  false, /* isEliminatable.  Not relevant for setters. */
354
  false, /* isAlwaysInSlot.  Only relevant for getters. */
355
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
356
  false,  /* isTypedMethod.  Only relevant for methods. */
357
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
358
};
359
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
360
static_assert(0 < 1, "There is no slot for us");
361
362
MOZ_CAN_RUN_SCRIPT static bool
363
get_host(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
364
0
{
365
0
  AUTO_PROFILER_LABEL_FAST("get URL.host", DOM, cx);
366
0
367
0
  DOMString result;
368
0
  self->GetHost(result);
369
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
370
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
371
0
    return false;
372
0
  }
373
0
  return true;
374
0
}
375
376
MOZ_CAN_RUN_SCRIPT static bool
377
set_host(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
378
0
{
379
0
  AUTO_PROFILER_LABEL_FAST("set URL.host", DOM, cx);
380
0
381
0
  binding_detail::FakeString arg0;
382
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
383
0
    return false;
384
0
  }
385
0
  NormalizeUSVString(arg0);
386
0
  self->SetHost(Constify(arg0));
387
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
388
0
389
0
  return true;
390
0
}
391
392
static const JSJitInfo host_getterinfo = {
393
  { (JSJitGetterOp)get_host },
394
  { prototypes::id::URL },
395
  { PrototypeTraits<prototypes::id::URL>::Depth },
396
  JSJitInfo::Getter,
397
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
398
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
399
  false,  /* isInfallible. False in setters. */
400
  false,  /* isMovable.  Not relevant for setters. */
401
  false, /* isEliminatable.  Not relevant for setters. */
402
  false, /* isAlwaysInSlot.  Only relevant for getters. */
403
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
404
  false,  /* isTypedMethod.  Only relevant for methods. */
405
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
406
};
407
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
408
static_assert(0 < 1, "There is no slot for us");
409
static const JSJitInfo host_setterinfo = {
410
  { (JSJitGetterOp)set_host },
411
  { prototypes::id::URL },
412
  { PrototypeTraits<prototypes::id::URL>::Depth },
413
  JSJitInfo::Setter,
414
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
415
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
416
  false,  /* isInfallible. False in setters. */
417
  false,  /* isMovable.  Not relevant for setters. */
418
  false, /* isEliminatable.  Not relevant for setters. */
419
  false, /* isAlwaysInSlot.  Only relevant for getters. */
420
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
421
  false,  /* isTypedMethod.  Only relevant for methods. */
422
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
423
};
424
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
425
static_assert(0 < 1, "There is no slot for us");
426
427
MOZ_CAN_RUN_SCRIPT static bool
428
get_hostname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
429
0
{
430
0
  AUTO_PROFILER_LABEL_FAST("get URL.hostname", DOM, cx);
431
0
432
0
  DOMString result;
433
0
  self->GetHostname(result);
434
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
435
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
436
0
    return false;
437
0
  }
438
0
  return true;
439
0
}
440
441
MOZ_CAN_RUN_SCRIPT static bool
442
set_hostname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
443
0
{
444
0
  AUTO_PROFILER_LABEL_FAST("set URL.hostname", DOM, cx);
445
0
446
0
  binding_detail::FakeString arg0;
447
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
448
0
    return false;
449
0
  }
450
0
  NormalizeUSVString(arg0);
451
0
  self->SetHostname(Constify(arg0));
452
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
453
0
454
0
  return true;
455
0
}
456
457
static const JSJitInfo hostname_getterinfo = {
458
  { (JSJitGetterOp)get_hostname },
459
  { prototypes::id::URL },
460
  { PrototypeTraits<prototypes::id::URL>::Depth },
461
  JSJitInfo::Getter,
462
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
463
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
464
  false,  /* isInfallible. False in setters. */
465
  false,  /* isMovable.  Not relevant for setters. */
466
  false, /* isEliminatable.  Not relevant for setters. */
467
  false, /* isAlwaysInSlot.  Only relevant for getters. */
468
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
469
  false,  /* isTypedMethod.  Only relevant for methods. */
470
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
471
};
472
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
473
static_assert(0 < 1, "There is no slot for us");
474
static const JSJitInfo hostname_setterinfo = {
475
  { (JSJitGetterOp)set_hostname },
476
  { prototypes::id::URL },
477
  { PrototypeTraits<prototypes::id::URL>::Depth },
478
  JSJitInfo::Setter,
479
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
480
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
481
  false,  /* isInfallible. False in setters. */
482
  false,  /* isMovable.  Not relevant for setters. */
483
  false, /* isEliminatable.  Not relevant for setters. */
484
  false, /* isAlwaysInSlot.  Only relevant for getters. */
485
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
486
  false,  /* isTypedMethod.  Only relevant for methods. */
487
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
488
};
489
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
490
static_assert(0 < 1, "There is no slot for us");
491
492
MOZ_CAN_RUN_SCRIPT static bool
493
get_port(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
494
0
{
495
0
  AUTO_PROFILER_LABEL_FAST("get URL.port", DOM, cx);
496
0
497
0
  DOMString result;
498
0
  self->GetPort(result);
499
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
500
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
501
0
    return false;
502
0
  }
503
0
  return true;
504
0
}
505
506
MOZ_CAN_RUN_SCRIPT static bool
507
set_port(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
508
0
{
509
0
  AUTO_PROFILER_LABEL_FAST("set URL.port", DOM, cx);
510
0
511
0
  binding_detail::FakeString arg0;
512
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
513
0
    return false;
514
0
  }
515
0
  NormalizeUSVString(arg0);
516
0
  self->SetPort(Constify(arg0));
517
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
518
0
519
0
  return true;
520
0
}
521
522
static const JSJitInfo port_getterinfo = {
523
  { (JSJitGetterOp)get_port },
524
  { prototypes::id::URL },
525
  { PrototypeTraits<prototypes::id::URL>::Depth },
526
  JSJitInfo::Getter,
527
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
528
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
529
  false,  /* isInfallible. False in setters. */
530
  false,  /* isMovable.  Not relevant for setters. */
531
  false, /* isEliminatable.  Not relevant for setters. */
532
  false, /* isAlwaysInSlot.  Only relevant for getters. */
533
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
534
  false,  /* isTypedMethod.  Only relevant for methods. */
535
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
536
};
537
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
538
static_assert(0 < 1, "There is no slot for us");
539
static const JSJitInfo port_setterinfo = {
540
  { (JSJitGetterOp)set_port },
541
  { prototypes::id::URL },
542
  { PrototypeTraits<prototypes::id::URL>::Depth },
543
  JSJitInfo::Setter,
544
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
545
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
546
  false,  /* isInfallible. False in setters. */
547
  false,  /* isMovable.  Not relevant for setters. */
548
  false, /* isEliminatable.  Not relevant for setters. */
549
  false, /* isAlwaysInSlot.  Only relevant for getters. */
550
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
551
  false,  /* isTypedMethod.  Only relevant for methods. */
552
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
553
};
554
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
555
static_assert(0 < 1, "There is no slot for us");
556
557
MOZ_CAN_RUN_SCRIPT static bool
558
get_pathname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
559
0
{
560
0
  AUTO_PROFILER_LABEL_FAST("get URL.pathname", DOM, cx);
561
0
562
0
  DOMString result;
563
0
  self->GetPathname(result);
564
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
565
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
566
0
    return false;
567
0
  }
568
0
  return true;
569
0
}
570
571
MOZ_CAN_RUN_SCRIPT static bool
572
set_pathname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
573
0
{
574
0
  AUTO_PROFILER_LABEL_FAST("set URL.pathname", DOM, cx);
575
0
576
0
  binding_detail::FakeString arg0;
577
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
578
0
    return false;
579
0
  }
580
0
  NormalizeUSVString(arg0);
581
0
  self->SetPathname(Constify(arg0));
582
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
583
0
584
0
  return true;
585
0
}
586
587
static const JSJitInfo pathname_getterinfo = {
588
  { (JSJitGetterOp)get_pathname },
589
  { prototypes::id::URL },
590
  { PrototypeTraits<prototypes::id::URL>::Depth },
591
  JSJitInfo::Getter,
592
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
593
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
594
  false,  /* isInfallible. False in setters. */
595
  false,  /* isMovable.  Not relevant for setters. */
596
  false, /* isEliminatable.  Not relevant for setters. */
597
  false, /* isAlwaysInSlot.  Only relevant for getters. */
598
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
599
  false,  /* isTypedMethod.  Only relevant for methods. */
600
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
601
};
602
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
603
static_assert(0 < 1, "There is no slot for us");
604
static const JSJitInfo pathname_setterinfo = {
605
  { (JSJitGetterOp)set_pathname },
606
  { prototypes::id::URL },
607
  { PrototypeTraits<prototypes::id::URL>::Depth },
608
  JSJitInfo::Setter,
609
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
610
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
611
  false,  /* isInfallible. False in setters. */
612
  false,  /* isMovable.  Not relevant for setters. */
613
  false, /* isEliminatable.  Not relevant for setters. */
614
  false, /* isAlwaysInSlot.  Only relevant for getters. */
615
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
616
  false,  /* isTypedMethod.  Only relevant for methods. */
617
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
618
};
619
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
620
static_assert(0 < 1, "There is no slot for us");
621
622
MOZ_CAN_RUN_SCRIPT static bool
623
get_search(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
624
0
{
625
0
  AUTO_PROFILER_LABEL_FAST("get URL.search", DOM, cx);
626
0
627
0
  DOMString result;
628
0
  self->GetSearch(result);
629
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
630
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
631
0
    return false;
632
0
  }
633
0
  return true;
634
0
}
635
636
MOZ_CAN_RUN_SCRIPT static bool
637
set_search(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
638
0
{
639
0
  AUTO_PROFILER_LABEL_FAST("set URL.search", DOM, cx);
640
0
641
0
  binding_detail::FakeString arg0;
642
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
643
0
    return false;
644
0
  }
645
0
  NormalizeUSVString(arg0);
646
0
  self->SetSearch(Constify(arg0));
647
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
648
0
649
0
  return true;
650
0
}
651
652
static const JSJitInfo search_getterinfo = {
653
  { (JSJitGetterOp)get_search },
654
  { prototypes::id::URL },
655
  { PrototypeTraits<prototypes::id::URL>::Depth },
656
  JSJitInfo::Getter,
657
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
658
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
659
  false,  /* isInfallible. False in setters. */
660
  false,  /* isMovable.  Not relevant for setters. */
661
  false, /* isEliminatable.  Not relevant for setters. */
662
  false, /* isAlwaysInSlot.  Only relevant for getters. */
663
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
664
  false,  /* isTypedMethod.  Only relevant for methods. */
665
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
666
};
667
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
668
static_assert(0 < 1, "There is no slot for us");
669
static const JSJitInfo search_setterinfo = {
670
  { (JSJitGetterOp)set_search },
671
  { prototypes::id::URL },
672
  { PrototypeTraits<prototypes::id::URL>::Depth },
673
  JSJitInfo::Setter,
674
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
675
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
676
  false,  /* isInfallible. False in setters. */
677
  false,  /* isMovable.  Not relevant for setters. */
678
  false, /* isEliminatable.  Not relevant for setters. */
679
  false, /* isAlwaysInSlot.  Only relevant for getters. */
680
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
681
  false,  /* isTypedMethod.  Only relevant for methods. */
682
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
683
};
684
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
685
static_assert(0 < 1, "There is no slot for us");
686
687
MOZ_CAN_RUN_SCRIPT static bool
688
get_searchParams(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
689
0
{
690
0
  AUTO_PROFILER_LABEL_FAST("get URL.searchParams", DOM, cx);
691
0
692
0
  auto result(StrongOrRawPtr<mozilla::dom::URLSearchParams>(self->SearchParams()));
693
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
694
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
695
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
696
0
    return false;
697
0
  }
698
0
  return true;
699
0
}
700
701
static const JSJitInfo searchParams_getterinfo = {
702
  { (JSJitGetterOp)get_searchParams },
703
  { prototypes::id::URL },
704
  { PrototypeTraits<prototypes::id::URL>::Depth },
705
  JSJitInfo::Getter,
706
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
707
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
708
  false,  /* isInfallible. False in setters. */
709
  true,  /* isMovable.  Not relevant for setters. */
710
  true, /* isEliminatable.  Not relevant for setters. */
711
  false, /* isAlwaysInSlot.  Only relevant for getters. */
712
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
713
  false,  /* isTypedMethod.  Only relevant for methods. */
714
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
715
};
716
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
717
static_assert(0 < 1, "There is no slot for us");
718
719
MOZ_CAN_RUN_SCRIPT static bool
720
get_hash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
721
0
{
722
0
  AUTO_PROFILER_LABEL_FAST("get URL.hash", DOM, cx);
723
0
724
0
  DOMString result;
725
0
  self->GetHash(result);
726
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
727
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
728
0
    return false;
729
0
  }
730
0
  return true;
731
0
}
732
733
MOZ_CAN_RUN_SCRIPT static bool
734
set_hash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
735
0
{
736
0
  AUTO_PROFILER_LABEL_FAST("set URL.hash", DOM, cx);
737
0
738
0
  binding_detail::FakeString arg0;
739
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
740
0
    return false;
741
0
  }
742
0
  NormalizeUSVString(arg0);
743
0
  self->SetHash(Constify(arg0));
744
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
745
0
746
0
  return true;
747
0
}
748
749
static const JSJitInfo hash_getterinfo = {
750
  { (JSJitGetterOp)get_hash },
751
  { prototypes::id::URL },
752
  { PrototypeTraits<prototypes::id::URL>::Depth },
753
  JSJitInfo::Getter,
754
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
755
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
756
  false,  /* isInfallible. False in setters. */
757
  false,  /* isMovable.  Not relevant for setters. */
758
  false, /* isEliminatable.  Not relevant for setters. */
759
  false, /* isAlwaysInSlot.  Only relevant for getters. */
760
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
761
  false,  /* isTypedMethod.  Only relevant for methods. */
762
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
763
};
764
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
765
static_assert(0 < 1, "There is no slot for us");
766
static const JSJitInfo hash_setterinfo = {
767
  { (JSJitGetterOp)set_hash },
768
  { prototypes::id::URL },
769
  { PrototypeTraits<prototypes::id::URL>::Depth },
770
  JSJitInfo::Setter,
771
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
772
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
773
  false,  /* isInfallible. False in setters. */
774
  false,  /* isMovable.  Not relevant for setters. */
775
  false, /* isEliminatable.  Not relevant for setters. */
776
  false, /* isAlwaysInSlot.  Only relevant for getters. */
777
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
778
  false,  /* isTypedMethod.  Only relevant for methods. */
779
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
780
};
781
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
782
static_assert(0 < 1, "There is no slot for us");
783
784
MOZ_CAN_RUN_SCRIPT static bool
785
toJSON(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, const JSJitMethodCallArgs& args)
786
0
{
787
0
  AUTO_PROFILER_LABEL_FAST("URL.toJSON", DOM, cx);
788
0
789
0
  DOMString result;
790
0
  self->ToJSON(result);
791
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
792
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
793
0
    return false;
794
0
  }
795
0
  return true;
796
0
}
797
798
static const JSJitInfo toJSON_methodinfo = {
799
  { (JSJitGetterOp)toJSON },
800
  { prototypes::id::URL },
801
  { PrototypeTraits<prototypes::id::URL>::Depth },
802
  JSJitInfo::Method,
803
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
804
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
805
  false,  /* isInfallible. False in setters. */
806
  false,  /* isMovable.  Not relevant for setters. */
807
  false, /* isEliminatable.  Not relevant for setters. */
808
  false, /* isAlwaysInSlot.  Only relevant for getters. */
809
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
810
  false,  /* isTypedMethod.  Only relevant for methods. */
811
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
812
};
813
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
814
static_assert(0 < 1, "There is no slot for us");
815
816
static bool
817
createObjectURL(JSContext* cx, unsigned argc, JS::Value* vp)
818
0
{
819
0
  AUTO_PROFILER_LABEL_FAST("URL.createObjectURL", DOM, cx);
820
0
821
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
822
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
823
0
824
0
  unsigned argcount = std::min(args.length(), 1u);
825
0
  switch (argcount) {
826
0
    case 1: {
827
0
      if (args[0].isObject()) {
828
0
        do {
829
0
          NonNull<mozilla::dom::Blob> arg0;
830
0
          {
831
0
            nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
832
0
            if (NS_FAILED(rv)) {
833
0
              break;
834
0
            }
835
0
          }
836
0
          GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
837
0
          if (global.Failed()) {
838
0
            return false;
839
0
          }
840
0
841
0
          FastErrorResult rv;
842
0
          DOMString result;
843
0
          mozilla::dom::URL::CreateObjectURL(global, MOZ_KnownLive(NonNullHelper(arg0)), result, rv);
844
0
          if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
845
0
            return false;
846
0
          }
847
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
848
0
          if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
849
0
            return false;
850
0
          }
851
0
          return true;
852
0
        } while (false);
853
0
        do {
854
0
          NonNull<mozilla::dom::MediaSource> arg0;
855
0
          {
856
0
            nsresult rv = UnwrapObject<prototypes::id::MediaSource, mozilla::dom::MediaSource>(args[0], arg0);
857
0
            if (NS_FAILED(rv)) {
858
0
              break;
859
0
            }
860
0
          }
861
0
          GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
862
0
          if (global.Failed()) {
863
0
            return false;
864
0
          }
865
0
866
0
          FastErrorResult rv;
867
0
          DOMString result;
868
0
          mozilla::dom::URL::CreateObjectURL(global, MOZ_KnownLive(NonNullHelper(arg0)), result, rv);
869
0
          if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
870
0
            return false;
871
0
          }
872
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
873
0
          if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
874
0
            return false;
875
0
          }
876
0
          return true;
877
0
        } while (false);
878
0
      }
879
0
      return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "1", "URL.createObjectURL");
880
0
      break;
881
0
    }
882
0
    default: {
883
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL.createObjectURL");
884
0
      break;
885
0
    }
886
0
  }
887
0
  MOZ_CRASH("We have an always-returning default case");
888
0
  return false;
889
0
}
890
891
static bool
892
revokeObjectURL(JSContext* cx, unsigned argc, JS::Value* vp)
893
0
{
894
0
  AUTO_PROFILER_LABEL_FAST("URL.revokeObjectURL", DOM, cx);
895
0
896
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
897
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
898
0
899
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
900
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL.revokeObjectURL");
901
0
  }
902
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
903
0
  if (global.Failed()) {
904
0
    return false;
905
0
  }
906
0
907
0
  binding_detail::FakeString arg0;
908
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
909
0
    return false;
910
0
  }
911
0
  FastErrorResult rv;
912
0
  mozilla::dom::URL::RevokeObjectURL(global, NonNullHelper(Constify(arg0)), rv);
913
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
914
0
    return false;
915
0
  }
916
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
917
0
  args.rval().setUndefined();
918
0
  return true;
919
0
}
920
921
static bool
922
isValidURL(JSContext* cx, unsigned argc, JS::Value* vp)
923
0
{
924
0
  AUTO_PROFILER_LABEL_FAST("URL.isValidURL", DOM, cx);
925
0
926
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
927
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
928
0
929
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
930
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL.isValidURL");
931
0
  }
932
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
933
0
  if (global.Failed()) {
934
0
    return false;
935
0
  }
936
0
937
0
  binding_detail::FakeString arg0;
938
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
939
0
    return false;
940
0
  }
941
0
  FastErrorResult rv;
942
0
  bool result(mozilla::dom::URL::IsValidURL(global, NonNullHelper(Constify(arg0)), rv));
943
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
944
0
    return false;
945
0
  }
946
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
947
0
  args.rval().setBoolean(result);
948
0
  return true;
949
0
}
950
951
static bool
952
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
953
0
{
954
0
  mozilla::dom::URL* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URL>(obj);
955
0
  // We don't want to preserve if we don't have a wrapper, and we
956
0
  // obviously can't preserve if we're not initialized.
957
0
  if (self && self->GetWrapperPreserveColor()) {
958
0
    PreserveWrapper(self);
959
0
  }
960
0
  return true;
961
0
}
962
963
static void
964
_finalize(js::FreeOp* fop, JSObject* obj)
965
0
{
966
0
  mozilla::dom::URL* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URL>(obj);
967
0
  if (self) {
968
0
    ClearWrapper(self, self, obj);
969
0
    AddForDeferredFinalization<mozilla::dom::URL>(self);
970
0
  }
971
0
}
972
973
static size_t
974
_objectMoved(JSObject* obj, JSObject* old)
975
0
{
976
0
  mozilla::dom::URL* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URL>(obj);
977
0
  if (self) {
978
0
    UpdateWrapper(self, self, obj, old);
979
0
  }
980
0
981
0
  return 0;
982
0
}
983
984
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
985
#if defined(__clang__)
986
#pragma clang diagnostic push
987
#pragma clang diagnostic ignored "-Wmissing-braces"
988
#endif
989
static const JSFunctionSpec sStaticMethods_specs[] = {
990
  JS_FNSPEC("createObjectURL", createObjectURL, nullptr, 1, JSPROP_ENUMERATE, nullptr),
991
  JS_FNSPEC("revokeObjectURL", revokeObjectURL, nullptr, 1, JSPROP_ENUMERATE, nullptr),
992
  JS_FS_END
993
};
994
#if defined(__clang__)
995
#pragma clang diagnostic pop
996
#endif
997
998
// Can't be const because the pref-enabled boolean needs to be writable
999
static PrefableDisablers sStaticMethods_disablers0 = {
1000
  true, false, GlobalNames::ServiceWorkerGlobalScope | GlobalNames::WorkerDebuggerGlobalScope, nullptr
1001
};
1002
1003
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
1004
  { &sStaticMethods_disablers0, &sStaticMethods_specs[0] },
1005
  { nullptr, nullptr }
1006
};
1007
1008
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1009
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1010
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1011
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1012
1013
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1014
#if defined(__clang__)
1015
#pragma clang diagnostic push
1016
#pragma clang diagnostic ignored "-Wmissing-braces"
1017
#endif
1018
static const JSFunctionSpec sChromeStaticMethods_specs[] = {
1019
  JS_FNSPEC("isValidURL", isValidURL, nullptr, 1, JSPROP_ENUMERATE, nullptr),
1020
  JS_FS_END
1021
};
1022
#if defined(__clang__)
1023
#pragma clang diagnostic pop
1024
#endif
1025
1026
// Can't be const because the pref-enabled boolean needs to be writable
1027
static PrefableDisablers sChromeStaticMethods_disablers0 = {
1028
  true, false, GlobalNames::ServiceWorkerGlobalScope | GlobalNames::WorkerDebuggerGlobalScope, nullptr
1029
};
1030
1031
static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = {
1032
  { &sChromeStaticMethods_disablers0, &sChromeStaticMethods_specs[0] },
1033
  { nullptr, nullptr }
1034
};
1035
1036
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1037
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1038
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1039
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1040
1041
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1042
#if defined(__clang__)
1043
#pragma clang diagnostic push
1044
#pragma clang diagnostic ignored "-Wmissing-braces"
1045
#endif
1046
static const JSFunctionSpec sMethods_specs[] = {
1047
  JS_FNSPEC("toJSON", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&toJSON_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1048
  JS_FNSPEC("toString", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&__stringifier_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1049
  JS_FS_END
1050
};
1051
#if defined(__clang__)
1052
#pragma clang diagnostic pop
1053
#endif
1054
1055
1056
static const Prefable<const JSFunctionSpec> sMethods[] = {
1057
  { nullptr, &sMethods_specs[0] },
1058
  { nullptr, nullptr }
1059
};
1060
1061
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1062
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1063
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1064
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1065
1066
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1067
#if defined(__clang__)
1068
#pragma clang diagnostic push
1069
#pragma clang diagnostic ignored "-Wmissing-braces"
1070
#endif
1071
static const JSPropertySpec sAttributes_specs[] = {
1072
  { "href", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &href_getterinfo, GenericSetter<NormalThisPolicy>, &href_setterinfo },
1073
  { "origin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &origin_getterinfo, nullptr, nullptr },
1074
  { "protocol", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &protocol_getterinfo, GenericSetter<NormalThisPolicy>, &protocol_setterinfo },
1075
  { "username", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &username_getterinfo, GenericSetter<NormalThisPolicy>, &username_setterinfo },
1076
  { "password", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &password_getterinfo, GenericSetter<NormalThisPolicy>, &password_setterinfo },
1077
  { "host", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &host_getterinfo, GenericSetter<NormalThisPolicy>, &host_setterinfo },
1078
  { "hostname", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hostname_getterinfo, GenericSetter<NormalThisPolicy>, &hostname_setterinfo },
1079
  { "port", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &port_getterinfo, GenericSetter<NormalThisPolicy>, &port_setterinfo },
1080
  { "pathname", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pathname_getterinfo, GenericSetter<NormalThisPolicy>, &pathname_setterinfo },
1081
  { "search", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &search_getterinfo, GenericSetter<NormalThisPolicy>, &search_setterinfo },
1082
  { "searchParams", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &searchParams_getterinfo, nullptr, nullptr },
1083
  { "hash", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hash_getterinfo, GenericSetter<NormalThisPolicy>, &hash_setterinfo },
1084
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1085
};
1086
#if defined(__clang__)
1087
#pragma clang diagnostic pop
1088
#endif
1089
1090
1091
static const Prefable<const JSPropertySpec> sAttributes[] = {
1092
  { nullptr, &sAttributes_specs[0] },
1093
  { nullptr, nullptr }
1094
};
1095
1096
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1097
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1098
static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1099
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1100
1101
1102
static uint16_t sNativeProperties_sortedPropertyIndices[16];
1103
static PropertyInfo sNativeProperties_propertyInfos[16];
1104
1105
static const NativePropertiesN<3> sNativeProperties = {
1106
  true,  0 /* sStaticMethods */,
1107
  false, 0,
1108
  true,  1 /* sMethods */,
1109
  true,  2 /* sAttributes */,
1110
  false, 0,
1111
  false, 0,
1112
  false, 0,
1113
  -1,
1114
  16,
1115
  sNativeProperties_sortedPropertyIndices,
1116
  {
1117
    { sStaticMethods, &sNativeProperties_propertyInfos[0] },
1118
    { sMethods, &sNativeProperties_propertyInfos[2] },
1119
    { sAttributes, &sNativeProperties_propertyInfos[4] }
1120
  }
1121
};
1122
static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1123
    "We have a property info count that is oversized");
1124
1125
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
1126
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
1127
1128
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
1129
  true,  0 /* sChromeStaticMethods */,
1130
  false, 0,
1131
  false, 0,
1132
  false, 0,
1133
  false, 0,
1134
  false, 0,
1135
  false, 0,
1136
  -1,
1137
  1,
1138
  sChromeOnlyNativeProperties_sortedPropertyIndices,
1139
  {
1140
    { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
1141
  }
1142
};
1143
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1144
    "We have a property info count that is oversized");
1145
1146
static bool
1147
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1148
0
{
1149
0
  AUTO_PROFILER_LABEL_FAST("URL constructor", DOM, cx);
1150
0
1151
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1152
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1153
0
  if (!args.isConstructing()) {
1154
0
    // XXXbz wish I could get the name from the callee instead of
1155
0
    // Adding more relocations
1156
0
    return ThrowConstructorWithoutNew(cx, "URL");
1157
0
  }
1158
0
1159
0
  JS::Rooted<JSObject*> desiredProto(cx);
1160
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
1161
0
    return false;
1162
0
  }
1163
0
1164
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1165
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL");
1166
0
  }
1167
0
  GlobalObject global(cx, obj);
1168
0
  if (global.Failed()) {
1169
0
    return false;
1170
0
  }
1171
0
1172
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1173
0
  binding_detail::FakeString arg0;
1174
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1175
0
    return false;
1176
0
  }
1177
0
  NormalizeUSVString(arg0);
1178
0
  Optional<nsAString> arg1;
1179
0
  binding_detail::FakeString arg1_holder;
1180
0
  if (args.hasDefined(1)) {
1181
0
    if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1_holder)) {
1182
0
      return false;
1183
0
    }
1184
0
    NormalizeUSVString(arg1_holder);
1185
0
    arg1 = &arg1_holder;
1186
0
  }
1187
0
  Maybe<JSAutoRealm> ar;
1188
0
  if (objIsXray) {
1189
0
    obj = js::CheckedUnwrap(obj);
1190
0
    if (!obj) {
1191
0
      return false;
1192
0
    }
1193
0
    ar.emplace(cx, obj);
1194
0
    if (!JS_WrapObject(cx, &desiredProto)) {
1195
0
      return false;
1196
0
    }
1197
0
  }
1198
0
  FastErrorResult rv;
1199
0
  auto result(StrongOrRawPtr<mozilla::dom::URL>(mozilla::dom::URL::Constructor(global, Constify(arg0), Constify(arg1), rv)));
1200
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1201
0
    return false;
1202
0
  }
1203
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1204
0
  static_assert(!IsPointer<decltype(result)>::value,
1205
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1206
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1207
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1208
0
    return false;
1209
0
  }
1210
0
  return true;
1211
0
}
1212
1213
static const js::ClassOps sInterfaceObjectClassOps = {
1214
    nullptr,               /* addProperty */
1215
    nullptr,               /* delProperty */
1216
    nullptr,               /* enumerate */
1217
    nullptr,               /* newEnumerate */
1218
    nullptr,               /* resolve */
1219
    nullptr,               /* mayResolve */
1220
    nullptr,               /* finalize */
1221
    _constructor, /* call */
1222
    nullptr,               /* hasInstance */
1223
    _constructor, /* construct */
1224
    nullptr,               /* trace */
1225
};
1226
1227
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1228
  {
1229
    "Function",
1230
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1231
    &sInterfaceObjectClassOps,
1232
    JS_NULL_CLASS_SPEC,
1233
    JS_NULL_CLASS_EXT,
1234
    &sInterfaceObjectClassObjectOps
1235
  },
1236
  eInterface,
1237
  true,
1238
  prototypes::id::URL,
1239
  PrototypeTraits<prototypes::id::URL>::Depth,
1240
  sNativePropertyHooks,
1241
  "function URL() {\n    [native code]\n}",
1242
  JS::GetRealmFunctionPrototype
1243
};
1244
1245
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1246
  {
1247
    "URLPrototype",
1248
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1249
    JS_NULL_CLASS_OPS,
1250
    JS_NULL_CLASS_SPEC,
1251
    JS_NULL_CLASS_EXT,
1252
    JS_NULL_OBJECT_OPS
1253
  },
1254
  eInterfacePrototype,
1255
  false,
1256
  prototypes::id::URL,
1257
  PrototypeTraits<prototypes::id::URL>::Depth,
1258
  sNativePropertyHooks,
1259
  "[object URLPrototype]",
1260
  JS::GetRealmObjectPrototype
1261
};
1262
1263
static const js::ClassOps sClassOps = {
1264
  _addProperty, /* addProperty */
1265
  nullptr,               /* delProperty */
1266
  nullptr,               /* enumerate */
1267
  nullptr, /* newEnumerate */
1268
  nullptr, /* resolve */
1269
  nullptr, /* mayResolve */
1270
  _finalize, /* finalize */
1271
  nullptr, /* call */
1272
  nullptr,               /* hasInstance */
1273
  nullptr,               /* construct */
1274
  nullptr, /* trace */
1275
};
1276
1277
static const js::ClassExtension sClassExtension = {
1278
  nullptr, /* weakmapKeyDelegateOp */
1279
  _objectMoved /* objectMovedOp */
1280
};
1281
1282
static const DOMJSClass sClass = {
1283
  { "URL",
1284
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1285
    &sClassOps,
1286
    JS_NULL_CLASS_SPEC,
1287
    &sClassExtension,
1288
    JS_NULL_OBJECT_OPS
1289
  },
1290
  { prototypes::id::URL, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1291
  IsBaseOf<nsISupports, mozilla::dom::URL >::value,
1292
  sNativePropertyHooks,
1293
  FindAssociatedGlobalForNative<mozilla::dom::URL>::Get,
1294
  GetProtoObjectHandle,
1295
  GetCCParticipant<mozilla::dom::URL>::Get()
1296
};
1297
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1298
              "Must have the right minimal number of reserved slots.");
1299
static_assert(1 >= 1,
1300
              "Must have enough reserved slots.");
1301
1302
const JSClass*
1303
GetJSClass()
1304
0
{
1305
0
  return sClass.ToJSClass();
1306
0
}
1307
1308
bool
1309
Wrap(JSContext* aCx, mozilla::dom::URL* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1310
0
{
1311
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::URL>::value,
1312
0
                "Shouldn't have wrappercached things that are not refcounted.");
1313
0
  MOZ_ASSERT(static_cast<mozilla::dom::URL*>(aObject) ==
1314
0
             reinterpret_cast<mozilla::dom::URL*>(aObject),
1315
0
             "Multiple inheritance for mozilla::dom::URL is broken.");
1316
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1317
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1318
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1319
0
             "You should probably not be using Wrap() directly; use "
1320
0
             "GetOrCreateDOMReflector instead");
1321
0
1322
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1323
0
             "nsISupports must be on our primary inheritance chain");
1324
0
1325
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1326
0
  if (!global) {
1327
0
    return false;
1328
0
  }
1329
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1330
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1331
0
1332
0
  // That might have ended up wrapping us already, due to the wonders
1333
0
  // of XBL.  Check for that, and bail out as needed.
1334
0
  aReflector.set(aCache->GetWrapper());
1335
0
  if (aReflector) {
1336
#ifdef DEBUG
1337
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1338
#endif // DEBUG
1339
    return true;
1340
0
  }
1341
0
1342
0
  JSAutoRealm ar(aCx, global);
1343
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1344
0
  if (!canonicalProto) {
1345
0
    return false;
1346
0
  }
1347
0
  JS::Rooted<JSObject*> proto(aCx);
1348
0
  if (aGivenProto) {
1349
0
    proto = aGivenProto;
1350
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1351
0
    // coming in, we changed compartments to that of "parent" so may need
1352
0
    // to wrap the proto here.
1353
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1354
0
      if (!JS_WrapObject(aCx, &proto)) {
1355
0
        return false;
1356
0
      }
1357
0
    }
1358
0
  } else {
1359
0
    proto = canonicalProto;
1360
0
  }
1361
0
1362
0
  BindingJSObjectCreator<mozilla::dom::URL> creator(aCx);
1363
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1364
0
  if (!aReflector) {
1365
0
    return false;
1366
0
  }
1367
0
1368
0
  aCache->SetWrapper(aReflector);
1369
0
  creator.InitializationSucceeded();
1370
0
1371
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1372
0
             aCache->GetWrapperPreserveColor() == aReflector);
1373
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1374
0
  // otherwise we won't be able to properly recreate it later, since
1375
0
  // we won't know what proto to use.  Note that we don't check
1376
0
  // aGivenProto here, since it's entirely possible (and even
1377
0
  // somewhat common) to have a non-null aGivenProto which is the
1378
0
  // same as canonicalProto.
1379
0
  if (proto != canonicalProto) {
1380
0
    PreserveWrapper(aObject);
1381
0
  }
1382
0
1383
0
  return true;
1384
0
}
1385
1386
const NativePropertyHooks sNativePropertyHooks[] = { {
1387
  nullptr,
1388
  nullptr,
1389
  nullptr,
1390
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1391
  prototypes::id::URL,
1392
  constructors::id::URL,
1393
  nullptr,
1394
  &DefaultXrayExpandoObjectClass
1395
} };
1396
1397
void
1398
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1399
0
{
1400
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1401
0
  if (!parentProto) {
1402
0
    return;
1403
0
  }
1404
0
1405
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1406
0
  if (!constructorProto) {
1407
0
    return;
1408
0
  }
1409
0
1410
0
  static bool sIdsInited = false;
1411
0
  if (!sIdsInited && NS_IsMainThread()) {
1412
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1413
0
      return;
1414
0
    }
1415
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1416
0
      return;
1417
0
    }
1418
0
    sIdsInited = true;
1419
0
  }
1420
0
1421
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::URL);
1422
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::URL);
1423
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1424
0
                              &sPrototypeClass.mBase, protoCache,
1425
0
                              nullptr,
1426
0
                              constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1427
0
                              interfaceCache,
1428
0
                              sNativeProperties.Upcast(),
1429
0
                              sChromeOnlyNativeProperties.Upcast(),
1430
0
                              "URL", aDefineOnGlobal,
1431
0
                              nullptr,
1432
0
                              false);
1433
0
}
1434
1435
JSObject*
1436
GetConstructorObject(JSContext* aCx)
1437
0
{
1438
0
  return GetConstructorObjectHandle(aCx);
1439
0
}
1440
1441
} // namespace URL_Binding
1442
1443
1444
1445
} // namespace dom
1446
} // namespace mozilla