Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLScriptElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLScriptElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "HTMLElementBinding.h"
4
#include "HTMLScriptElementBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/Preferences.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/CustomElementRegistry.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/DocGroup.h"
12
#include "mozilla/dom/HTMLScriptElement.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/XrayExpandoClass.h"
17
#include "nsContentUtils.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
namespace binding_detail {}; // Just to make sure it's known as a namespace
23
using namespace mozilla::dom::binding_detail;
24
25
26
namespace HTMLScriptElement_Binding {
27
28
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value,
29
              "Can't inherit from an interface with a different ownership model.");
30
31
MOZ_CAN_RUN_SCRIPT static bool
32
get_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
33
0
{
34
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.src", DOM, cx);
35
0
36
0
  DOMString result;
37
0
  self->GetSrc(result);
38
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
39
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
40
0
    return false;
41
0
  }
42
0
  return true;
43
0
}
44
45
MOZ_CAN_RUN_SCRIPT static bool
46
set_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
47
0
{
48
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.src", DOM, cx);
49
0
50
0
  binding_detail::FakeString arg0;
51
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
52
0
    return false;
53
0
  }
54
0
  Maybe<AutoCEReaction> ceReaction;
55
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
56
0
    DocGroup* docGroup = self->GetDocGroup();
57
0
    if (docGroup) {
58
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
59
0
    }
60
0
  }
61
0
  FastErrorResult rv;
62
0
  nsIPrincipal* subjectPrincipal;
63
0
  {
64
0
    JS::Realm* realm = js::GetContextRealm(cx);
65
0
    MOZ_ASSERT(realm);
66
0
    JSPrincipals* principals = JS::GetRealmPrincipals(realm);
67
0
    nsIPrincipal* principal = nsJSPrincipals::get(principals);
68
0
    if (nsContentUtils::IsSystemPrincipal(principal)) {
69
0
      principal = nullptr;
70
0
    }
71
0
72
0
    subjectPrincipal = principal;
73
0
  }
74
0
  self->SetSrc(NonNullHelper(Constify(arg0)), subjectPrincipal, rv);
75
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
76
0
    return false;
77
0
  }
78
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
79
0
80
0
  return true;
81
0
}
82
83
static const JSJitInfo src_getterinfo = {
84
  { (JSJitGetterOp)get_src },
85
  { prototypes::id::HTMLScriptElement },
86
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
87
  JSJitInfo::Getter,
88
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
89
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
90
  false,  /* isInfallible. False in setters. */
91
  false,  /* isMovable.  Not relevant for setters. */
92
  false, /* isEliminatable.  Not relevant for setters. */
93
  false, /* isAlwaysInSlot.  Only relevant for getters. */
94
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
95
  false,  /* isTypedMethod.  Only relevant for methods. */
96
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
97
};
98
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
99
static_assert(0 < 1, "There is no slot for us");
100
static const JSJitInfo src_setterinfo = {
101
  { (JSJitGetterOp)set_src },
102
  { prototypes::id::HTMLScriptElement },
103
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
104
  JSJitInfo::Setter,
105
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
106
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
107
  false,  /* isInfallible. False in setters. */
108
  false,  /* isMovable.  Not relevant for setters. */
109
  false, /* isEliminatable.  Not relevant for setters. */
110
  false, /* isAlwaysInSlot.  Only relevant for getters. */
111
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
112
  false,  /* isTypedMethod.  Only relevant for methods. */
113
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
114
};
115
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
116
static_assert(0 < 1, "There is no slot for us");
117
118
MOZ_CAN_RUN_SCRIPT static bool
119
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
120
0
{
121
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.type", DOM, cx);
122
0
123
0
  DOMString result;
124
0
  self->GetType(result);
125
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
126
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
127
0
    return false;
128
0
  }
129
0
  return true;
130
0
}
131
132
MOZ_CAN_RUN_SCRIPT static bool
133
set_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
134
0
{
135
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.type", DOM, cx);
136
0
137
0
  binding_detail::FakeString arg0;
138
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
139
0
    return false;
140
0
  }
141
0
  Maybe<AutoCEReaction> ceReaction;
142
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
143
0
    DocGroup* docGroup = self->GetDocGroup();
144
0
    if (docGroup) {
145
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
146
0
    }
147
0
  }
148
0
  FastErrorResult rv;
149
0
  self->SetType(NonNullHelper(Constify(arg0)), rv);
150
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
151
0
    return false;
152
0
  }
153
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
154
0
155
0
  return true;
156
0
}
157
158
static const JSJitInfo type_getterinfo = {
159
  { (JSJitGetterOp)get_type },
160
  { prototypes::id::HTMLScriptElement },
161
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
162
  JSJitInfo::Getter,
163
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
164
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
165
  false,  /* isInfallible. False in setters. */
166
  false,  /* isMovable.  Not relevant for setters. */
167
  false, /* isEliminatable.  Not relevant for setters. */
168
  false, /* isAlwaysInSlot.  Only relevant for getters. */
169
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
170
  false,  /* isTypedMethod.  Only relevant for methods. */
171
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
172
};
173
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
174
static_assert(0 < 1, "There is no slot for us");
175
static const JSJitInfo type_setterinfo = {
176
  { (JSJitGetterOp)set_type },
177
  { prototypes::id::HTMLScriptElement },
178
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
179
  JSJitInfo::Setter,
180
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
181
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
182
  false,  /* isInfallible. False in setters. */
183
  false,  /* isMovable.  Not relevant for setters. */
184
  false, /* isEliminatable.  Not relevant for setters. */
185
  false, /* isAlwaysInSlot.  Only relevant for getters. */
186
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
187
  false,  /* isTypedMethod.  Only relevant for methods. */
188
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
189
};
190
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
191
static_assert(0 < 1, "There is no slot for us");
192
193
MOZ_CAN_RUN_SCRIPT static bool
194
get_noModule(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
195
0
{
196
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.noModule", DOM, cx);
197
0
198
0
  bool result(self->NoModule());
199
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
200
0
  args.rval().setBoolean(result);
201
0
  return true;
202
0
}
203
204
MOZ_CAN_RUN_SCRIPT static bool
205
set_noModule(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
206
0
{
207
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.noModule", DOM, cx);
208
0
209
0
  bool arg0;
210
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
211
0
    return false;
212
0
  }
213
0
  Maybe<AutoCEReaction> ceReaction;
214
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
215
0
    DocGroup* docGroup = self->GetDocGroup();
216
0
    if (docGroup) {
217
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
218
0
    }
219
0
  }
220
0
  FastErrorResult rv;
221
0
  self->SetNoModule(arg0, rv);
222
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
223
0
    return false;
224
0
  }
225
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
226
0
227
0
  return true;
228
0
}
229
230
static const JSJitInfo noModule_getterinfo = {
231
  { (JSJitGetterOp)get_noModule },
232
  { prototypes::id::HTMLScriptElement },
233
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
234
  JSJitInfo::Getter,
235
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
236
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
237
  true,  /* isInfallible. False in setters. */
238
  false,  /* isMovable.  Not relevant for setters. */
239
  false, /* isEliminatable.  Not relevant for setters. */
240
  false, /* isAlwaysInSlot.  Only relevant for getters. */
241
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
242
  false,  /* isTypedMethod.  Only relevant for methods. */
243
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
244
};
245
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
246
static_assert(0 < 1, "There is no slot for us");
247
static const JSJitInfo noModule_setterinfo = {
248
  { (JSJitGetterOp)set_noModule },
249
  { prototypes::id::HTMLScriptElement },
250
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
251
  JSJitInfo::Setter,
252
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
253
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
254
  false,  /* isInfallible. False in setters. */
255
  false,  /* isMovable.  Not relevant for setters. */
256
  false, /* isEliminatable.  Not relevant for setters. */
257
  false, /* isAlwaysInSlot.  Only relevant for getters. */
258
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
259
  false,  /* isTypedMethod.  Only relevant for methods. */
260
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
261
};
262
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
263
static_assert(0 < 1, "There is no slot for us");
264
265
MOZ_CAN_RUN_SCRIPT static bool
266
get_charset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
267
0
{
268
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.charset", DOM, cx);
269
0
270
0
  DOMString result;
271
0
  self->GetCharset(result);
272
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
273
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
274
0
    return false;
275
0
  }
276
0
  return true;
277
0
}
278
279
MOZ_CAN_RUN_SCRIPT static bool
280
set_charset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
281
0
{
282
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.charset", DOM, cx);
283
0
284
0
  binding_detail::FakeString arg0;
285
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
286
0
    return false;
287
0
  }
288
0
  Maybe<AutoCEReaction> ceReaction;
289
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
290
0
    DocGroup* docGroup = self->GetDocGroup();
291
0
    if (docGroup) {
292
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
293
0
    }
294
0
  }
295
0
  FastErrorResult rv;
296
0
  self->SetCharset(NonNullHelper(Constify(arg0)), rv);
297
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
298
0
    return false;
299
0
  }
300
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
301
0
302
0
  return true;
303
0
}
304
305
static const JSJitInfo charset_getterinfo = {
306
  { (JSJitGetterOp)get_charset },
307
  { prototypes::id::HTMLScriptElement },
308
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
309
  JSJitInfo::Getter,
310
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
311
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
312
  false,  /* isInfallible. False in setters. */
313
  false,  /* isMovable.  Not relevant for setters. */
314
  false, /* isEliminatable.  Not relevant for setters. */
315
  false, /* isAlwaysInSlot.  Only relevant for getters. */
316
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
317
  false,  /* isTypedMethod.  Only relevant for methods. */
318
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
319
};
320
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
321
static_assert(0 < 1, "There is no slot for us");
322
static const JSJitInfo charset_setterinfo = {
323
  { (JSJitGetterOp)set_charset },
324
  { prototypes::id::HTMLScriptElement },
325
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
326
  JSJitInfo::Setter,
327
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
328
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
329
  false,  /* isInfallible. False in setters. */
330
  false,  /* isMovable.  Not relevant for setters. */
331
  false, /* isEliminatable.  Not relevant for setters. */
332
  false, /* isAlwaysInSlot.  Only relevant for getters. */
333
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
334
  false,  /* isTypedMethod.  Only relevant for methods. */
335
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
336
};
337
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
338
static_assert(0 < 1, "There is no slot for us");
339
340
MOZ_CAN_RUN_SCRIPT static bool
341
get_async(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
342
0
{
343
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.async", DOM, cx);
344
0
345
0
  bool result(self->Async());
346
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
347
0
  args.rval().setBoolean(result);
348
0
  return true;
349
0
}
350
351
MOZ_CAN_RUN_SCRIPT static bool
352
set_async(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
353
0
{
354
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.async", DOM, cx);
355
0
356
0
  bool arg0;
357
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
358
0
    return false;
359
0
  }
360
0
  Maybe<AutoCEReaction> ceReaction;
361
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
362
0
    DocGroup* docGroup = self->GetDocGroup();
363
0
    if (docGroup) {
364
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
365
0
    }
366
0
  }
367
0
  FastErrorResult rv;
368
0
  self->SetAsync(arg0, rv);
369
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
370
0
    return false;
371
0
  }
372
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
373
0
374
0
  return true;
375
0
}
376
377
static const JSJitInfo async_getterinfo = {
378
  { (JSJitGetterOp)get_async },
379
  { prototypes::id::HTMLScriptElement },
380
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
381
  JSJitInfo::Getter,
382
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
383
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
384
  true,  /* isInfallible. False in setters. */
385
  false,  /* isMovable.  Not relevant for setters. */
386
  false, /* isEliminatable.  Not relevant for setters. */
387
  false, /* isAlwaysInSlot.  Only relevant for getters. */
388
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
389
  false,  /* isTypedMethod.  Only relevant for methods. */
390
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
391
};
392
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
393
static_assert(0 < 1, "There is no slot for us");
394
static const JSJitInfo async_setterinfo = {
395
  { (JSJitGetterOp)set_async },
396
  { prototypes::id::HTMLScriptElement },
397
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
398
  JSJitInfo::Setter,
399
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
400
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
401
  false,  /* isInfallible. False in setters. */
402
  false,  /* isMovable.  Not relevant for setters. */
403
  false, /* isEliminatable.  Not relevant for setters. */
404
  false, /* isAlwaysInSlot.  Only relevant for getters. */
405
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
406
  false,  /* isTypedMethod.  Only relevant for methods. */
407
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
408
};
409
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
410
static_assert(0 < 1, "There is no slot for us");
411
412
MOZ_CAN_RUN_SCRIPT static bool
413
get_defer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
414
0
{
415
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.defer", DOM, cx);
416
0
417
0
  bool result(self->Defer());
418
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
419
0
  args.rval().setBoolean(result);
420
0
  return true;
421
0
}
422
423
MOZ_CAN_RUN_SCRIPT static bool
424
set_defer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
425
0
{
426
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.defer", DOM, cx);
427
0
428
0
  bool arg0;
429
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
430
0
    return false;
431
0
  }
432
0
  Maybe<AutoCEReaction> ceReaction;
433
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
434
0
    DocGroup* docGroup = self->GetDocGroup();
435
0
    if (docGroup) {
436
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
437
0
    }
438
0
  }
439
0
  FastErrorResult rv;
440
0
  self->SetDefer(arg0, rv);
441
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
442
0
    return false;
443
0
  }
444
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
445
0
446
0
  return true;
447
0
}
448
449
static const JSJitInfo defer_getterinfo = {
450
  { (JSJitGetterOp)get_defer },
451
  { prototypes::id::HTMLScriptElement },
452
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
453
  JSJitInfo::Getter,
454
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
455
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
456
  true,  /* isInfallible. False in setters. */
457
  false,  /* isMovable.  Not relevant for setters. */
458
  false, /* isEliminatable.  Not relevant for setters. */
459
  false, /* isAlwaysInSlot.  Only relevant for getters. */
460
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
461
  false,  /* isTypedMethod.  Only relevant for methods. */
462
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
463
};
464
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
465
static_assert(0 < 1, "There is no slot for us");
466
static const JSJitInfo defer_setterinfo = {
467
  { (JSJitGetterOp)set_defer },
468
  { prototypes::id::HTMLScriptElement },
469
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
470
  JSJitInfo::Setter,
471
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
472
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
473
  false,  /* isInfallible. False in setters. */
474
  false,  /* isMovable.  Not relevant for setters. */
475
  false, /* isEliminatable.  Not relevant for setters. */
476
  false, /* isAlwaysInSlot.  Only relevant for getters. */
477
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
478
  false,  /* isTypedMethod.  Only relevant for methods. */
479
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
480
};
481
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
482
static_assert(0 < 1, "There is no slot for us");
483
484
MOZ_CAN_RUN_SCRIPT static bool
485
get_crossOrigin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
486
0
{
487
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.crossOrigin", DOM, cx);
488
0
489
0
  DOMString result;
490
0
  self->GetCrossOrigin(result);
491
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
492
0
  if (!xpc::StringToJsval(cx, result, args.rval())) {
493
0
    return false;
494
0
  }
495
0
  return true;
496
0
}
497
498
MOZ_CAN_RUN_SCRIPT static bool
499
set_crossOrigin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
500
0
{
501
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.crossOrigin", DOM, cx);
502
0
503
0
  binding_detail::FakeString arg0;
504
0
  if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) {
505
0
    return false;
506
0
  }
507
0
  Maybe<AutoCEReaction> ceReaction;
508
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
509
0
    DocGroup* docGroup = self->GetDocGroup();
510
0
    if (docGroup) {
511
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
512
0
    }
513
0
  }
514
0
  FastErrorResult rv;
515
0
  self->SetCrossOrigin(NonNullHelper(Constify(arg0)), rv);
516
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
517
0
    return false;
518
0
  }
519
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
520
0
521
0
  return true;
522
0
}
523
524
static const JSJitInfo crossOrigin_getterinfo = {
525
  { (JSJitGetterOp)get_crossOrigin },
526
  { prototypes::id::HTMLScriptElement },
527
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
528
  JSJitInfo::Getter,
529
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
530
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
531
  false,  /* isInfallible. False in setters. */
532
  false,  /* isMovable.  Not relevant for setters. */
533
  false, /* isEliminatable.  Not relevant for setters. */
534
  false, /* isAlwaysInSlot.  Only relevant for getters. */
535
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
536
  false,  /* isTypedMethod.  Only relevant for methods. */
537
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
538
};
539
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
540
static_assert(0 < 1, "There is no slot for us");
541
static const JSJitInfo crossOrigin_setterinfo = {
542
  { (JSJitGetterOp)set_crossOrigin },
543
  { prototypes::id::HTMLScriptElement },
544
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
545
  JSJitInfo::Setter,
546
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
547
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
548
  false,  /* isInfallible. False in setters. */
549
  false,  /* isMovable.  Not relevant for setters. */
550
  false, /* isEliminatable.  Not relevant for setters. */
551
  false, /* isAlwaysInSlot.  Only relevant for getters. */
552
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
553
  false,  /* isTypedMethod.  Only relevant for methods. */
554
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
555
};
556
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
557
static_assert(0 < 1, "There is no slot for us");
558
559
MOZ_CAN_RUN_SCRIPT static bool
560
get_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
561
0
{
562
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.text", DOM, cx);
563
0
564
0
  FastErrorResult rv;
565
0
  DOMString result;
566
0
  self->GetText(result, rv);
567
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
568
0
    return false;
569
0
  }
570
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
571
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
572
0
    return false;
573
0
  }
574
0
  return true;
575
0
}
576
577
MOZ_CAN_RUN_SCRIPT static bool
578
set_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
579
0
{
580
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.text", DOM, cx);
581
0
582
0
  binding_detail::FakeString arg0;
583
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
584
0
    return false;
585
0
  }
586
0
  Maybe<AutoCEReaction> ceReaction;
587
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
588
0
    DocGroup* docGroup = self->GetDocGroup();
589
0
    if (docGroup) {
590
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
591
0
    }
592
0
  }
593
0
  FastErrorResult rv;
594
0
  self->SetText(NonNullHelper(Constify(arg0)), rv);
595
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
596
0
    return false;
597
0
  }
598
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
599
0
600
0
  return true;
601
0
}
602
603
static const JSJitInfo text_getterinfo = {
604
  { (JSJitGetterOp)get_text },
605
  { prototypes::id::HTMLScriptElement },
606
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
607
  JSJitInfo::Getter,
608
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
609
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
610
  false,  /* isInfallible. False in setters. */
611
  false,  /* isMovable.  Not relevant for setters. */
612
  false, /* isEliminatable.  Not relevant for setters. */
613
  false, /* isAlwaysInSlot.  Only relevant for getters. */
614
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
615
  false,  /* isTypedMethod.  Only relevant for methods. */
616
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
617
};
618
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
619
static_assert(0 < 1, "There is no slot for us");
620
static const JSJitInfo text_setterinfo = {
621
  { (JSJitGetterOp)set_text },
622
  { prototypes::id::HTMLScriptElement },
623
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
624
  JSJitInfo::Setter,
625
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
626
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
627
  false,  /* isInfallible. False in setters. */
628
  false,  /* isMovable.  Not relevant for setters. */
629
  false, /* isEliminatable.  Not relevant for setters. */
630
  false, /* isAlwaysInSlot.  Only relevant for getters. */
631
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
632
  false,  /* isTypedMethod.  Only relevant for methods. */
633
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
634
};
635
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
636
static_assert(0 < 1, "There is no slot for us");
637
638
MOZ_CAN_RUN_SCRIPT static bool
639
get_event(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
640
0
{
641
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.event", DOM, cx);
642
0
643
0
  DOMString result;
644
0
  self->GetEvent(result);
645
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
646
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
647
0
    return false;
648
0
  }
649
0
  return true;
650
0
}
651
652
MOZ_CAN_RUN_SCRIPT static bool
653
set_event(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
654
0
{
655
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.event", DOM, cx);
656
0
657
0
  binding_detail::FakeString arg0;
658
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
659
0
    return false;
660
0
  }
661
0
  Maybe<AutoCEReaction> ceReaction;
662
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
663
0
    DocGroup* docGroup = self->GetDocGroup();
664
0
    if (docGroup) {
665
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
666
0
    }
667
0
  }
668
0
  FastErrorResult rv;
669
0
  self->SetEvent(NonNullHelper(Constify(arg0)), rv);
670
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
671
0
    return false;
672
0
  }
673
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
674
0
675
0
  return true;
676
0
}
677
678
static const JSJitInfo event_getterinfo = {
679
  { (JSJitGetterOp)get_event },
680
  { prototypes::id::HTMLScriptElement },
681
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
682
  JSJitInfo::Getter,
683
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
684
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
685
  false,  /* isInfallible. False in setters. */
686
  false,  /* isMovable.  Not relevant for setters. */
687
  false, /* isEliminatable.  Not relevant for setters. */
688
  false, /* isAlwaysInSlot.  Only relevant for getters. */
689
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
690
  false,  /* isTypedMethod.  Only relevant for methods. */
691
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
692
};
693
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
694
static_assert(0 < 1, "There is no slot for us");
695
static const JSJitInfo event_setterinfo = {
696
  { (JSJitGetterOp)set_event },
697
  { prototypes::id::HTMLScriptElement },
698
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
699
  JSJitInfo::Setter,
700
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
701
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
702
  false,  /* isInfallible. False in setters. */
703
  false,  /* isMovable.  Not relevant for setters. */
704
  false, /* isEliminatable.  Not relevant for setters. */
705
  false, /* isAlwaysInSlot.  Only relevant for getters. */
706
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
707
  false,  /* isTypedMethod.  Only relevant for methods. */
708
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
709
};
710
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
711
static_assert(0 < 1, "There is no slot for us");
712
713
MOZ_CAN_RUN_SCRIPT static bool
714
get_htmlFor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
715
0
{
716
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.htmlFor", DOM, cx);
717
0
718
0
  DOMString result;
719
0
  self->GetHtmlFor(result);
720
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
721
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
722
0
    return false;
723
0
  }
724
0
  return true;
725
0
}
726
727
MOZ_CAN_RUN_SCRIPT static bool
728
set_htmlFor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
729
0
{
730
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.htmlFor", DOM, cx);
731
0
732
0
  binding_detail::FakeString arg0;
733
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
734
0
    return false;
735
0
  }
736
0
  Maybe<AutoCEReaction> ceReaction;
737
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
738
0
    DocGroup* docGroup = self->GetDocGroup();
739
0
    if (docGroup) {
740
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
741
0
    }
742
0
  }
743
0
  FastErrorResult rv;
744
0
  self->SetHtmlFor(NonNullHelper(Constify(arg0)), rv);
745
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
746
0
    return false;
747
0
  }
748
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
749
0
750
0
  return true;
751
0
}
752
753
static const JSJitInfo htmlFor_getterinfo = {
754
  { (JSJitGetterOp)get_htmlFor },
755
  { prototypes::id::HTMLScriptElement },
756
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
757
  JSJitInfo::Getter,
758
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
759
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
760
  false,  /* isInfallible. False in setters. */
761
  false,  /* isMovable.  Not relevant for setters. */
762
  false, /* isEliminatable.  Not relevant for setters. */
763
  false, /* isAlwaysInSlot.  Only relevant for getters. */
764
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
765
  false,  /* isTypedMethod.  Only relevant for methods. */
766
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
767
};
768
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
769
static_assert(0 < 1, "There is no slot for us");
770
static const JSJitInfo htmlFor_setterinfo = {
771
  { (JSJitGetterOp)set_htmlFor },
772
  { prototypes::id::HTMLScriptElement },
773
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
774
  JSJitInfo::Setter,
775
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
776
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
777
  false,  /* isInfallible. False in setters. */
778
  false,  /* isMovable.  Not relevant for setters. */
779
  false, /* isEliminatable.  Not relevant for setters. */
780
  false, /* isAlwaysInSlot.  Only relevant for getters. */
781
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
782
  false,  /* isTypedMethod.  Only relevant for methods. */
783
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
784
};
785
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
786
static_assert(0 < 1, "There is no slot for us");
787
788
MOZ_CAN_RUN_SCRIPT static bool
789
get_integrity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitGetterCallArgs args)
790
0
{
791
0
  AUTO_PROFILER_LABEL_FAST("get HTMLScriptElement.integrity", DOM, cx);
792
0
793
0
  DOMString result;
794
0
  self->GetIntegrity(result);
795
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
796
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
797
0
    return false;
798
0
  }
799
0
  return true;
800
0
}
801
802
MOZ_CAN_RUN_SCRIPT static bool
803
set_integrity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLScriptElement* self, JSJitSetterCallArgs args)
804
0
{
805
0
  AUTO_PROFILER_LABEL_FAST("set HTMLScriptElement.integrity", DOM, cx);
806
0
807
0
  binding_detail::FakeString arg0;
808
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
809
0
    return false;
810
0
  }
811
0
  Maybe<AutoCEReaction> ceReaction;
812
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
813
0
    DocGroup* docGroup = self->GetDocGroup();
814
0
    if (docGroup) {
815
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
816
0
    }
817
0
  }
818
0
  FastErrorResult rv;
819
0
  self->SetIntegrity(NonNullHelper(Constify(arg0)), rv);
820
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
821
0
    return false;
822
0
  }
823
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
824
0
825
0
  return true;
826
0
}
827
828
static const JSJitInfo integrity_getterinfo = {
829
  { (JSJitGetterOp)get_integrity },
830
  { prototypes::id::HTMLScriptElement },
831
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
832
  JSJitInfo::Getter,
833
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
834
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
835
  false,  /* isInfallible. False in setters. */
836
  false,  /* isMovable.  Not relevant for setters. */
837
  false, /* isEliminatable.  Not relevant for setters. */
838
  false, /* isAlwaysInSlot.  Only relevant for getters. */
839
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
840
  false,  /* isTypedMethod.  Only relevant for methods. */
841
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
842
};
843
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
844
static_assert(0 < 1, "There is no slot for us");
845
static const JSJitInfo integrity_setterinfo = {
846
  { (JSJitGetterOp)set_integrity },
847
  { prototypes::id::HTMLScriptElement },
848
  { PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth },
849
  JSJitInfo::Setter,
850
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
851
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
852
  false,  /* isInfallible. False in setters. */
853
  false,  /* isMovable.  Not relevant for setters. */
854
  false, /* isEliminatable.  Not relevant for setters. */
855
  false, /* isAlwaysInSlot.  Only relevant for getters. */
856
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
857
  false,  /* isTypedMethod.  Only relevant for methods. */
858
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
859
};
860
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
861
static_assert(0 < 1, "There is no slot for us");
862
863
static bool
864
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
865
0
{
866
0
  mozilla::dom::HTMLScriptElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLScriptElement>(obj);
867
0
  // We don't want to preserve if we don't have a wrapper, and we
868
0
  // obviously can't preserve if we're not initialized.
869
0
  if (self && self->GetWrapperPreserveColor()) {
870
0
    PreserveWrapper(self);
871
0
  }
872
0
  return true;
873
0
}
874
875
static void
876
_finalize(js::FreeOp* fop, JSObject* obj)
877
0
{
878
0
  mozilla::dom::HTMLScriptElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLScriptElement>(obj);
879
0
  if (self) {
880
0
    ClearWrapper(self, self, obj);
881
0
    AddForDeferredFinalization<mozilla::dom::HTMLScriptElement>(self);
882
0
  }
883
0
}
884
885
static size_t
886
_objectMoved(JSObject* obj, JSObject* old)
887
0
{
888
0
  mozilla::dom::HTMLScriptElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLScriptElement>(obj);
889
0
  if (self) {
890
0
    UpdateWrapper(self, self, obj, old);
891
0
  }
892
0
893
0
  return 0;
894
0
}
895
896
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
897
#if defined(__clang__)
898
#pragma clang diagnostic push
899
#pragma clang diagnostic ignored "-Wmissing-braces"
900
#endif
901
static const JSPropertySpec sAttributes_specs[] = {
902
  { "src", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &src_getterinfo, GenericSetter<NormalThisPolicy>, &src_setterinfo },
903
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, GenericSetter<NormalThisPolicy>, &type_setterinfo },
904
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
905
  { "noModule", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &noModule_getterinfo, GenericSetter<NormalThisPolicy>, &noModule_setterinfo },
906
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
907
  { "charset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &charset_getterinfo, GenericSetter<NormalThisPolicy>, &charset_setterinfo },
908
  { "async", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &async_getterinfo, GenericSetter<NormalThisPolicy>, &async_setterinfo },
909
  { "defer", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &defer_getterinfo, GenericSetter<NormalThisPolicy>, &defer_setterinfo },
910
  { "crossOrigin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &crossOrigin_getterinfo, GenericSetter<NormalThisPolicy>, &crossOrigin_setterinfo },
911
  { "text", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &text_getterinfo, GenericSetter<NormalThisPolicy>, &text_setterinfo },
912
  { "event", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &event_getterinfo, GenericSetter<NormalThisPolicy>, &event_setterinfo },
913
  { "htmlFor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &htmlFor_getterinfo, GenericSetter<NormalThisPolicy>, &htmlFor_setterinfo },
914
  { "integrity", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &integrity_getterinfo, GenericSetter<NormalThisPolicy>, &integrity_setterinfo },
915
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
916
};
917
#if defined(__clang__)
918
#pragma clang diagnostic pop
919
#endif
920
921
// Can't be const because the pref-enabled boolean needs to be writable
922
static PrefableDisablers sAttributes_disablers3 = {
923
  true, false, 0, nullptr
924
};
925
926
static const Prefable<const JSPropertySpec> sAttributes[] = {
927
  { nullptr, &sAttributes_specs[0] },
928
  { &sAttributes_disablers3, &sAttributes_specs[3] },
929
  { nullptr, &sAttributes_specs[5] },
930
  { nullptr, nullptr }
931
};
932
933
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
934
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
935
static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
936
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
937
938
939
static uint16_t sNativeProperties_sortedPropertyIndices[11];
940
static PropertyInfo sNativeProperties_propertyInfos[11];
941
942
static const NativePropertiesN<1> sNativeProperties = {
943
  false, 0,
944
  false, 0,
945
  false, 0,
946
  true,  0 /* sAttributes */,
947
  false, 0,
948
  false, 0,
949
  false, 0,
950
  -1,
951
  11,
952
  sNativeProperties_sortedPropertyIndices,
953
  {
954
    { sAttributes, &sNativeProperties_propertyInfos[0] }
955
  }
956
};
957
static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
958
    "We have a property info count that is oversized");
959
960
static bool
961
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
962
0
{
963
0
  AUTO_PROFILER_LABEL_FAST("HTMLScriptElement constructor", DOM, cx);
964
0
965
0
  return HTMLConstructor(cx, argc, vp,
966
0
                         constructors::id::HTMLScriptElement,
967
0
                         prototypes::id::HTMLScriptElement,
968
0
                         CreateInterfaceObjects);
969
0
}
970
971
static const js::ClassOps sInterfaceObjectClassOps = {
972
    nullptr,               /* addProperty */
973
    nullptr,               /* delProperty */
974
    nullptr,               /* enumerate */
975
    nullptr,               /* newEnumerate */
976
    nullptr,               /* resolve */
977
    nullptr,               /* mayResolve */
978
    nullptr,               /* finalize */
979
    _constructor, /* call */
980
    nullptr,               /* hasInstance */
981
    _constructor, /* construct */
982
    nullptr,               /* trace */
983
};
984
985
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
986
  {
987
    "Function",
988
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
989
    &sInterfaceObjectClassOps,
990
    JS_NULL_CLASS_SPEC,
991
    JS_NULL_CLASS_EXT,
992
    &sInterfaceObjectClassObjectOps
993
  },
994
  eInterface,
995
  true,
996
  prototypes::id::HTMLScriptElement,
997
  PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth,
998
  sNativePropertyHooks,
999
  "function HTMLScriptElement() {\n    [native code]\n}",
1000
  HTMLElement_Binding::GetConstructorObject
1001
};
1002
1003
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1004
  {
1005
    "HTMLScriptElementPrototype",
1006
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1007
    JS_NULL_CLASS_OPS,
1008
    JS_NULL_CLASS_SPEC,
1009
    JS_NULL_CLASS_EXT,
1010
    JS_NULL_OBJECT_OPS
1011
  },
1012
  eInterfacePrototype,
1013
  false,
1014
  prototypes::id::HTMLScriptElement,
1015
  PrototypeTraits<prototypes::id::HTMLScriptElement>::Depth,
1016
  sNativePropertyHooks,
1017
  "[object HTMLScriptElementPrototype]",
1018
  HTMLElement_Binding::GetProtoObject
1019
};
1020
1021
static const js::ClassOps sClassOps = {
1022
  _addProperty, /* addProperty */
1023
  nullptr,               /* delProperty */
1024
  nullptr,               /* enumerate */
1025
  nullptr, /* newEnumerate */
1026
  nullptr, /* resolve */
1027
  nullptr, /* mayResolve */
1028
  _finalize, /* finalize */
1029
  nullptr, /* call */
1030
  nullptr,               /* hasInstance */
1031
  nullptr,               /* construct */
1032
  nullptr, /* trace */
1033
};
1034
1035
static const js::ClassExtension sClassExtension = {
1036
  nullptr, /* weakmapKeyDelegateOp */
1037
  _objectMoved /* objectMovedOp */
1038
};
1039
1040
static const DOMJSClass sClass = {
1041
  { "HTMLScriptElement",
1042
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1043
    &sClassOps,
1044
    JS_NULL_CLASS_SPEC,
1045
    &sClassExtension,
1046
    JS_NULL_OBJECT_OPS
1047
  },
1048
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLScriptElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1049
  IsBaseOf<nsISupports, mozilla::dom::HTMLScriptElement >::value,
1050
  sNativePropertyHooks,
1051
  FindAssociatedGlobalForNative<mozilla::dom::HTMLScriptElement>::Get,
1052
  GetProtoObjectHandle,
1053
  GetCCParticipant<mozilla::dom::HTMLScriptElement>::Get()
1054
};
1055
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1056
              "Must have the right minimal number of reserved slots.");
1057
static_assert(1 >= 1,
1058
              "Must have enough reserved slots.");
1059
1060
const JSClass*
1061
GetJSClass()
1062
0
{
1063
0
  return sClass.ToJSClass();
1064
0
}
1065
1066
bool
1067
Wrap(JSContext* aCx, mozilla::dom::HTMLScriptElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1068
0
{
1069
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLScriptElement>::value,
1070
0
                "Shouldn't have wrappercached things that are not refcounted.");
1071
0
  MOZ_ASSERT(static_cast<mozilla::dom::HTMLScriptElement*>(aObject) ==
1072
0
             reinterpret_cast<mozilla::dom::HTMLScriptElement*>(aObject),
1073
0
             "Multiple inheritance for mozilla::dom::HTMLScriptElement is broken.");
1074
0
  MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
1075
0
             reinterpret_cast<nsGenericHTMLElement*>(aObject),
1076
0
             "Multiple inheritance for nsGenericHTMLElement is broken.");
1077
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
1078
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
1079
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
1080
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
1081
0
             reinterpret_cast<nsINode*>(aObject),
1082
0
             "Multiple inheritance for nsINode is broken.");
1083
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1084
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1085
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1086
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1087
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1088
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1089
0
             "You should probably not be using Wrap() directly; use "
1090
0
             "GetOrCreateDOMReflector instead");
1091
0
1092
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1093
0
             "nsISupports must be on our primary inheritance chain");
1094
0
1095
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1096
0
  if (!global) {
1097
0
    return false;
1098
0
  }
1099
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1100
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1101
0
1102
0
  // That might have ended up wrapping us already, due to the wonders
1103
0
  // of XBL.  Check for that, and bail out as needed.
1104
0
  aReflector.set(aCache->GetWrapper());
1105
0
  if (aReflector) {
1106
#ifdef DEBUG
1107
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1108
#endif // DEBUG
1109
    return true;
1110
0
  }
1111
0
1112
0
  JSAutoRealm ar(aCx, global);
1113
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1114
0
  if (!canonicalProto) {
1115
0
    return false;
1116
0
  }
1117
0
  JS::Rooted<JSObject*> proto(aCx);
1118
0
  if (aGivenProto) {
1119
0
    proto = aGivenProto;
1120
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1121
0
    // coming in, we changed compartments to that of "parent" so may need
1122
0
    // to wrap the proto here.
1123
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1124
0
      if (!JS_WrapObject(aCx, &proto)) {
1125
0
        return false;
1126
0
      }
1127
0
    }
1128
0
  } else {
1129
0
    proto = canonicalProto;
1130
0
  }
1131
0
1132
0
  BindingJSObjectCreator<mozilla::dom::HTMLScriptElement> creator(aCx);
1133
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1134
0
  if (!aReflector) {
1135
0
    return false;
1136
0
  }
1137
0
1138
0
  aCache->SetWrapper(aReflector);
1139
0
  creator.InitializationSucceeded();
1140
0
1141
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1142
0
             aCache->GetWrapperPreserveColor() == aReflector);
1143
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1144
0
  // otherwise we won't be able to properly recreate it later, since
1145
0
  // we won't know what proto to use.  Note that we don't check
1146
0
  // aGivenProto here, since it's entirely possible (and even
1147
0
  // somewhat common) to have a non-null aGivenProto which is the
1148
0
  // same as canonicalProto.
1149
0
  if (proto != canonicalProto) {
1150
0
    PreserveWrapper(aObject);
1151
0
  }
1152
0
1153
0
  return true;
1154
0
}
1155
1156
const NativePropertyHooks sNativePropertyHooks[] = { {
1157
  nullptr,
1158
  nullptr,
1159
  nullptr,
1160
  { sNativeProperties.Upcast(), nullptr },
1161
  prototypes::id::HTMLScriptElement,
1162
  constructors::id::HTMLScriptElement,
1163
  HTMLElement_Binding::sNativePropertyHooks,
1164
  &DefaultXrayExpandoObjectClass
1165
} };
1166
1167
void
1168
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1169
0
{
1170
0
  JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx));
1171
0
  if (!parentProto) {
1172
0
    return;
1173
0
  }
1174
0
1175
0
  JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx));
1176
0
  if (!constructorProto) {
1177
0
    return;
1178
0
  }
1179
0
1180
0
  static bool sIdsInited = false;
1181
0
  if (!sIdsInited && NS_IsMainThread()) {
1182
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1183
0
      return;
1184
0
    }
1185
0
    sIdsInited = true;
1186
0
  }
1187
0
1188
0
  static bool sPrefCachesInited = false;
1189
0
  if (!sPrefCachesInited && NS_IsMainThread()) {
1190
0
    sPrefCachesInited = true;
1191
0
    Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "dom.moduleScripts.enabled");
1192
0
  }
1193
0
1194
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLScriptElement);
1195
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLScriptElement);
1196
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1197
0
                              &sPrototypeClass.mBase, protoCache,
1198
0
                              nullptr,
1199
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1200
0
                              interfaceCache,
1201
0
                              sNativeProperties.Upcast(),
1202
0
                              nullptr,
1203
0
                              "HTMLScriptElement", aDefineOnGlobal,
1204
0
                              nullptr,
1205
0
                              false);
1206
0
}
1207
1208
JSObject*
1209
GetConstructorObject(JSContext* aCx)
1210
0
{
1211
0
  return GetConstructorObjectHandle(aCx);
1212
0
}
1213
1214
} // namespace HTMLScriptElement_Binding
1215
1216
1217
1218
} // namespace dom
1219
} // namespace mozilla